tskrtt

Simple libev based gopher server
git clone https://git.inz.fi/tskrtt/
Log | Files | Refs | README

commit 7309eaa790b1ddd39b59b14e95b50b9385061d17
parent 57d3706f27f6a53eb4c264a05c3321c320b36778
Author: Santtu Lakkala <inz@inz.fi>
Date:   Mon, 17 May 2021 00:47:39 +0300

Improve gph handling

Diffstat:
Mmain.c | 17++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/main.c b/main.c @@ -985,15 +985,26 @@ static bool process_gph_line(EV_P_ struct client *c, char *line, size_t linelen) if (line[linelen - 1] == ']') line[--linelen] = '\0'; + if (!*type) + type = "i"; + if (*type == 'i' || *type == '3') { + if (!resource) + resource = "."; + if (!server) + server = "."; + if (!port) + port = "."; + } + if (!resource) return client_printf(c, "3Invalid line\r\n"); - if (!server || !strcmp(server, "server")) + if (!server || !*server || !strcmp(server, "server")) server = hostname; - else if (!port) + else if (!port || !*port) port = dfl_port; - if (!port || !strcmp(port, "port")) + if (!port || !*port || !strcmp(port, "port")) port = oport; if (strpfx(resource, "URI:") || strpfx(resource, "URL:") || *resource == '/' || strcmp(server, hostname) || strcmp(port, oport))