mirror of https://github.com/nucypher/nucypher.git
Restore the horoscopes
parent
9ce7d50352
commit
3fd2605c77
|
@ -16,20 +16,23 @@ along with nucypher. If not, see <https://www.gnu.org/licenses/>.
|
|||
"""
|
||||
|
||||
import binascii
|
||||
import os
|
||||
from typing import Tuple
|
||||
|
||||
import os
|
||||
from bytestring_splitter import VariableLengthBytestring
|
||||
from constant_sorrow import constants
|
||||
from constant_sorrow.constants import FLEET_STATES_MATCH, NO_KNOWN_NODES
|
||||
from flask import Flask, Response
|
||||
from flask import request
|
||||
from hendrix.experience import crosstown_traffic
|
||||
from jinja2 import Template, TemplateError
|
||||
from twisted.logger import Logger
|
||||
from umbral import pre
|
||||
from umbral.keys import UmbralPublicKey
|
||||
from umbral.kfrags import KFrag
|
||||
|
||||
from bytestring_splitter import VariableLengthBytestring
|
||||
from constant_sorrow import constants
|
||||
from constant_sorrow.constants import FLEET_STATES_MATCH, NO_KNOWN_NODES
|
||||
from hendrix.experience import crosstown_traffic
|
||||
|
||||
import nucypher
|
||||
from nucypher.config.storages import ForgetfulNodeStorage
|
||||
from nucypher.crypto.kits import UmbralMessageKit
|
||||
from nucypher.crypto.powers import KeyPairBasedPower, PowerUpError
|
||||
|
@ -42,6 +45,13 @@ from nucypher.network import LEARNING_LOOP_VERSION
|
|||
from nucypher.network.exceptions import NodeSeemsToBeDown
|
||||
from nucypher.network.protocols import InterfaceInfo
|
||||
|
||||
HERE = BASE_DIR = os.path.abspath(os.path.dirname(__file__))
|
||||
TEMPLATES_DIR = os.path.join(HERE, "templates")
|
||||
|
||||
with open(os.path.join(TEMPLATES_DIR, "basic_status.j2"), "r") as f:
|
||||
_status_template_content = f.read()
|
||||
status_template = Template(_status_template_content)
|
||||
|
||||
|
||||
class ProxyRESTServer:
|
||||
SERVER_VERSION = LEARNING_LOOP_VERSION
|
||||
|
@ -371,6 +381,23 @@ def make_rest_app(
|
|||
log.info("Bad TreasureMap ID; not storing {}".format(treasure_map_id))
|
||||
assert False
|
||||
|
||||
@rest_app.route('/status')
|
||||
def status():
|
||||
headers = {"Content-Type": "text/html", "charset": "utf-8"}
|
||||
previous_states = list(reversed(this_node.known_nodes.states.values()))[:5]
|
||||
|
||||
try:
|
||||
content = status_template.render(this_node=this_node,
|
||||
known_nodes=this_node.known_nodes,
|
||||
previous_states=previous_states,
|
||||
domains=serving_domains,
|
||||
version=nucypher.__version__)
|
||||
except Exception as e:
|
||||
log.debug("Template Rendering Exception: ".format(str(e)))
|
||||
raise TemplateError(str(e)) from e
|
||||
|
||||
return Response(response=content, headers=headers)
|
||||
|
||||
return rest_app, datastore
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,156 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="icon" type="image/x-icon" href="https://www.nucypher.com/favicon-32x32.png"/>
|
||||
</head>
|
||||
|
||||
<style type="text/css">
|
||||
html {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
table, th, td {
|
||||
border: 1px solid black;
|
||||
}
|
||||
.nucypher-nickname-icon {
|
||||
border-width: 10px;
|
||||
border-style: solid;
|
||||
margin: 3px;
|
||||
padding: 3px;
|
||||
text-align: center;
|
||||
box-shadow: 1px 1px black, -1px -1px black;
|
||||
width: 100px;
|
||||
}
|
||||
.small {
|
||||
float:left;
|
||||
width: 100%;
|
||||
text-shadow: none;
|
||||
font-family: sans;
|
||||
font-size: 10px;
|
||||
}
|
||||
.symbols {
|
||||
float:left;
|
||||
width: 100%;
|
||||
}
|
||||
.single-symbol {
|
||||
font-size: 3em;
|
||||
color: black;
|
||||
text-shadow: 1px 1px black, -1px -1px black;
|
||||
}
|
||||
.address, .small-address {
|
||||
font-family: monospace;
|
||||
}
|
||||
.small-address {
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.state {
|
||||
float:left;
|
||||
}
|
||||
#previous-states {
|
||||
float:left;
|
||||
clear:left;
|
||||
}
|
||||
|
||||
#previous-states .state {
|
||||
margin:left: 10px;
|
||||
border-right: 3px solid black;
|
||||
}
|
||||
|
||||
#previous-states .nucypher-nickname-icon {
|
||||
height:75px;
|
||||
width: 75px;
|
||||
}
|
||||
|
||||
#previous-states .single-symbol {
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
#known-nodes {
|
||||
float:left;
|
||||
clear:left;
|
||||
}
|
||||
.small-address {
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.state {
|
||||
float:left;
|
||||
}
|
||||
#previous-states {
|
||||
float:left;
|
||||
clear:left;
|
||||
}
|
||||
|
||||
#previous-states .state {
|
||||
margin:left: 10px;
|
||||
border-right: 3px solid black;
|
||||
}
|
||||
|
||||
#previous-states .nucypher-nickname-icon {
|
||||
height:75px;
|
||||
width: 75px;
|
||||
}
|
||||
|
||||
#previous-states .single-symbol {
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
#known-nodes {
|
||||
float:left;
|
||||
clear:left;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="this-node">
|
||||
<h2>{{ this_node.nickname}}</h2>
|
||||
{{ this_node.nickname_icon }}
|
||||
<h4>v{{ version }}</h4>
|
||||
<h4>Domains: {% for domain in domains %}{{ domain }} {% endfor %}</h4>
|
||||
|
||||
<h3>Fleet State</h3>
|
||||
<div class="state">
|
||||
<h4>{{ known_nodes.nickname }}</h4>
|
||||
{{ known_nodes.icon }}
|
||||
<br/>
|
||||
<span class="small">{{ known_nodes.updated }}</span>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="previous-states">
|
||||
<h3>Previous States</h3>
|
||||
{% for state in previous_states %}
|
||||
<div class="state">
|
||||
<h5>{{ state.nickname }}</h5>
|
||||
{{ state.icon }}
|
||||
<br/>
|
||||
<span class="small">{{ state.updated }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div id="known-nodes">
|
||||
<h4>Known Nodes:</h4>
|
||||
<table>
|
||||
<thead>
|
||||
<td>Icon</td>
|
||||
<td>Nickname / Checksum</td>
|
||||
<td>Launched</td>
|
||||
<td>Last Seen</td>
|
||||
<td>Fleet State</td>
|
||||
</thead>
|
||||
{% for node in known_nodes -%}
|
||||
<tr>
|
||||
<td>{{ node.nickname_icon }}</td>
|
||||
<td>
|
||||
<a href="https://{{ node.rest_url()}}/status">{{ node.nickname }}</a>
|
||||
<br/><span class="small">{{ node.checksum_address }}</span>
|
||||
</td>
|
||||
<td>{{ node.timestamp }}</td>
|
||||
<td>{{ node.last_seen }}</td>
|
||||
<td>{{ node.fleet_state_icon }}</td>
|
||||
</tr>
|
||||
{%- endfor %}
|
||||
</table>
|
||||
</div>
|
||||
</html>
|
Loading…
Reference in New Issue