setting up i2p option

i2pd
lza_menace 3 years ago
parent f55dc9e893
commit f5cd0ebf15

@ -0,0 +1,15 @@
FROM ubuntu:20.04
RUN apt-get update && apt-get install i2pd -y
RUN mkdir -p /run/i2pd \
&& chown -R i2pd:i2pd /run/i2pd \
&& chmod 700 -R /run/i2pd
USER i2pd
EXPOSE 4447
EXPOSE 11744
EXPOSE 4444
ENTRYPOINT ["i2pd", "--socksproxy.address=0.0.0.0", "--httpproxy.address=0.0.0.0"]

@ -8,3 +8,11 @@ services:
restart: unless-stopped restart: unless-stopped
ports: ports:
- 127.0.0.1:9050:9050 - 127.0.0.1:9050:9050
i2pd:
container_name: i2p
build:
context: .
dockerfile: Dockerfile-i2pd
restart: unless-stopped
ports:
- 127.0.0.1:4447:4447

@ -14,7 +14,7 @@ from flask import Flask, request, redirect, jsonify
from flask import render_template, flash, url_for from flask import render_template, flash, url_for
from urllib.parse import urlparse from urllib.parse import urlparse
from xmrnodes.helpers import determine_crypto, is_onion, make_request from xmrnodes.helpers import determine_crypto, is_onion, is_b32, make_request
from xmrnodes.helpers import retrieve_peers, rw_cache from xmrnodes.helpers import retrieve_peers, rw_cache
from xmrnodes.forms import SubmitNode from xmrnodes.forms import SubmitNode
from xmrnodes.models import Node, HealthCheck, Peer from xmrnodes.models import Node, HealthCheck, Peer
@ -36,6 +36,7 @@ def index():
nettype = request.args.get("nettype", "mainnet") nettype = request.args.get("nettype", "mainnet")
crypto = request.args.get("crypto", "monero") crypto = request.args.get("crypto", "monero")
onion = request.args.get("onion", False) onion = request.args.get("onion", False)
i2p = request.args.get("i2p", False)
nodes = Node.select().where( nodes = Node.select().where(
Node.validated==True Node.validated==True
).where( ).where(
@ -47,6 +48,8 @@ def index():
) )
if onion: if onion:
nodes = nodes.where(Node.is_tor==True) nodes = nodes.where(Node.is_tor==True)
if i2p:
nodes = nodes.where(Node.is_i2p==True)
nodes = [n for n in nodes] nodes = [n for n in nodes]
shuffle(nodes) shuffle(nodes)
@ -255,6 +258,7 @@ def validate():
node.datetime_checked = now node.datetime_checked = now
node.crypto = crypto node.crypto = crypto
node.is_tor = is_onion(node.url) node.is_tor = is_onion(node.url)
node.is_i2p = is_b32(node.url)
node.save() node.save()
else: else:
logging.info("unexpected nettype") logging.info("unexpected nettype")
@ -272,6 +276,8 @@ def validate():
node.delete_instance() node.delete_instance()
except Exception as e: except Exception as e:
logging.info("failed for reasons unknown") logging.info("failed for reasons unknown")
if app.debug:
logging.info(e)
node.delete_instance() node.delete_instance()
@app.cli.command("export") @app.cli.command("export")

@ -6,3 +6,5 @@ TOR_HOST = os.environ.get('TOR_HOST', '127.0.0.1')
TOR_PORT = os.environ.get('TOR_PORT', 9050) TOR_PORT = os.environ.get('TOR_PORT', 9050)
NODE_HOST = os.environ.get('NODE_HOST', '127.0.0.1') NODE_HOST = os.environ.get('NODE_HOST', '127.0.0.1')
NODE_PORT = os.environ.get('NODE_PORT', 18080) NODE_PORT = os.environ.get('NODE_PORT', 18080)
I2P_HOST = os.environ.get('I2P_HOST', '127.0.0.1')
I2P_PORT = os.environ.get('I2P_PORT', 4447)

@ -16,6 +16,9 @@ def make_request(url: str, path="/get_info", data=None):
if is_onion(url): if is_onion(url):
proxies = {"http": f"socks5h://{config.TOR_HOST}:{config.TOR_PORT}"} proxies = {"http": f"socks5h://{config.TOR_HOST}:{config.TOR_PORT}"}
timeout = 18 timeout = 18
elif is_b32(url):
proxies = {"http": f"socks5h://{config.I2P_HOST}:{config.I2P_PORT}"}
timeout = 18
else: else:
proxies = None proxies = None
timeout = 6 timeout = 6
@ -58,6 +61,15 @@ def is_onion(url: str):
else: else:
return False return False
def is_b32(url: str):
_split = url.split(":")
if len(_split) < 2:
return False
if _split[1].endswith(".i2p"):
return True
else:
return False
# Use hacky filesystem cache since i dont feel like shipping redis # Use hacky filesystem cache since i dont feel like shipping redis
def rw_cache(key_name, data=None): def rw_cache(key_name, data=None):
pickle_file = path.join(config.DATA_DIR, f'{key_name}.pkl') pickle_file = path.join(config.DATA_DIR, f'{key_name}.pkl')

@ -12,6 +12,7 @@ class Node(Model):
id = AutoField() id = AutoField()
url = CharField(unique=True) url = CharField(unique=True)
is_tor = BooleanField(default=False) is_tor = BooleanField(default=False)
is_i2p = BooleanField(default=False)
available = BooleanField(default=False) available = BooleanField(default=False)
validated = BooleanField(default=False) validated = BooleanField(default=False)
nettype = CharField(null=True) nettype = CharField(null=True)

@ -0,0 +1,3 @@
<svg width="340" height="140" viewBox="0 0 340 140" fill="none" xmlns="http://www.w3.org/2000/svg"><title>i2p icon</title>
<path d="M118.352 20.855C105.257 7.77487 87.8477 0.571777 69.3317 0.571777C50.8158 0.571777 33.4062 7.77487 20.3112 20.855C7.21629 33.935 0.00502883 51.3249 0.00502883 69.8199C0.00502883 85.2005 5.00363 99.7976 14.2063 111.803L2.7608 123.235C-0.920266 126.912 -0.920266 132.87 2.7608 136.546C6.44186 140.223 12.406 140.223 16.0871 136.546L27.5627 125.084C39.5312 134.155 54.0543 139.068 69.3418 139.068C87.8577 139.068 105.267 131.865 118.362 118.785C131.457 105.705 138.668 88.3148 138.668 69.8199C138.658 51.3249 131.447 33.935 118.352 20.855ZM83.3218 106.689C83.3117 106.699 83.3117 106.699 83.3017 106.709C75.8993 114.093 63.8705 114.093 56.4681 106.709C49.0658 99.3154 49.0658 87.3002 56.4681 79.9062C60.1693 76.2092 65.0271 74.3607 69.8849 74.3607C74.7427 74.3607 79.6005 76.2092 83.3017 79.9062C90.694 87.2901 90.704 99.2953 83.3218 106.689ZM44.3789 67.8207C32.4306 79.7555 30.6403 98.0496 38.9881 111.903C36.6246 110.447 34.422 108.709 32.4105 106.699C18.3802 92.6849 18.3802 69.8802 32.4105 55.8658C39.4306 48.8536 48.6433 45.3575 57.8561 45.3575C67.0688 45.3575 76.2915 48.8636 83.3017 55.8658C85.3132 57.875 87.0431 60.0852 88.5014 62.436C74.6421 54.0977 56.3273 55.8859 44.3789 67.8207ZM106.263 106.709C105.006 107.965 103.698 109.141 102.351 110.246C107.943 101.706 110.96 91.7305 110.96 81.2825C110.96 67.1175 105.438 53.7963 95.4109 43.7803C77.3476 25.7575 49.4278 23.4569 28.8501 36.8685C29.9665 35.5123 31.1432 34.1962 32.4105 32.9405C42.2769 23.0852 55.392 17.6603 69.3317 17.6603C83.2715 17.6603 96.3966 23.0852 106.263 32.9405C116.13 42.7957 121.561 55.8859 121.561 69.8199C121.561 83.7539 116.119 96.8541 106.263 106.709Z" fill="black"/>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

Loading…
Cancel
Save