add i2p
This commit is contained in:
parent
b88bd19578
commit
b4008c58a2
|
@ -0,0 +1,13 @@
|
|||
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
|
||||
|
||||
ENTRYPOINT ["i2pd"]
|
|
@ -8,3 +8,11 @@ services:
|
|||
restart: unless-stopped
|
||||
ports:
|
||||
- 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
|
||||
|
|
|
@ -36,6 +36,7 @@ def index():
|
|||
nettype = request.args.get("nettype", "mainnet")
|
||||
crypto = request.args.get("crypto", "monero")
|
||||
onion = request.args.get("onion", False)
|
||||
i2p = request.args.get("i2p", False)
|
||||
nodes = Node.select().where(
|
||||
Node.validated==True
|
||||
).where(
|
||||
|
@ -47,6 +48,8 @@ def index():
|
|||
)
|
||||
if onion:
|
||||
nodes = nodes.where(Node.is_tor==True)
|
||||
if i2p:
|
||||
nodes = nodes.where(Node.is_i2p==True)
|
||||
|
||||
nodes = [n for n in nodes]
|
||||
shuffle(nodes)
|
||||
|
@ -255,6 +258,7 @@ def validate():
|
|||
node.datetime_checked = now
|
||||
node.crypto = crypto
|
||||
node.is_tor = is_onion(node.url)
|
||||
node.is_i2p = is_b32(node.url)
|
||||
node.save()
|
||||
else:
|
||||
logging.info("unexpected nettype")
|
||||
|
|
|
@ -4,5 +4,7 @@ SECRET_KEY = os.environ.get('SECRET_KEY', 'xxxx')
|
|||
DATA_DIR = os.environ.get('DATA_DIR', './data')
|
||||
TOR_HOST = os.environ.get('TOR_HOST', '127.0.0.1')
|
||||
TOR_PORT = os.environ.get('TOR_PORT', 9050)
|
||||
I2P_HOST = os.environ.get('I2P_HOST', '127.0.0.1')
|
||||
I2P_PORT = os.environ.get('I2P_PORT', 4447)
|
||||
NODE_HOST = os.environ.get('NODE_HOST', '127.0.0.1')
|
||||
NODE_PORT = os.environ.get('NODE_PORT', 18080)
|
||||
|
|
|
@ -16,6 +16,9 @@ def make_request(url: str, path="/get_info", data=None):
|
|||
if is_onion(url):
|
||||
proxies = {"http": f"socks5h://{config.TOR_HOST}:{config.TOR_PORT}"}
|
||||
timeout = 18
|
||||
if is_b32(url):
|
||||
proxies = {"http": f"socks5h://{config.I2P_HOST}:{config.I2P_PORT}"}
|
||||
timeout = 18
|
||||
else:
|
||||
proxies = None
|
||||
timeout = 6
|
||||
|
@ -58,6 +61,15 @@ def is_onion(url: str):
|
|||
else:
|
||||
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
|
||||
def rw_cache(key_name, data=None):
|
||||
pickle_file = path.join(config.DATA_DIR, f'{key_name}.pkl')
|
||||
|
|
|
@ -12,6 +12,7 @@ class Node(Model):
|
|||
id = AutoField()
|
||||
url = CharField(unique=True)
|
||||
is_tor = BooleanField(default=False)
|
||||
is_i2p = BooleanField(default=False)
|
||||
available = BooleanField(default=False)
|
||||
validated = BooleanField(default=False)
|
||||
nettype = CharField(null=True)
|
||||
|
|
Loading…
Reference in New Issue