From b3791e703d2c743bfe6eb0bea674890072d0eaf5 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 18 Jun 2020 21:56:29 +0100 Subject: [PATCH] Special accept case for i2p domains --- daemon.py | 19 ++++++++++++------- deploy/i2p | 5 ++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/daemon.py b/daemon.py index b1d20e952..aadfd6cdc 100644 --- a/daemon.py +++ b/daemon.py @@ -591,6 +591,11 @@ class PubServer(BaseHTTPRequestHandler): self._write(msg) return True + def _hasAccept(self, callingDomain: str) -> bool: + if self.headers.get('Accept') or callingDomain.endswith('.b32.i2p'): + return True + return False + def _mastoApi(self, callingDomain: str) -> bool: """This is a vestigil mastodon API for the purpose of returning an empty result to sites like @@ -622,7 +627,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.systemLanguage, self.server.projectVersion) msg = json.dumps(instanceJson).encode('utf-8') - if self.headers.get('Accept'): + if self._hasAccept(callingDomain): if 'application/ld+json' in self.headers['Accept']: self._set_headers('application/ld+json', len(msg), None, callingDomain) @@ -643,7 +648,7 @@ class PubServer(BaseHTTPRequestHandler): # information about the interests of a small number of accounts msg = json.dumps(['mastodon.social', self.server.domainFull]).encode('utf-8') - if self.headers.get('Accept'): + if self._hasAccept(callingDomain): if 'application/ld+json' in self.headers['Accept']: self._set_headers('application/ld+json', len(msg), None, callingDomain) @@ -659,7 +664,7 @@ class PubServer(BaseHTTPRequestHandler): if self.path.startswith('/api/v1/instance/activity'): # This is just a dummy result. msg = json.dumps([]).encode('utf-8') - if self.headers.get('Accept'): + if self._hasAccept(callingDomain): if 'application/ld+json' in self.headers['Accept']: self._set_headers('application/ld+json', len(msg), None, callingDomain) @@ -685,7 +690,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.projectVersion) if info: msg = json.dumps(info).encode('utf-8') - if self.headers.get('Accept'): + if self._hasAccept(callingDomain): if 'application/ld+json' in self.headers['Accept']: self._set_headers('application/ld+json', len(msg), None, callingDomain) @@ -745,7 +750,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.domainFull) if wfResult: msg = json.dumps(wfResult).encode('utf-8') - if self.headers.get('Accept'): + if self._hasAccept(callingDomain): if 'application/ld+json' in self.headers['Accept']: self._set_headers('application/ld+json', len(msg), None, callingDomain) @@ -1129,7 +1134,7 @@ class PubServer(BaseHTTPRequestHandler): if 'favicon.ico' in self.path: favType = 'image/x-icon' favFilename = 'favicon.ico' - if self.headers.get('Accept'): + if self._hasAccept(callingDomain): if 'image/webp' in self.headers['Accept']: favType = 'image/webp' favFilename = 'favicon.webp' @@ -1188,7 +1193,7 @@ class PubServer(BaseHTTPRequestHandler): # is this a html request? htmlGET = False - if self.headers.get('Accept'): + if self._hasAccept(callingDomain): if self._requestHTTP(): htmlGET = True else: diff --git a/deploy/i2p b/deploy/i2p index 462e74349..65b4c0721 100755 --- a/deploy/i2p +++ b/deploy/i2p @@ -115,7 +115,6 @@ if ! grep -q 'epicyon.dat' /var/lib/i2pd/tunnels.conf; then echo 'host = 127.0.0.1'; echo 'inport = 80'; echo "port = ${NGINX_PORT}"; - echo 'destination = epicyon.i2p'; echo 'inbound.length = 1'; echo 'inbound.quantity = 5'; echo 'outbound.length = 1'; @@ -387,6 +386,6 @@ ln -s /etc/nginx/sites-available/epicyon /etc/nginx/sites-enabled/ systemctl restart nginx echo "Your Epicyon i2p instance is now installed." -echo 'In Firefox see preferences/network settings, manual proxy and uncheck DNS over HTTPS' -echo "In a browser proxied through 127.0.0.1 port 4444 with socks5 proxy on 127.0.0.1 port 4447 navigate to http://${I2P_DOMAIN} and register an account" +echo 'In Firefox see preferences/network settings, manual proxy and uncheck DNS over HTTPS. In about:config and find the property media.peerConnection.ice.proxy_only and set it to true.' +echo "In a browser proxied through 127.0.0.1 port 4444 navigate to http://${I2P_DOMAIN} and register an account" exit 0