i2p integration (#26)

* working on i2p integration

* finishing i2p setup

* fix comment

* include hidden txt for tor
revamp-ui
lalanza808 2 years ago committed by GitHub
parent 8fa675c273
commit 181b448379
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,29 @@
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
apt-get install wget sudo -y
WORKDIR /tmp/i2p
RUN wget https://github.com/PurpleI2P/i2pd/releases/download/2.47.0/i2pd_2.47.0-1jammy1_amd64.deb -O i2pd.deb -q
RUN apt install ./i2pd.deb -y
RUN rm -rf /tmp/i2p
RUN adduser \
--system \
--shell /bin/bash \
--gecos 'i2p' \
--group \
--disabled-password \
--home /home/i2p \
--uid 1000 \
i2p
COPY conf/i2p-entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
EXPOSE 4444
CMD /entrypoint.sh

@ -0,0 +1,9 @@
#!/bin/bash
chown -R i2p:i2p /home/i2p
# Run i2pd
sudo -u i2p i2pd \
--httpproxy.enabled 1 \
--httpproxy.address 0.0.0.0 \
--httpproxy.port 4444

@ -1,10 +1,20 @@
version: '3'
services:
tor:
container_name: tor
container_name: fail-tor
build:
context: .
dockerfile: Dockerfile-torsocks
dockerfile: Dockerfile-tor
restart: unless-stopped
ports:
- 127.0.0.1:9050:9050
i2p:
container_name: fail-i2p
build:
context: .
dockerfile: Dockerfile-i2p
restart: unless-stopped
ports:
- 127.0.0.1:4444:4444
volumes:
- ./data/i2pd:/home/i2p/.i2pd

@ -8,7 +8,7 @@ import requests
from flask import Blueprint
from urllib.parse import urlparse
from xmrnodes.helpers import determine_crypto, is_onion, make_request
from xmrnodes.helpers import determine_crypto, is_onion, is_i2p, make_request
from xmrnodes.helpers import retrieve_peers, rw_cache, get_highest_block
from xmrnodes.models import Node, HealthCheck, Peer
from xmrnodes import config
@ -171,6 +171,7 @@ def validate():
node.datetime_checked = now
node.crypto = crypto
node.is_tor = is_onion(node.url)
node.is_i2p = is_i2p(node.url)
node.save()
else:
logging.info("unexpected nettype")

@ -14,3 +14,5 @@ NODE_HOST = environ.get("NODE_HOST", "singapore.node.xmr.pm")
NODE_PORT = environ.get("NODE_PORT", 18080)
HEALTHY_BLOCK_DIFF = int(environ.get("HEALTHY_BLOCK_DIFF", 500))
PEER_LIFETIME = int(environ.get("PEER_LIFETIME", 96))
I2P_HOST = environ.get("I2P_HOST", "127.0.0.1")
I2P_PORT = environ.get("I2P_PORT", 4444)

@ -19,6 +19,10 @@ def make_request(url: str, path="/get_info", data=None):
_p = f"socks5h://{config.TOR_HOST}:{config.TOR_PORT}"
proxies = {"http": _p, "https": _p}
timeout = 30
elif is_i2p(url):
_p = f"http://{config.I2P_HOST}:{config.I2P_PORT}"
proxies = {"http": _p, "https": _p}
timeout = 30
else:
proxies = None
timeout = 10
@ -60,6 +64,14 @@ def determine_crypto(url):
except:
return "unknown"
def is_i2p(url: str):
_split = url.split(":")
if len(_split) < 2:
return False
if _split[1].endswith(".i2p"):
return True
else:
return False
def is_onion(url: str):
_split = url.split(":")

@ -14,6 +14,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)
web_compatible = BooleanField(default=False)

@ -19,6 +19,7 @@ def index():
nettype = request.args.get("network", "mainnet")
crypto = request.args.get("chain", "monero")
onion = request.args.get("onion", False)
i2p = request.args.get("i2p", False)
show_all = "true" == request.args.get("all", "false")
web_compatible = request.args.get("cors", False)
highest_block = get_highest_block(nettype, crypto)
@ -42,6 +43,8 @@ def index():
nodes = nodes.order_by(Node.datetime_entered.desc())
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)

@ -0,0 +1 @@
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 122.88 108.58"><title>internet-cloud</title><path d="M86.34,29.94c-.75.37-1.5.77-2.25,1.21a51.63,51.63,0,0,0-6.73,4.78l-4.84-5.54a39.41,39.41,0,0,1,5.41-4.21,37.64,37.64,0,0,1,4.76-2.65q1-.5,2-.93a29.42,29.42,0,0,0-13-12.2A31.6,31.6,0,0,0,55,7.49a30.21,30.21,0,0,0-15.62,6.1A29.27,29.27,0,0,0,28.68,31.73l-.48,2.51-2.5.44a34.43,34.43,0,0,0-6.56,1.77,21.94,21.94,0,0,0-5,2.66,16.8,16.8,0,0,0-3,2.79A17,17,0,0,0,7.34,53a20.13,20.13,0,0,0,3.79,11.54,18.9,18.9,0,0,0,3.17,3.4,16.05,16.05,0,0,0,3.07,2,33.37,33.37,0,0,0-.46,5.5c0,.77,0,1.53.08,2.28-.46-.16-.92-.33-1.36-.51a23.17,23.17,0,0,1-6.05-3.63,26.15,26.15,0,0,1-4.4-4.72A27.49,27.49,0,0,1,0,53,23.7,23.7,0,0,1,9.86,33.15a29,29,0,0,1,6.63-3.55A39.89,39.89,0,0,1,22,27.92,36.11,36.11,0,0,1,34.92,7.78,37.49,37.49,0,0,1,54.34.18a39,39,0,0,1,20.54,3.6A36.88,36.88,0,0,1,92,20.65a29.8,29.8,0,0,1,4.79-.36,24.55,24.55,0,0,1,18.31,8,28.35,28.35,0,0,1,3,3.9,32.93,32.93,0,0,1,4.77,17.92c-.07,6.3-1.78,12.59-5.25,17.21A27.32,27.32,0,0,1,109,74.69a32.27,32.27,0,0,1-3,1.5c0-.25,0-.5,0-.75a32.52,32.52,0,0,0-.78-7.07l.17-.09a20.32,20.32,0,0,0,6.4-5.41c2.5-3.33,3.73-8,3.78-12.87A25.55,25.55,0,0,0,112,36.14a21.47,21.47,0,0,0-2.25-2.9,17.38,17.38,0,0,0-13-5.61,25.39,25.39,0,0,0-10.41,2.31ZM56.56,46.35A28.25,28.25,0,0,0,50,48.26,30.52,30.52,0,0,0,44.91,51a27.93,27.93,0,0,0-4.34,3.57h0a29.47,29.47,0,0,0-2.35,2.65h8.56a67,67,0,0,1,9.79-10.87ZM87,90h.07a32.64,32.64,0,0,0,1.52-3.08l0-.09a28,28,0,0,0,1.68-5.45,29.27,29.27,0,0,0,.52-4.1h-8.2A29.44,29.44,0,0,1,78.88,90Zm-2.37,3.67H76.6a59.64,59.64,0,0,1-10,10.82l.77-.15a27.88,27.88,0,0,0,5.55-1.71,31.27,31.27,0,0,0,5-2.74,27.93,27.93,0,0,0,4.34-3.57h0a27.78,27.78,0,0,0,2.34-2.64Zm-12.6,0H63.27v8.85a62,62,0,0,0,8.79-8.85Zm-12.45,0H50.82a62,62,0,0,0,8.79,8.85V93.67Zm-13.33,0H38.21a29.35,29.35,0,0,0,2.35,2.64h0a27.93,27.93,0,0,0,4.34,3.57A31.27,31.27,0,0,0,50,102.63l.09,0a28.28,28.28,0,0,0,5.46,1.67l.77.15a59.64,59.64,0,0,1-10-10.82ZM35.78,90H44a29.3,29.3,0,0,1-3.78-12.72H32a28.52,28.52,0,0,0,2.23,9.64A32.7,32.7,0,0,0,35.78,90Zm12.45,0H59.61V77.28H43.88A26.76,26.76,0,0,0,48.23,90Zm15,0H74.65A26.87,26.87,0,0,0,79,77.28H63.27V90ZM32,73.61h8.27a31.46,31.46,0,0,1,4.16-12.72H35.78A31.49,31.49,0,0,0,34.26,64l0,.08a28.31,28.31,0,0,0-1.68,5.46,28.89,28.89,0,0,0-.52,4.1Zm11.94,0H59.61V60.89H48.71A29.16,29.16,0,0,0,44,73.61Zm19.31,0H78.92a29.16,29.16,0,0,0-4.75-12.72H63.27V73.61Zm19.32,0h8.27a28.89,28.89,0,0,0-.52-4.1A28.24,28.24,0,0,0,88.63,64a34,34,0,0,0-1.53-3.08H78.42a31.48,31.48,0,0,1,4.17,12.72ZM51.31,57.22h8.3v-8.7a67.76,67.76,0,0,0-8.3,8.7Zm12,0h8.3a67.76,67.76,0,0,0-8.3-8.7v8.7Zm12.84,0h8.55a27.89,27.89,0,0,0-2.34-2.65h0A27.93,27.93,0,0,0,78,51a30.52,30.52,0,0,0-5-2.74l-.09,0a28.31,28.31,0,0,0-5.46-1.68l-1.05-.19a67,67,0,0,1,9.79,10.87ZM48.52,44.9a32.55,32.55,0,0,1,12.92-2.59,33.85,33.85,0,0,1,6.65.64,31.45,31.45,0,0,1,6.17,1.91l.1,0A34.41,34.41,0,0,1,80,48a31.57,31.57,0,0,1,4.89,4,31,31,0,0,1,4,4.89A34.07,34.07,0,0,1,92,62.52a32,32,0,0,1,2,6.27,34.34,34.34,0,0,1,0,13.3A31.24,31.24,0,0,1,92,88.26l0,.11A34.07,34.07,0,0,1,88.92,94a32.47,32.47,0,0,1-4,4.89,32.06,32.06,0,0,1-4.9,4A34.45,34.45,0,0,1,74.36,106a31.34,31.34,0,0,1-6.27,1.94,34.34,34.34,0,0,1-13.3,0,31.42,31.42,0,0,1-6.17-1.9l-.1,0a35,35,0,0,1-5.65-3.07A32.57,32.57,0,0,1,34,94a34.87,34.87,0,0,1-3.07-5.64A32.81,32.81,0,0,1,28.3,75.44,33.93,33.93,0,0,1,29,68.79a32.11,32.11,0,0,1,1.9-6.17l0-.1A34.87,34.87,0,0,1,34,56.88,31.55,31.55,0,0,1,38,52a32.5,32.5,0,0,1,4.88-4,34.92,34.92,0,0,1,5.65-3.06Z"/></svg>

After

Width:  |  Height:  |  Size: 3.5 KiB

@ -0,0 +1,3 @@
<svg width="140" height="140" viewBox="0 0 140 140" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M118.352 20.7544C105.257 7.67428 87.8477 0.471191 69.3317 0.471191C50.8158 0.471191 33.4062 7.67428 20.3112 20.7544C7.21629 33.8344 0.00502883 51.2243 0.00502883 69.7193C0.00502883 85.0999 5.00363 99.697 14.2063 111.702L2.7608 123.135C-0.920266 126.812 -0.920266 132.769 2.7608 136.446C6.44186 140.123 12.406 140.123 16.0871 136.446L27.5627 124.983C39.5312 134.055 54.0543 138.967 69.3418 138.967C87.8577 138.967 105.267 131.764 118.362 118.684C131.457 105.604 138.668 88.2142 138.668 69.7193C138.658 51.2243 131.447 33.8344 118.352 20.7544ZM83.3218 106.589C83.3117 106.599 83.3117 106.599 83.3017 106.609C75.8993 113.993 63.8705 113.993 56.4681 106.609C49.0658 99.2148 49.0658 87.1996 56.4681 79.8056C60.1693 76.1086 65.0271 74.2601 69.8849 74.2601C74.7427 74.2601 79.6005 76.1086 83.3017 79.8056C90.694 87.1895 90.704 99.1947 83.3218 106.589ZM44.3789 67.7201C32.4306 79.6549 30.6403 97.949 38.9881 111.803C36.6246 110.346 34.422 108.608 32.4105 106.599C18.3802 92.5843 18.3802 69.7796 32.4105 55.7652C39.4306 48.753 48.6433 45.2569 57.8561 45.2569C67.0688 45.2569 76.2915 48.763 83.3017 55.7652C85.3132 57.7744 87.0431 59.9846 88.5014 62.3354C74.6421 53.9971 56.3273 55.7853 44.3789 67.7201ZM106.263 106.609C105.006 107.865 103.698 109.04 102.351 110.145C107.943 101.606 110.96 91.6299 110.96 81.1819C110.96 67.0169 105.438 53.6957 95.4109 43.6797C77.3476 25.6569 49.4278 23.3563 28.8501 36.7679C29.9665 35.4117 31.1432 34.0956 32.4105 32.8399C42.2769 22.9846 55.392 17.5597 69.3317 17.5597C83.2715 17.5597 96.3966 22.9846 106.263 32.8399C116.13 42.6952 121.561 55.7853 121.561 69.7193C121.561 83.6533 116.119 96.7535 106.263 106.609Z" fill="#000"/>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

@ -60,6 +60,11 @@
<input type="checkbox" name="onion" id="onion" {% if request.args.get('onion') == 'on' %}checked{% endif %}>
</span>
<span>
<label for="i2p">I2P:</label>
<input type="checkbox" name="i2p" id="i2p" {% if request.args.get('i2p') == 'on' %}checked{% endif %}>
</span>
<span>
<input type="submit" value="Filter" class="pure-button pure-pink">
</span>
@ -96,6 +101,7 @@
<table class="pure-table pure-table-horizontal pure-table-striped js-sort-table">
<thead>
<tr>
<th class="js-sort-string">Type</th>
<th class="js-sort-string">URL</th>
<th class="js-sort-number">Height</th>
<th class="js-sort-none">Up</th>
@ -109,7 +115,18 @@
{% for node in nodes %}
<tr class="js-sort-table">
<td>
{% if node.is_tor %}<img src="/static/images/tor.svg" width="15px">{% endif %}
{% if node.is_tor %}
<img src="/static/images/tor.svg" height="20px">
<span class="hidden">tor</span>
{% elif node.is_i2p %}
<img src="/static/images/i2p.svg" height="20px">
<span class="hidden">i2p</span>
{% else %}
<img src="/static/images/clearnet.svg" height="20px">
<span class="hidden">clear</span>
{% endif %}
</td>
<td>
<span class="nodeURL">{{ node.url }}</span>
{% if node.donation_address | seems_legit %}
<span class="donationAddress">{{ node.donation_address }}</span>

Loading…
Cancel
Save