relax the "wont proxy request" check: don't check the port number

Don't refuse to serve the request if the port number doesn't match the
one we're listening on, as initially suggested by Allen Sobot.

Complex setup may have a gmid instance reachable from multiple ports and
the meaning of the check in the first places was to avoid tricking
clients into thinking that we're serving for those domains: the port
number is way less important than the schema or domain name.

In the long run, the best way would probably to add a `listen on'
keyword for the servers blocks, just like OpenBSD' httpd, but gmid can't
listen on multiple ports/interfaces yet
This commit is contained in:
Omar Polo 2021-12-09 20:59:05 +00:00
parent 34c4ca6ebc
commit 52c92ef680
2 changed files with 3 additions and 2 deletions

View File

@ -1,5 +1,6 @@
2021-12-09 Omar Polo <op@omarpolo.com>
* server.c (client_read): don't check if the port in the request is the same we're listening on. Suggested by Allen Sobot, thanks!
* configure: add --prefix=... long argument.
2021-11-16 Omar Polo <op@omarpolo.com>

View File

@ -963,8 +963,8 @@ client_read(struct bufferevent *bev, void *d)
return;
}
if (c->iri.port_no != conf.port ||
strcmp(c->iri.schema, "gemini") ||
/* ignore the port number */
if (strcmp(c->iri.schema, "gemini") ||
strcmp(decoded, c->domain)) {
start_reply(c, PROXY_REFUSED, "won't proxy request");
return;