add checks for web compatible rpc nodes

pull/13/head
lza_menace 3 years ago
parent 508d074947
commit e94f0057bf

@ -37,12 +37,17 @@ def index():
crypto = request.args.get("crypto", "monero") crypto = request.args.get("crypto", "monero")
onion = request.args.get("onion", False) onion = request.args.get("onion", False)
show_all = "true" == request.args.get("all", "false") show_all = "true" == request.args.get("all", "false")
web_compatible = request.args.get("web_compatible", False)
nodes = Node.select().where( nodes = Node.select().where(
Node.validated == True, Node.validated == True,
Node.nettype == nettype, Node.nettype == nettype,
Node.crypto == crypto Node.crypto == crypto
) )
if web_compatible:
nodes = nodes.where(Node.web_compatible == True)
nodes_all = nodes.count() nodes_all = nodes.count()
nodes_unhealthy = nodes.where(Node.available == False).count() nodes_unhealthy = nodes.where(Node.available == False).count()
@ -65,7 +70,8 @@ def index():
nodes_unhealthy=nodes_unhealthy, nodes_unhealthy=nodes_unhealthy,
nettype=nettype, nettype=nettype,
crypto=crypto, crypto=crypto,
form=form form=form,
web_compatible=web_compatible
) )
@app.route("/nodes.json") @app.route("/nodes.json")
@ -80,7 +86,8 @@ def nodes_json():
return jsonify({ return jsonify({
"monero": { "monero": {
"clear": [n.url for n in xmr_nodes if n.is_tor == False], "clear": [n.url for n in xmr_nodes if n.is_tor == False],
"onion": [n.url for n in xmr_nodes if n.is_tor == True] "onion": [n.url for n in xmr_nodes if n.is_tor == True],
"web_compatible": [n.url for n in xmr_nodes if n.web_compatible == True],
}, },
"wownero": { "wownero": {
"clear": [n.url for n in wow_nodes if n.is_tor == False], "clear": [n.url for n in wow_nodes if n.is_tor == False],
@ -161,9 +168,12 @@ def check():
assert "status" in r.json() assert "status" in r.json()
assert "offline" in r.json() assert "offline" in r.json()
assert "height" in r.json() assert "height" in r.json()
has_cors = 'Access-Control-Allow-Origin' in r.headers
is_ssl = node.url.startswith('https://')
if r.json()["status"] == "OK": if r.json()["status"] == "OK":
logging.info("success") logging.info("success")
node.available = True node.available = True
node.web_compatible = has_cors and is_ssl
node.last_height = r.json()["height"] node.last_height = r.json()["height"]
hc.health = True hc.health = True
else: else:
@ -253,6 +263,8 @@ def validate():
r = make_request(node.url) r = make_request(node.url)
assert "height" in r.json() assert "height" in r.json()
assert "nettype" in r.json() assert "nettype" in r.json()
has_cors = 'Access-Control-Allow-Origin' in r.headers
is_ssl = node.url.startswith('https://')
nettype = r.json()["nettype"] nettype = r.json()["nettype"]
crypto = determine_crypto(node.url) crypto = determine_crypto(node.url)
logging.info("success") logging.info("success")
@ -260,6 +272,7 @@ def validate():
node.nettype = nettype node.nettype = nettype
node.available = True node.available = True
node.validated = True node.validated = True
node.web_compatible = has_cors and is_ssl
node.last_height = r.json()["height"] node.last_height = r.json()["height"]
node.datetime_checked = now node.datetime_checked = now
node.crypto = crypto node.crypto = crypto

@ -13,13 +13,14 @@ from xmrnodes import config
def make_request(url: str, path="/get_info", data=None): def make_request(url: str, path="/get_info", data=None):
headers = {"Origin": "https://monero.fail"}
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
else: else:
proxies = None proxies = None
timeout = 6 timeout = 6
r = r_get(url + path, timeout=timeout, proxies=proxies, json=data) r = r_get(url + path, timeout=timeout, proxies=proxies, json=data, headers=headers)
r.raise_for_status() r.raise_for_status()
return r return r

@ -14,6 +14,7 @@ class Node(Model):
is_tor = BooleanField(default=False) is_tor = BooleanField(default=False)
available = BooleanField(default=False) available = BooleanField(default=False)
validated = BooleanField(default=False) validated = BooleanField(default=False)
web_compatible = BooleanField(default=False)
nettype = CharField(null=True) nettype = CharField(null=True)
last_height = IntegerField(null=True) last_height = IntegerField(null=True)
crypto = CharField(null=True) crypto = CharField(null=True)

@ -79,3 +79,11 @@ input[type="text"] {
#nodes { #nodes {
padding-top: 1em; padding-top: 1em;
} }
.filter-green {
filter: invert(58%) sepia(20%) saturate(5505%) hue-rotate(67deg) brightness(101%) contrast(90%);
}
.filter-red {
filter: invert(16%) sepia(59%) saturate(5380%) hue-rotate(333deg) brightness(79%) contrast(101%);
}

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 489 489" style="enable-background:new 0 0 489 489;" xml:space="preserve">
<g>
<g>
<path d="M244.5,0C109.3,0,0,109.3,0,244.5S109.3,489,244.5,489S489,379.7,489,244.5S379.7,0,244.5,0z M244.5,448.4
c-112.4,0-203.9-91.5-203.9-203.9S132.1,40.6,244.5,40.6s203.9,91.5,203.9,203.9S356.9,448.4,244.5,448.4z"/>
<path d="M354.8,134.2c-8.3-8.3-20.8-8.3-29.1,0l-81.2,81.2l-81.1-81.1c-8.3-8.3-20.8-8.3-29.1,0s-8.3,20.8,0,29.1l81.1,81.1
l-81.1,81.1c-8.3,8.3-8.6,21.1,0,29.1c6.5,6,18.8,10.4,29.1,0l81.1-81.1l81.1,81.1c12.4,11.7,25,4.2,29.1,0
c8.3-8.3,8.3-20.8,0-29.1l-81.1-81.1l81.1-81.1C363.1,155,363.1,142.5,354.8,134.2z"/>
</g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="46px" height="46px" viewBox="0 0 46 46" style="enable-background:new 0 0 46 46;" xml:space="preserve">
<g>
<g>
<path d="M23,6c9.374,0,17,7.627,17,17c0,9.375-7.626,17-17,17S6,32.375,6,23C6,13.627,13.626,6,23,6 M23,0C10.298,0,0,10.298,0,23
c0,12.703,10.298,23,23,23s23-10.297,23-23C46,10.298,35.702,0,23,0L23,0z"/>
<g>
<path d="M20.887,32.482c-0.609,0.608-1.437,0.951-2.298,0.951c-0.861,0-1.689-0.343-2.298-0.951l-7.122-7.123
c-1.269-1.269-1.269-3.327,0-4.596c1.27-1.27,3.327-1.27,4.597,0l4.243,4.242c0.321,0.32,0.84,0.32,1.161,0l11.489-11.489
c1.271-1.27,3.327-1.27,4.597,0c1.27,1.27,1.27,3.327,0,4.597L20.887,32.482z"/>
</g>
</g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -33,6 +33,7 @@
<a href="{% if 'crypto' in request.args %}{{ request.url }}&{% else %}/?{% endif %}nettype=mainnet"><button class="pure-button search-btn">Mainnet</button></a> <a href="{% if 'crypto' in request.args %}{{ request.url }}&{% else %}/?{% endif %}nettype=mainnet"><button class="pure-button search-btn">Mainnet</button></a>
<a href="{% if 'crypto' in request.args %}{{ request.url }}&{% else %}/?{% endif %}nettype=testnet"><button class="pure-button search-btn">Testnet</button></a> <a href="{% if 'crypto' in request.args %}{{ request.url }}&{% else %}/?{% endif %}nettype=testnet"><button class="pure-button search-btn">Testnet</button></a>
<a href="{% if 'crypto' in request.args %}{{ request.url }}&{% else %}/?{% endif %}nettype=stagenet"><button class="pure-button search-btn">Stagenet</button></a> <a href="{% if 'crypto' in request.args %}{{ request.url }}&{% else %}/?{% endif %}nettype=stagenet"><button class="pure-button search-btn">Stagenet</button></a>
<a href="{% if 'crypto' in request.args %}{{ request.url }}&{% else %}/?{% endif %}web_compatible=true"><button class="pure-button search-btn">Web</button></a>
{% if 'onion' not in request.args %}<a href="{% if 'nettype' in request.args or 'crypto' in request.args %}{{ request.url }}&{% else %}/?{% endif %}onion=true"><button class="pure-button search-btn"><img src="/static/images/tor.svg" width=15px> Onion</button></a>{% endif %} {% if 'onion' not in request.args %}<a href="{% if 'nettype' in request.args or 'crypto' in request.args %}{{ request.url }}&{% else %}/?{% endif %}onion=true"><button class="pure-button search-btn"><img src="/static/images/tor.svg" width=15px> Onion</button></a>{% endif %}
<a href="/?crypto=wownero"><button class="pure-button search-btn wownero"><img src="/static/images/wownero.svg" width=50px></button></a> <a href="/?crypto=wownero"><button class="pure-button search-btn wownero"><img src="/static/images/wownero.svg" width=50px></button></a>
<a href="/"><button class="pure-button search-btn button-warning" style="border: dashed red;">x Clear</button></a> <a href="/"><button class="pure-button search-btn button-warning" style="border: dashed red;">x Clear</button></a>
@ -56,6 +57,7 @@
<tr> <tr>
<th>URL</th> <th>URL</th>
<th>Available</th> <th>Available</th>
<th>Web<br/>Compatible</th>
<th>Network</th> <th>Network</th>
<th>Date Added</th> <th>Date Added</th>
<th>Height</th> <th>Height</th>
@ -74,6 +76,13 @@
<span class="dot glowing-red""></span> <span class="dot glowing-red""></span>
{% endif %} {% endif %}
</td> </td>
<td>
{% if node.web_compatible %}
<img src="/static/images/success.svg" class="filter-green" width=16px>
{% else %}
<img src="/static/images/error.svg" class="filter-red" width=16px>
{% endif %}
</td>
<td>{{ node.nettype }}</td> <td>{{ node.nettype }}</td>
<td>{{ node.datetime_entered.strftime('%Y-%m-%d %H:%M') }} UTC <br/>({{ node.datetime_entered | humanize }})</td> <td>{{ node.datetime_entered.strftime('%Y-%m-%d %H:%M') }} UTC <br/>({{ node.datetime_entered | humanize }})</td>
<td>{{ node.last_height }}</td> <td>{{ node.last_height }}</td>

Loading…
Cancel
Save