mirror of https://gitlab.com/bashrc2/epicyon
Special accept case for i2p domains
parent
46ff17f7c5
commit
b3791e703d
19
daemon.py
19
daemon.py
|
@ -591,6 +591,11 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self._write(msg)
|
self._write(msg)
|
||||||
return True
|
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:
|
def _mastoApi(self, callingDomain: str) -> bool:
|
||||||
"""This is a vestigil mastodon API for the purpose
|
"""This is a vestigil mastodon API for the purpose
|
||||||
of returning an empty result to sites like
|
of returning an empty result to sites like
|
||||||
|
@ -622,7 +627,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.systemLanguage,
|
self.server.systemLanguage,
|
||||||
self.server.projectVersion)
|
self.server.projectVersion)
|
||||||
msg = json.dumps(instanceJson).encode('utf-8')
|
msg = json.dumps(instanceJson).encode('utf-8')
|
||||||
if self.headers.get('Accept'):
|
if self._hasAccept(callingDomain):
|
||||||
if 'application/ld+json' in self.headers['Accept']:
|
if 'application/ld+json' in self.headers['Accept']:
|
||||||
self._set_headers('application/ld+json', len(msg),
|
self._set_headers('application/ld+json', len(msg),
|
||||||
None, callingDomain)
|
None, callingDomain)
|
||||||
|
@ -643,7 +648,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# information about the interests of a small number of accounts
|
# information about the interests of a small number of accounts
|
||||||
msg = json.dumps(['mastodon.social',
|
msg = json.dumps(['mastodon.social',
|
||||||
self.server.domainFull]).encode('utf-8')
|
self.server.domainFull]).encode('utf-8')
|
||||||
if self.headers.get('Accept'):
|
if self._hasAccept(callingDomain):
|
||||||
if 'application/ld+json' in self.headers['Accept']:
|
if 'application/ld+json' in self.headers['Accept']:
|
||||||
self._set_headers('application/ld+json', len(msg),
|
self._set_headers('application/ld+json', len(msg),
|
||||||
None, callingDomain)
|
None, callingDomain)
|
||||||
|
@ -659,7 +664,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if self.path.startswith('/api/v1/instance/activity'):
|
if self.path.startswith('/api/v1/instance/activity'):
|
||||||
# This is just a dummy result.
|
# This is just a dummy result.
|
||||||
msg = json.dumps([]).encode('utf-8')
|
msg = json.dumps([]).encode('utf-8')
|
||||||
if self.headers.get('Accept'):
|
if self._hasAccept(callingDomain):
|
||||||
if 'application/ld+json' in self.headers['Accept']:
|
if 'application/ld+json' in self.headers['Accept']:
|
||||||
self._set_headers('application/ld+json', len(msg),
|
self._set_headers('application/ld+json', len(msg),
|
||||||
None, callingDomain)
|
None, callingDomain)
|
||||||
|
@ -685,7 +690,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.projectVersion)
|
self.server.projectVersion)
|
||||||
if info:
|
if info:
|
||||||
msg = json.dumps(info).encode('utf-8')
|
msg = json.dumps(info).encode('utf-8')
|
||||||
if self.headers.get('Accept'):
|
if self._hasAccept(callingDomain):
|
||||||
if 'application/ld+json' in self.headers['Accept']:
|
if 'application/ld+json' in self.headers['Accept']:
|
||||||
self._set_headers('application/ld+json', len(msg),
|
self._set_headers('application/ld+json', len(msg),
|
||||||
None, callingDomain)
|
None, callingDomain)
|
||||||
|
@ -745,7 +750,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.domainFull)
|
self.server.domainFull)
|
||||||
if wfResult:
|
if wfResult:
|
||||||
msg = json.dumps(wfResult).encode('utf-8')
|
msg = json.dumps(wfResult).encode('utf-8')
|
||||||
if self.headers.get('Accept'):
|
if self._hasAccept(callingDomain):
|
||||||
if 'application/ld+json' in self.headers['Accept']:
|
if 'application/ld+json' in self.headers['Accept']:
|
||||||
self._set_headers('application/ld+json', len(msg),
|
self._set_headers('application/ld+json', len(msg),
|
||||||
None, callingDomain)
|
None, callingDomain)
|
||||||
|
@ -1129,7 +1134,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if 'favicon.ico' in self.path:
|
if 'favicon.ico' in self.path:
|
||||||
favType = 'image/x-icon'
|
favType = 'image/x-icon'
|
||||||
favFilename = 'favicon.ico'
|
favFilename = 'favicon.ico'
|
||||||
if self.headers.get('Accept'):
|
if self._hasAccept(callingDomain):
|
||||||
if 'image/webp' in self.headers['Accept']:
|
if 'image/webp' in self.headers['Accept']:
|
||||||
favType = 'image/webp'
|
favType = 'image/webp'
|
||||||
favFilename = 'favicon.webp'
|
favFilename = 'favicon.webp'
|
||||||
|
@ -1188,7 +1193,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
# is this a html request?
|
# is this a html request?
|
||||||
htmlGET = False
|
htmlGET = False
|
||||||
if self.headers.get('Accept'):
|
if self._hasAccept(callingDomain):
|
||||||
if self._requestHTTP():
|
if self._requestHTTP():
|
||||||
htmlGET = True
|
htmlGET = True
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -115,7 +115,6 @@ if ! grep -q 'epicyon.dat' /var/lib/i2pd/tunnels.conf; then
|
||||||
echo 'host = 127.0.0.1';
|
echo 'host = 127.0.0.1';
|
||||||
echo 'inport = 80';
|
echo 'inport = 80';
|
||||||
echo "port = ${NGINX_PORT}";
|
echo "port = ${NGINX_PORT}";
|
||||||
echo 'destination = epicyon.i2p';
|
|
||||||
echo 'inbound.length = 1';
|
echo 'inbound.length = 1';
|
||||||
echo 'inbound.quantity = 5';
|
echo 'inbound.quantity = 5';
|
||||||
echo 'outbound.length = 1';
|
echo 'outbound.length = 1';
|
||||||
|
@ -387,6 +386,6 @@ ln -s /etc/nginx/sites-available/epicyon /etc/nginx/sites-enabled/
|
||||||
systemctl restart nginx
|
systemctl restart nginx
|
||||||
|
|
||||||
echo "Your Epicyon i2p instance is now installed."
|
echo "Your Epicyon i2p instance is now installed."
|
||||||
echo 'In Firefox see preferences/network settings, manual proxy and uncheck DNS over HTTPS'
|
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 with socks5 proxy on 127.0.0.1 port 4447 navigate to http://${I2P_DOMAIN} and register an account"
|
echo "In a browser proxied through 127.0.0.1 port 4444 navigate to http://${I2P_DOMAIN} and register an account"
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue