diff options
| -rw-r--r-- | README.md | 167 | ||||
| -rwxr-xr-x | mirror-checker.lua | 2 |
2 files changed, 167 insertions, 2 deletions
| @@ -1,6 +1,8 @@ | |||
| 1 | Lua script for checking the health of Devuan Linux package mirrors. | 1 | Lua script for checking the health of Devuan Linux package mirrors. |
| 2 | 2 | ||
| 3 | This is currently under development, not everything has been written yet. | 3 | This is currently under development, not everything has been written yet. |
| 4 | Some of this document mentions some of the things that are not written | ||
| 5 | yet. | ||
| 4 | 6 | ||
| 5 | mirror-checker-lua is a Lua script used by the Devuan mirror admins | 7 | mirror-checker-lua is a Lua script used by the Devuan mirror admins |
| 6 | (maybe, if they like it) to check the health of Devuan Linux package | 8 | (maybe, if they like it) to check the health of Devuan Linux package |
| @@ -92,3 +94,166 @@ To only run the HTTP integrity tests, only on IPv6 - | |||
| 92 | 94 | ||
| 93 | $ ./mirror-checker.lua --tests=http,Integrity,IPv6 | 95 | $ ./mirror-checker.lua --tests=http,Integrity,IPv6 |
| 94 | 96 | ||
| 97 | |||
| 98 | The tests. | ||
| 99 | ---------- | ||
| 100 | |||
| 101 | The basic test is to find all the IPs for a mirror, including any CNAMES, | ||
| 102 | then send HTTP HEAD requests to those IPs, with HOST headers for that mirror, | ||
| 103 | and follow any redirections, doing the same for those redirections. | ||
| 104 | Unless a specific mirror is given on the command line, the mirror_list.txt | ||
| 105 | file from pkgmaster.devuan.org is used to select mirrors to test. | ||
| 106 | |||
| 107 | The --tests= option can be used to adjust the list of tests performed. | ||
| 108 | |||
| 109 | * IPv4, perform the tests with IPv4 addresses (A records) | ||
| 110 | * IPv6, perform the tests with IPv6 addresses (AAAA records) | ||
| 111 | * ftp, test FTP protocol access, check for the existence of the file instead of a HTTP HEAD. | ||
| 112 | * http, test HTTP protocol access. | ||
| 113 | * https, test HTTPS protocol access. | ||
| 114 | * rsync, test RSYNC protocol access. | ||
| 115 | * DNS-RR, ??????????????? | ||
| 116 | * Protocol, warn if the protocol changed during a test. | ||
| 117 | * URL-Sanity, add gratuitous multiple slashes to the URLs. | ||
| 118 | * Integrity, check PGP signatures. | ||
| 119 | * Updated, check Release dates. | ||
| 120 | |||
| 121 | The old tests include a "DNS-RR" test, I'm not sure what that is. I | ||
| 122 | guess it checks if the mirror responds properly if it's accessed via it's | ||
| 123 | DNS RR (round robin) IP, and a HOST header of deb.devuan.org. If no | ||
| 124 | other mirror is listed on the command line, we start with deb.devuan.org | ||
| 125 | and check all of it's IPs, which are the DNS RR mirrors anyway. | ||
| 126 | |||
| 127 | The mirror_list.txt file also used to select which protocols to test for | ||
| 128 | each mirror, it will only test those protocols the mirror lists as | ||
| 129 | supporting. | ||
| 130 | |||
| 131 | |||
| 132 | Options. | ||
| 133 | -------- | ||
| 134 | |||
| 135 | --help | ||
| 136 | |||
| 137 | Print the help text. | ||
| 138 | |||
| 139 | --version | ||
| 140 | |||
| 141 | Print the version. | ||
| 142 | |||
| 143 | --tests | ||
| 144 | |||
| 145 | Select which tests to run. The arguments are comma separated. A | ||
| 146 | negative argument deselects a test. Examples are given above. | ||
| 147 | |||
| 148 | --referenceSite | ||
| 149 | |||
| 150 | The mirror to use as a reference for the tests, the default is pkgmaster.devuan.org. | ||
| 151 | |||
| 152 | -v | ||
| 153 | |||
| 154 | Print more verbose output. Normally only CRITICAL and ERROR message sare | ||
| 155 | printed. -v will print WARNING messages as well, -v -v INFO messages, | ||
| 156 | and -v -v -v DEBUG messages. All messages are logged regardless. | ||
| 157 | |||
| 158 | -q | ||
| 159 | |||
| 160 | Only print CRITICAL messages. | ||
| 161 | |||
| 162 | -k | ||
| 163 | |||
| 164 | Keep any results from the previous runs, instead of deleting them before | ||
| 165 | running the tests. | ||
| 166 | |||
| 167 | -n | ||
| 168 | |||
| 169 | Don't fork the tests. Normally each mirror is run in its own fork. | ||
| 170 | |||
| 171 | |||
| 172 | Theory of operation. | ||
| 173 | -------------------- | ||
| 174 | |||
| 175 | Typically you would call it without any specific mirror mentioned on the | ||
| 176 | command line. I'll start the discussion from there. | ||
| 177 | |||
| 178 | Create the results directory. | ||
| 179 | |||
| 180 | If -k is not given, delete results/*.log. | ||
| 181 | |||
| 182 | Delete results/*.check. | ||
| 183 | |||
| 184 | touch results/stamp | ||
| 185 | |||
| 186 | Open results/mirror-checker-lua.log for message logging. | ||
| 187 | |||
| 188 | Download mirror_list.txt from the reference site. Build a table of | ||
| 189 | Active mirrors keyed by the FDQN, include the listed Protocols as a sub | ||
| 190 | table. Write this table to results/mirrors.lua so that the forked tests | ||
| 191 | can read it. | ||
| 192 | |||
| 193 | Remove the mirror site from the mirrors table, then CheckRedirects() it | ||
| 194 | first. | ||
| 195 | |||
| 196 | CheckRedirects() deb.devuan.org, the DNS RR. | ||
| 197 | |||
| 198 | Loop through the mirrors table, and CheckRedirects() each one. | ||
| 199 | |||
| 200 | Wait for all forked tests to finish. | ||
| 201 | |||
| 202 | Delete results/*.check. | ||
| 203 | |||
| 204 | |||
| 205 | The CheckRedirects() function does this - | ||
| 206 | |||
| 207 | If there is no second argument, then the host is set to the first | ||
| 208 | argument, otherwise the host is the second argument. | ||
| 209 | |||
| 210 | Gather the IPs for the host name with the following command - | ||
| 211 | |||
| 212 | dig +keepopen +noall +nottlid +answer example.com A example.com AAAA | ||
| 213 | example.com CNAME example.com SRV | sort -r | uniq | ||
| 214 | |||
| 215 | So it should end up with all the IPV4, IPV6, CNAME, and SRV records for | ||
| 216 | that host. | ||
| 217 | |||
| 218 | For each IPv4 and IPv6 address, fork a copy of the script something like | ||
| 219 | this (including any arguments originally provided to the script) - | ||
| 220 | |||
| 221 | ionice -c3 ./mirror-checker.lua example.com/path x.x.x.x & | ||
| 222 | |||
| 223 | ionice -c3 ./mirror-checker.lua example.com/path [x:x:x:x:x:x] & | ||
| 224 | |||
| 225 | For each CNAME, it CheckRedirects() the host, but with the CNAME as a | ||
| 226 | second argument. | ||
| 227 | |||
| 228 | SRV reconds don't do anything yet, coz I have yet to see one from my test | ||
| 229 | environment, so can't test it. | ||
| 230 | |||
| 231 | |||
| 232 | Each forked call of the script from above does this - | ||
| 233 | |||
| 234 | Open results/mirror-checker-lua_example.com_x.x.x.x.log for message | ||
| 235 | logging. | ||
| 236 | |||
| 237 | Loads the mirrors table from results/mirrors.lua. | ||
| 238 | |||
| 239 | If performing the Integrity or Updated testes, delete results/example.com | ||
| 240 | directory, downloads the reference files using wget. While it should | ||
| 241 | actually perform the Integrity and Updated tests now, those haven't been | ||
| 242 | written yet. Note that currently this downloads 4GB per mirror. | ||
| 243 | |||
| 244 | Calls CheckRedirects() with the host as first and second arguments, and | ||
| 245 | includes the IP this time. The inclusion of the IP causes | ||
| 246 | CheckRedirects() to call checkPaths(). | ||
| 247 | |||
| 248 | |||
| 249 | checkPaths() will call checkURL() for each of the reference files. | ||
| 250 | |||
| 251 | |||
| 252 | checkURL() uses LuaSocket (or LuaSec for HTTPS) to send a HEAD request to | ||
| 253 | the IP, with a Host header set to the original host name. Redirects will | ||
| 254 | not be followed by that request. If the request returns a redirect, then | ||
| 255 | checkURL() is called recursively. If the redirect is to some host we are | ||
| 256 | not already checking, we call CheckRedirects() on it, with an IP of | ||
| 257 | "redir". This causes CheckRedirects() to bypass the IP gathering | ||
| 258 | process, and call checkPaths() with the new host. | ||
| 259 | |||
diff --git a/mirror-checker.lua b/mirror-checker.lua index 6675a49..b2d1cc7 100755 --- a/mirror-checker.lua +++ b/mirror-checker.lua | |||
| @@ -411,7 +411,7 @@ if 0 ~= #args then | |||
| 411 | local option = "" | 411 | local option = "" |
| 412 | for i, a in pairs(args) do | 412 | for i, a in pairs(args) do |
| 413 | if ("--help" == a) or ("-h" == a) then | 413 | if ("--help" == a) or ("-h" == a) then |
| 414 | print("I should write some docs, huh?") | 414 | print("I should write some docs, huh? Read README.md for instructions.") |
| 415 | elseif "--version" == a then | 415 | elseif "--version" == a then |
| 416 | print("mirror-checker-lua version 0.1 WIP development version") | 416 | print("mirror-checker-lua version 0.1 WIP development version") |
| 417 | elseif "-v" == a then | 417 | elseif "-v" == a then |
