]> PatchyGit - patchyircd.git/commitdiff
apply a different hostname on 127.0.0.2
authorEgor <egor@patchysicp.xyz>
Fri, 26 Jan 2024 15:13:37 +0000 (17:13 +0200)
committerEgor <egor@patchysicp.xyz>
Fri, 26 Jan 2024 15:13:37 +0000 (17:13 +0200)
for the people who connect to the hidden service

src/main.c

index a7d39ea..1627ffc 100644 (file)
@@ -181,10 +181,18 @@ void accept_from_sock(struct listener *listener)
                cl->peername = mystrdup(client_addr);
                if (!cl->peername) abort();
                cl->peerport = port;
-               if (cctx || !strcmp(cl->peername, "127.0.0.1"))
+               if (cctx)
                        cl->umode |= UMODE_SECURE;
                extern const char *hostname;
-               cl->hostname = mystrdup(!strcmp(cl->peername, "127.0.0.1") ? "localhost" : hostname);
+               if (!strcmp(cl->peername, "127.0.0.1")) {
+                       cl->hostname = mystrdup("localhost");
+                       cl->umode |= UMODE_SECURE;
+               } else if (!strcmp(cl->peername, "127.0.0.2")) {
+                       cl->hostname = mystrdup("onion");
+                       cl->umode |= UMODE_SECURE;
+               } else {
+                       cl->hostname = mystrdup(hostname);
+               }
                if (!cl->hostname)
                        abort();
                net_poll_add(cl->FD, SOCKTYPE_CLIENT, cl);