phroxy

Gopher to HTTP proxy
git clone git://git.z3bra.org/phroxy.git
Log | Files | Refs | LICENSE

commit 7b716aa8cb5087d707b16615ffdaeedb930a5bcc
parent 60dbd05fe2fc35874ea32542f3849507f2787ce3
Author: Willy Goiffon <dev@z3bra.org>
Date:   Mon, 20 Sep 2021 10:41:05 +0200

Provide a static /robots.txt response

Diffstat:
Mconfig.def.h | 1+
Mphroxy.c | 13+++++++++++++
2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -9,6 +9,7 @@ const char *head = "</head>\n" "<body>\n"; const char *foot = "</body></html>\n"; +const char *robotstxt = "User-Agent: *\nDisallow: /\n"; const char *items[] = { [ITEM_0] = "📄", diff --git a/phroxy.c b/phroxy.c @@ -370,6 +370,16 @@ printhtml(int fd, const char *data, size_t len) } int +servebots() +{ + printf("HTTP/1.1 200 OK\r\n"); + printheaders("text/plain"); + printf("\r\n"); + write(1, robotstxt, strlen(robotstxt)); + return 0; +} + +int serveitem(char item, char *path, char *data, size_t len) { char *send; @@ -440,6 +450,9 @@ phroxy(char *url) char *hole, *path, *host, *port; char *data = NULL, *srch = NULL; + if (!strncmp(url, "/robots.txt", 10)) + return servebots(); + url++; hole = strsep(&url, "/"); if (!hole || !strnlen(hole, 1))