5
0
mirror of https://github.com/cwinfo/yggdrasil-map synced 2024-11-22 07:00:28 +00:00

sendGraph.py updates

This commit is contained in:
Michał Zieliński 2015-07-30 18:59:30 +02:00
parent f4fc407f8e
commit 8cfd0bf957
4 changed files with 27 additions and 19 deletions

View File

@ -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()

View File

@ -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'

View File

@ -10,8 +10,12 @@
<h3>Network map</h3>
<p>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.</p>
<h3>Node names</h3>
<p>For now, node names are assigned manually. You can submit Pull Request to <a href="https://github.com/zielmicha/nodedb">nodedb</a> if you want to have your node named.
In future this will be replaced by some reverse DNS system.
<h3>Contact</h3>
<p>fc00 was orginally created by <em>Randati</em>. Currently fc00 is run by <em>zielmicha</em>.
<p>fc00 was orginally created by <em>Randati</em>. fc00 is currently run by <em>zielmicha</em>.
If you have something to say or you would like to help, contact him via michal@zielinscy.org.pl.</p>
</div>
</div>

View File

@ -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('/')
@ -27,7 +29,8 @@ def page_sendGraph():
print "Receiving graph from %s" % (request.remote_addr)
data = request.form['data']
ret = insert_graph_data(app.config, 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: