diff --git a/scripts/sendGraph.py b/scripts/sendGraph.py index 846e201..377354b 100755 --- a/scripts/sendGraph.py +++ b/scripts/sendGraph.py @@ -1,18 +1,18 @@ #!/usr/bin/env python2 - ############################################################################### # CONFIG # URL where data is sent -# fc00.atomshare.net for clearnet access -# h.fc00.atomshare.net for hyperboria +# www.fc00.org for clearnet access +# h.fc00.org for hyperboria # [fc53:dcc5:e89d:9082:4097:6622:5e82:c654] for DNS-less access -url = 'http://fc00.atomshare.net/sendGraph' +url = 'http://www.fc00.org/sendGraph' +# update your email address, so I can contact you in case something goes wrong +your_mail = 'bad_mail@example.com' # Cjdns path without trailing slash cjdns_path = '/opt/cjdns' - # ---------------------- # RPC connection details # ---------------------- @@ -29,9 +29,11 @@ cjdns_processes = 1 # This can be used if you are running multiple instances ############################################################################### - - import sys + +if your_mail == 'bad_mail@example.com': + sys.exit('Please edit sendGraph.py to include your email address.') + import urllib import urllib2 from collections import deque @@ -200,7 +202,6 @@ def cjdns_graph_from_nodes(cjdns, source_nodes): # Add edge e = Edge(nodes[node.ip], nodes[child_ip]) - print node.ip, child_ip if not e in edges: edges.append(e) @@ -209,7 +210,7 @@ def cjdns_graph_from_nodes(cjdns, source_nodes): def send_data(graph_data): - post_data = urllib.urlencode({'data': graph_data}) + post_data = urllib.urlencode({'data': graph_data, 'mail': your_mail}) req = urllib2.Request(url, post_data) response = urllib2.urlopen(req) return response.read() diff --git a/web/graphData.py b/web/graphData.py index 6dbba48..8161358 100644 --- a/web/graphData.py +++ b/web/graphData.py @@ -3,9 +3,9 @@ from database import NodeDB from graph import Node, Edge import traceback -def insert_graph_data(config, json_str): +def insert_graph_data(config, data, mail, ip): try: - graph_data = json.loads(json_str) + graph_data = json.loads(data) except ValueError: return 'Invalid JSON' @@ -36,7 +36,7 @@ def insert_graph_data(config, json_str): try: with NodeDB(config) as db: - db.insert_graph(nodes, edges) + db.insert_graph(nodes, edges) except Exception: traceback.print_exc() return 'Database failure' diff --git a/web/templates/about.html b/web/templates/about.html index a51234c..212d9e8 100644 --- a/web/templates/about.html +++ b/web/templates/about.html @@ -9,9 +9,13 @@

Network map

The network page has a map of Hyperboria as it is now. The map is not complete since it is hard/impossible to get a full picture of the network. A rough estimate is that at least half of the nodes are pictured here, probably more. The nodes and links that are shown on the page are very likely to exist but this should not be taken as a guarantee.

+ +

Node names

+

For now, node names are assigned manually. You can submit Pull Request to nodedb if you want to have your node named. + In future this will be replaced by some reverse DNS system.

Contact

-

fc00 was orginally created by Randati. Currently fc00 is run by zielmicha. +

fc00 was orginally created by Randati. fc00 is currently run by zielmicha. If you have something to say or you would like to help, contact him via michal@zielinscy.org.pl.

diff --git a/web/web.py b/web/web.py index 90fdc39..ff55e58 100644 --- a/web/web.py +++ b/web/web.py @@ -4,13 +4,15 @@ from graphData import insert_graph_data app = Flask(__name__) app.config.from_pyfile('web_config.cfg') - -@app.context_processor -def add_ip(): +def get_ip(): ip = request.headers['x-real-ip'] if ip == '10.18.3.20': ip = request.headers['x-atomshare-real-ip'] - return dict(ip=ip) + return ip + +@app.context_processor +def add_ip(): + return dict(ip=get_ip()) @app.route('/') @@ -26,8 +28,9 @@ def page_about(): def page_sendGraph(): print "Receiving graph from %s" % (request.remote_addr) - data = request.form['data'] - ret = insert_graph_data(app.config, data) + data = request.form['data'] + mail = request.form.get('mail', 'none') + ret = insert_graph_data(ip=get_ip(), config=app.config, data=data, mail=mail) if ret == None: return 'OK' else: