aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2021-01-11 14:45:57 +0000
committerOmar Polo <op@omarpolo.com>2021-01-11 14:45:57 +0000
commit7b1d97903280066059ed4b00d4d407876957d071 (patch)
tree0f3ee57dfbb2e3d0942cae1ab020e00aa8d82993
parent6a9ae707737d978bccbabdc36beae509151a7be2 (diff)
reject non-gemini protocols with 531.4
-rw-r--r--ChangeLog1
-rw-r--r--gmid.c7
-rw-r--r--gmid.h1
3 files changed, 9 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 9f61b0a..eeb786f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
2021-01-11 Omar Polo <op@omarpolo.com>
* gmid.c (main): ipv6 disabled by default and -6 flag to enable it
+ (handle): reject non-gemini protocols with 53
2021-01-10 Omar Polo <op@omarpolo.com>
diff --git a/gmid.c b/gmid.c
index 0c1bed2..fca2ef6 100644
--- a/gmid.c
+++ b/gmid.c
@@ -600,6 +600,13 @@ handle(struct pollfd *fds, struct client *client)
return;
}
+ if (strcmp(iri.schema, "gemini")) {
+ if (!start_reply(fds, client, PROXY_REFUSED, "won't proxy request"))
+ return;
+ goodbye(fds, client);
+ return;
+ }
+
LOGI(client, "GET %s%s%s",
*iri.path ? iri.path : "/",
*iri.query ? "?" : "",
diff --git a/gmid.h b/gmid.h
index ecca57f..e145d1a 100644
--- a/gmid.h
+++ b/gmid.h
@@ -45,6 +45,7 @@
#define SUCCESS 20
#define TEMP_FAILURE 40
#define NOT_FOUND 51
+#define PROXY_REFUSED 53
#define BAD_REQUEST 59
#define MAX_USERS 64