aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authoronefang2019-11-23 21:53:06 +1000
committeronefang2019-11-23 21:53:06 +1000
commit4933e356ed5b85a33bda8ecc6098dea19307fd06 (patch)
tree223f6f5805375c6e58ce4c1c7d7af0313bb75796
parentUse --connect-to properly. (diff)
downloadapt-panopticon-4933e356ed5b85a33bda8ecc6098dea19307fd06.zip
apt-panopticon-4933e356ed5b85a33bda8ecc6098dea19307fd06.tar.gz
apt-panopticon-4933e356ed5b85a33bda8ecc6098dea19307fd06.tar.bz2
apt-panopticon-4933e356ed5b85a33bda8ecc6098dea19307fd06.tar.xz
Decode curl command return status.
Diffstat (limited to '')
-rwxr-xr-xapt-panopticon.lua103
1 files changed, 99 insertions, 4 deletions
diff --git a/apt-panopticon.lua b/apt-panopticon.lua
index a7d67d2..4b9e359 100755
--- a/apt-panopticon.lua
+++ b/apt-panopticon.lua
@@ -102,6 +102,100 @@ local arg = {}
102local sendArgs = "" 102local sendArgs = ""
103local logFile 103local logFile
104 104
105local curlStatus =
106{
107 [1 ] = "Unsupported protocol. This build of curl has no support for this protocol.",
108 [2 ] = "Failed to initialize.",
109 [3 ] = "URL malformed. The syntax was not correct.",
110 [4 ] = "A feature or option that was needed to perform the desired request was not enabled or was explicitly disabled at build-time. To make curl able to do this, you probably need another build of libcurl!",
111 [5 ] = "Couldn't resolve proxy. The given proxy host could not be resolved.",
112 [6 ] = "Couldn't resolve host. The given remote host was not resolved.",
113 [7 ] = "Failed to connect to host.",
114 [8 ] = "Weird server reply. The server sent data curl couldn't parse.",
115 [9 ] = "FTP access denied. The server denied login or denied access to the particular resource or directory you wanted to reach. Most often you tried to change to a directory that doesn't exist on the server.",
116
117 [11] = "FTP weird PASS reply. Curl couldn't parse the reply sent to the PASS request.",
118
119 [13] = "FTP weird PASV reply, Curl couldn't parse the reply sent to the PASV request.",
120 [14] = "FTP weird 227 format. Curl couldn't parse the 227-line the server sent.",
121 [15] = "FTP can't get host. Couldn't resolve the host IP we got in the 227-line.",
122
123 [17] = "FTP couldn't set binary. Couldn't change transfer method to binary.",
124 [18] = "Partial file. Only a part of the file was transferred.",
125 [19] = "FTP couldn't download/access the given file, the RETR (or similar) command failed.",
126
127 [21] = "FTP quote error. A quote command returned error from the server.",
128 [22] = "HTTP page not retrieved. The requested url was not found or returned another error with the HTTP error code being 400 or above. This return code only appears if -f, --fail is used.",
129 [23] = "Write error. Curl couldn't write data to a local filesystem or similar.",
130
131 [25] = "FTP couldn't STOR file. The server denied the STOR operation, used for FTP uploading.",
132 [26] = "Read error. Various reading problems.",
133 [27] = "Out of memory. A memory allocation request failed.",
134 [28] = "Operation timeout. The specified time-out period was reached according to the conditions.",
135
136 [30] = "FTP PORT failed. The PORT command failed. Not all FTP servers support the PORT command, try doing a transfer using PASV instead!",
137 [31] = "FTP couldn't use REST. The REST command failed. This command is used for resumed FTP transfers.",
138
139 [33] = "HTTP range error. The range \"command\" didn't work.",
140 [34] = "HTTP post error. Internal post-request generation error.",
141 [35] = "SSL connect error. The SSL handshaking failed.",
142 [36] = "FTP bad download resume. Couldn't continue an earlier aborted download.",
143 [37] = "FILE couldn't read file. Failed to open the file. Permissions?",
144 [38] = "LDAP cannot bind. LDAP bind operation failed.",
145 [39] = "LDAP search failed.",
146
147 [41] = "Function not found. A required LDAP function was not found.",
148 [42] = "Aborted by callback. An application told curl to abort the operation.",
149 [43] = "Internal error. A function was called with a bad parameter.",
150
151 [45] = "Interface error. A specified outgoing interface could not be used.",
152
153 [47] = "Too many redirects. When following redirects, curl hit the maximum amount.",
154 [48] = "Unknown option specified to libcurl. This indicates that you passed a weird option to curl that was passed on to libcurl and rejected. Read up in the manual!",
155 [49] = "Malformed telnet option.",
156
157 [51] = "The peer's SSL certificate or SSH MD5 fingerprint was not OK.",
158 [52] = "The server didn't reply anything, which here is considered an error.",
159 [53] = "SSL crypto engine not found.",
160 [54] = "Cannot set SSL crypto engine as default.",
161 [55] = "Failed sending network data.",
162 [56] = "Failure in receiving network data.",
163
164 [58] = "Problem with the local certificate.",
165 [59] = "Couldn't use specified SSL cipher.",
166 [60] = "Peer certificate cannot be authenticated with known CA certificates.",
167 [61] = "Unrecognized transfer encoding.",
168 [62] = "Invalid LDAP URL.",
169 [63] = "Maximum file size exceeded.",
170 [64] = "Requested FTP SSL level failed.",
171 [65] = "Sending the data requires a rewind that failed.",
172 [66] = "Failed to initialise SSL Engine.",
173 [67] = "The user name, password, or similar was not accepted and curl failed to log in.",
174 [68] = "File not found on TFTP server.",
175 [69] = "Permission problem on TFTP server.",
176 [70] = "Out of disk space on TFTP server.",
177 [71] = "Illegal TFTP operation.",
178 [72] = "Unknown TFTP transfer ID.",
179 [73] = "File already exists (TFTP).",
180 [74] = "No such user (TFTP).",
181 [75] = "Character conversion failed.",
182 [76] = "Character conversion functions required.",
183 [77] = "Problem with reading the SSL CA cert (path? access rights?).",
184 [78] = "The resource referenced in the URL does not exist.",
185 [79] = "An unspecified error occurred during the SSH session.",
186 [80] = "Failed to shut down the SSL connection.",
187
188 [82] = "Could not load CRL file, missing or wrong format (added in 7.19.0).",
189 [83] = "Issuer check failed (added in 7.19.0).",
190 [84] = "The FTP PRET command failed",
191 [85] = "RTSP: mismatch of CSeq numbers",
192 [86] = "RTSP: mismatch of Session Identifiers",
193 [87] = "unable to parse FTP file list",
194 [88] = "FTP chunk callback reported error",
195 [89] = "No connection available, the session will be queued",
196 [90] = "SSL public key does not matched pinned public key",
197}
198
105 199
106local socket = require 'socket' 200local socket = require 'socket'
107local ftp = require 'socket.ftp' 201local ftp = require 'socket.ftp'
@@ -236,7 +330,7 @@ local execute = function (s)
236 result = result .. status .. "\n" 330 result = result .. status .. "\n"
237 status = l 331 status = l
238 end 332 end
239 return 0 + status, result 333 return status, result
240end 334end
241 335
242local fork = function(s) 336local fork = function(s)
@@ -352,13 +446,14 @@ checkHEAD = function (host, URL, r, retry)
352 hdr .. ' -w "#%{http_code} %{ssl_verify_result} %{url_effective}\\n" ' .. PU.scheme .. '://' .. host .. PU.path .. ' >>results/"STATUS_' .. fname .. '"' 446 hdr .. ' -w "#%{http_code} %{ssl_verify_result} %{url_effective}\\n" ' .. PU.scheme .. '://' .. host .. PU.path .. ' >>results/"STATUS_' .. fname .. '"'
353 local status, result = execute(cmd) 447 local status, result = execute(cmd)
354 os.execute('cat results/"HEADERS_' .. fname .. '" >>results/"STATUS_' .. fname .. '" 2>/dev/null; rm results/"HEADERS_' .. fname .. '" 2>/dev/null') 448 os.execute('cat results/"HEADERS_' .. fname .. '" >>results/"STATUS_' .. fname .. '" 2>/dev/null; rm results/"HEADERS_' .. fname .. '" 2>/dev/null')
355 if 28 == status then 449 if "28" == status then
356 E(" TIMEOUT " .. timeouts + 1 .. ", retry " .. retry + 1, PU.scheme, "", host) 450 E(" TIMEOUT " .. timeouts + 1 .. ", retry " .. retry + 1, PU.scheme, "", host)
357 timeouts = timeouts + 1 451 timeouts = timeouts + 1
358 checkHEAD(host, URL, r, retry + 1, timeouts) 452 checkHEAD(host, URL, r, retry + 1, timeouts)
359 return 453 return
360 elseif 0 ~= status then 454 elseif "0" ~= status then
361 E(" The curl command return an error code of " .. status .. ", consult the curl manual for what this means.", PU.scheme, "", host) 455 local msg = curlStatus[0 + status]
456 E(" The curl command return an error code of " .. status .. "- " .. msg, PU.scheme, "", host)
362 checkHEAD(host, URL, r, retry + 1, timeouts) 457 checkHEAD(host, URL, r, retry + 1, timeouts)
363 return 458 return
364 end 459 end