Respond with status 53 if an unknown hostname is requested

This commit is contained in:
Jaakko Keränen 2024-04-13 14:05:45 +03:00
parent cf91752b5b
commit d1905e688c
No known key found for this signature in database
GPG Key ID: BACCFCFB98DB2EDC
2 changed files with 7 additions and 0 deletions

View File

@ -57,6 +57,10 @@ v0.6.1:
* Static: Fixed unquoting URL paths when looking up files.
* Added example of printing Gemini meta line in CGI documentation.
v0.6.2:
* Respond with status 53 if an unknown hostname is requested. This helps reveal configuration errors where the correct hostnames are not specified.
### v0.5
* Added `processes` to the `[server]` section to configure how many request handler processes are started.

View File

@ -387,6 +387,9 @@ def handle_gemini_or_titan_request(request_data):
if stream.get_servername().decode() != hostname:
report_error(stream, 53, "Proxy request refused")
return
if stream.get_servername().decode() not in worker.cfg.hostnames():
report_error(stream, 53, f"Proxy request refused ({stream.get_servername().decode()})")
return
try:
status, meta, body, from_cache = worker.context.call_entrypoint(Request(