| author | |
| committer | |
| log | b73fb93bbf37ad4de7502141fec2d1c1ff4f27fd |
| tree | 0d9e83b8ae2d5b373226ffef28c7e45fb4218ce6 |
| parent | 129b355b89c28ac75a69758310ca0e2f0a6b7d7c |
| signature | Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU |
4 files changed, 29 insertions(+), 6 deletions(-)
service/copyparty/copyparty.conf+2| ... | ... | @@ -55,5 +55,7 @@ |
| 55 | 55 | r: * |
| 56 | 56 | A: snow |
| 57 | 57 | flags: |
| 58 | md_hist: n | |
| 59 | zip_who: 2 | |
| 58 | 60 | chmod_f: 664 |
| 59 | 61 | chmod_d: 775 |
tools/router-zig-test.py+22-3| ... | ... | @@ -51,8 +51,8 @@ def main(): |
| 51 | 51 | port = listener.getsockname()[1] |
| 52 | 52 | lines = ['{', ' admin off', ' auto_https off', '}'] |
| 53 | 53 | with patch.dict(os.environ, {'SNOWGLOBE_STATE': temporary}): |
| 54 | for host, service in [('prod.localhost', 'copyparty'), ('paired.localhost', paired), ('unpaired.localhost', 'copyparty-preview-ffffffff')]: | |
| 55 | lines += [f'http://{host}:{port} {{', *router.zig_mirror_routes(service, routes), ' handle {', ' respond 204', ' }', '}'] | |
| 54 | for host, service in [('prod.localhost', 'copyparty'), ('paired.localhost', paired), ('unpaired.localhost', 'copyparty-preview-ffffffff'), ('missing.localhost', 'copyparty')]: | |
| 55 | lines += [f'http://{host}:{port} {{', *router.zig_mirror_routes(service, {} if host == 'missing.localhost' else routes), ' handle {', ' respond 204', ' }', '}'] | |
| 56 | 56 | conf = root / 'Caddyfile' |
| 57 | 57 | conf.write_text('\n'.join(lines)) |
| 58 | 58 | validated = subprocess.run([str(args.caddy), 'validate', '--config', str(conf), '--adapter', 'caddyfile'], capture_output=True, text=True) |
| ... | ... | @@ -89,9 +89,28 @@ def main(): |
| 89 | 89 | for path in ['/mirrors/zig/', '/mirrors/zig/releases/', '/mirrors/zig/dev/', '/mirrors/zig/releases/zig-0.0.0.tar.xz', |
| 90 | 90 | '/mirrors/zig/preadme.md', '/mirrors/zig/not-zig.zip']: |
| 91 | 91 | assert request(host, path) == (204, b'') |
| 92 | for path in ['/mirrors/zig/.hist/preadme.md', '/mirrors/zig/.mirror-locks/file', '/mirrors/.secret', | |
| 93 | '/mirrors/zig/nested/.secret/file', '/mirrors/zig/%2ehist/file', '/mirrors/zig/%2Ehist/file', | |
| 94 | '/mirrors/zig%2f.hist/file', '/mirrors/zig%2F.hist/file', '//mirrors///zig//.hist/file', | |
| 95 | '/mirrors/zig/normal/../.hist/file', '/before/../mirrors/zig/.hist/file', | |
| 96 | '/mirrors/zig/?doc=.secret', '/mirrors/zig/?DOC=%2esecret', | |
| 97 | '/mirrors/zig/?doc=readme.md&DOC=.secret', '/mirrors/zig/?DOC=.secret&doc=readme.md', | |
| 98 | '/mirrors/zig/?doc=%2Esecret', '/mirrors/zig/?x=1&DoC=.secret']: | |
| 99 | count = len(Mirror.requests) | |
| 100 | assert request(host, path) == (404, b''), path | |
| 101 | assert request(host, path, method='HEAD') == (404, b''), path | |
| 102 | assert len(Mirror.requests) == count | |
| 103 | for path in ['/media/zig/.hist/preadme.md', '/media/?doc=.secret', '/.static/copyparty.css', | |
| 104 | '/mirrors/zig/?download=1', '/mirrors/zig/?x=doc=readme.md', | |
| 105 | '/mirrors/zig/?doc=preadme.md', '/mirrors/zig/?doc=regular.zip', | |
| 106 | '/mirrors/zig/?DOC=visible.md', '/mirrors/zig/?doc', '/mirrors/zig/?x=1&DoC=visible.md']: | |
| 107 | assert request(host, path) == (204, b''), path | |
| 92 | 108 | assert request(host, archive, method='POST') == (204, b'') |
| 93 | 109 | count = len(Mirror.requests) |
| 94 | assert request('unpaired.localhost', archive) == (503, b'') | |
| 110 | for host in ['unpaired.localhost', 'missing.localhost']: | |
| 111 | assert request(host, archive) == (503, b'') | |
| 112 | assert request(host, '/mirrors/zig/.hist/file') == (404, b'') | |
| 113 | assert request(host, '/mirrors/zig/?DOC=.secret') == (404, b'') | |
| 95 | 114 | assert len(Mirror.requests) == count |
| 96 | 115 | finally: |
| 97 | 116 | caddy.terminate() |
tools/router.py+4-2| ... | ... | @@ -119,7 +119,9 @@ def zig_mirror_routes(service, routes): |
| 119 | 119 | mirror = None |
| 120 | 120 | upstreams = set().union(*(route["upstreams"] for route in routes.values() if mirror in route["services"])) |
| 121 | 121 | pattern = r"^/mirrors/zig/zig[^/]*\.(?:tar\.xz|zip)(?:\.minisig)?$" |
| 122 | lines = [" @zig_mirror {", " method GET HEAD", f" path_regexp zig_mirror {pattern}", " }", | |
| 122 | lines = [" @mirror_private expression `path_regexp('^/+mirrors(?:/+[^/]*)*/+[.]') || (path_regexp('^/+mirrors(?:/|$)') && {http.request.uri.query}.matches('(?i)(^|&)doc=(?:[.]|%2e)'))`", | |
| 123 | " handle @mirror_private {", " respond 404", " }", | |
| 124 | " @zig_mirror {", " method GET HEAD", f" path_regexp zig_mirror {pattern}", " }", | |
| 123 | 125 | " handle @zig_mirror {"] |
| 124 | 126 | if upstreams: |
| 125 | 127 | if any(not re.fullmatch(r"127\.0\.0\.1:[0-9]+|\[::1\]:[0-9]+", upstream) for upstream in upstreams): |
| ... | ... | @@ -349,7 +351,7 @@ def render(token): |
| 349 | 351 | continue |
| 350 | 352 | lines += [" tracing {", f" span {service}", " span_attributes {", |
| 351 | 353 | f" snowglobe.service {service}", " snowglobe.kind edge", " }", " }"] |
| 352 | if (service == "copyparty" and "zig-mirror" in internal_services) or re.fullmatch(r"copyparty-preview-[0-9a-f]{8}", service): | |
| 354 | if service == "copyparty" or re.fullmatch(r"copyparty-preview-[0-9a-f]{8}", service): | |
| 353 | 355 | lines += zig_mirror_routes(service, routes) |
| 354 | 356 | manifest = os.path.join(ROUTE_DIR, service + ".json") |
| 355 | 357 | assets = {} |
tools/zig-mirror.md+1-1| ... | ... | @@ -49,7 +49,7 @@ group. Run the mirror image's `verify` command against the copied destination |
| 49 | 49 | before publishing it. A disposable container can bind that exact subtree |
| 50 | 50 | read-only. The checksum and authenticity passes may run concurrently with |
| 51 | 51 | bounded CPU/I/O to reuse the filesystem cache. Both must finish successfully. |
| 52 | Retain old `.hist` metadata privately; anonymous users lack dot-file permission. | |
| 52 | Retain old `.hist` metadata privately; verify that public URLs cannot fetch it. | |
| 53 | 53 | |
| 54 | 54 | Promote the reviewed configuration through `tools/deploy.py prod`. Do not replace |
| 55 | 55 | containers by hand. Confirm anonymous GET/HEAD/Range on flat and nested URLs, |