fetch and display onion addresses for nodes

master
lza_menace 4 years ago
parent 55da2573a4
commit 6856fcc8ae

@ -22,6 +22,24 @@ class Cache(object):
value=data value=data
) )
def get_tor_url(self, codename):
key_name = f'node_{codename}_tor_url'
data = self.redis.get(key_name)
if data:
current_app.logger.info(f'HIT - {key_name}')
return data
else:
current_app.logger.info(f'MISS - {key_name}')
try:
dns = f'{codename}.node.{config.DO_DOMAIN}'
url = f'https://{dns}/tor/'
r = r_get(url, timeout=6)
data = r.text.strip()
self.store_data(key_name, 86400, data)
return data
except:
return {'error': 'true'}
def get_info(self, codename): def get_info(self, codename):
key_name = f'node_{codename}_info' key_name = f'node_{codename}_info'
data = self.redis.get(key_name) data = self.redis.get(key_name)

@ -29,6 +29,10 @@ class Operation(db.Model):
record_v4_id = db.Column(db.Integer, unique=True, nullable=True) record_v4_id = db.Column(db.Integer, unique=True, nullable=True)
record_v6_id = db.Column(db.Integer, unique=True, nullable=True) record_v6_id = db.Column(db.Integer, unique=True, nullable=True)
def get_node_tor_url(self):
u = cache.get_tor_url(self.codename)
return u.decode()
def get_node_url(self): def get_node_url(self):
return f'{self.codename}.node.{config.DO_DOMAIN}' return f'{self.codename}.node.{config.DO_DOMAIN}'

@ -37,7 +37,11 @@
<td>{{ op.codename }}</td> <td>{{ op.codename }}</td>
<td>{{ op.create_date }}</td> <td>{{ op.create_date }}</td>
<td>{{ op.region }}</td> <td>{{ op.region }}</td>
<td>{{ op.get_node_url() }}</td> <td>
{{ op.get_node_url() }}
<br />
{{ op.get_node_tor_url() }}
</td>
<td id="{{ op.codename }}-status"><i class="fa fa-sync-alt fa-spin"></i> Checking</td> <td id="{{ op.codename }}-status"><i class="fa fa-sync-alt fa-spin"></i> Checking</td>
<td><a class="is-link" href="https://{{ op.get_node_url() }}/d/0ktA4KDGk/daemon-stats?orgId=1&refresh=30s&from=now-6h&to=now" target="_blank">View Stats</a></td> <td><a class="is-link" href="https://{{ op.get_node_url() }}/d/0ktA4KDGk/daemon-stats?orgId=1&refresh=30s&from=now-6h&to=now" target="_blank">View Stats</a></td>
</tr> </tr>

Loading…
Cancel
Save