Add I2P information to UI
This commit is contained in:
parent
feebcd0662
commit
74cb52a175
3 changed files with 48 additions and 7 deletions
|
@ -62,13 +62,15 @@ class UiWebsocketPlugin(object):
|
|||
connected = len([peer for peer in site.peers.values() if peer.connection and peer.connection.connected])
|
||||
connectable = len([peer_id for peer_id in site.peers.keys() if not peer_id.endswith(":0")])
|
||||
onion = len([peer_id for peer_id in site.peers.keys() if ".onion" in peer_id])
|
||||
i2p = len([peer_id for peer_id in site.peers.keys() if ".i2p" in peer_id])
|
||||
peers_total = len(site.peers)
|
||||
if peers_total:
|
||||
percent_connected = float(connected) / peers_total
|
||||
percent_connectable = float(connectable) / peers_total
|
||||
percent_onion = float(onion) / peers_total
|
||||
percent_i2p = float(i2p) / peers_total
|
||||
else:
|
||||
percent_connectable = percent_connected = percent_onion = 0
|
||||
percent_connectable = percent_connected = percent_onion = percent_i2p = 0
|
||||
body.append("""
|
||||
<li>
|
||||
<label>Peers</label>
|
||||
|
@ -76,12 +78,14 @@ class UiWebsocketPlugin(object):
|
|||
<li style='width: 100%' class='total back-black' title="Total peers"></li>
|
||||
<li style='width: {percent_connectable:.0%}' class='connectable back-blue' title='Connectable peers'></li>
|
||||
<li style='width: {percent_onion:.0%}' class='connected back-purple' title='Onion'></li>
|
||||
<li style='width: {percent_i2p:.0%}' class='connected back-purple' title='I2P'></li>
|
||||
<li style='width: {percent_connected:.0%}' class='connected back-green' title='Connected peers'></li>
|
||||
</ul>
|
||||
<ul class='graph-legend'>
|
||||
<li class='color-green'><span>connected:</span><b>{connected}</b></li>
|
||||
<li class='color-blue'><span>Connectable:</span><b>{connectable}</b></li>
|
||||
<li class='color-purple'><span>Onion:</span><b>{onion}</b></li>
|
||||
<li class='color-purple'><span>I2P:</span><b>{i2p}</b></li>
|
||||
<li class='color-black'><span>Total:</span><b>{peers_total}</b></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
|
|
@ -126,6 +126,11 @@ class UiRequestPlugin(object):
|
|||
for site_address, onion in main.file_server.tor_manager.site_onions.items():
|
||||
yield "- %-34s: %s<br>" % (site_address, onion)
|
||||
|
||||
# I2P Destinations
|
||||
yield "<br><br><b>I2P Destinations (status: %s):</b><br>" % main.file_server.i2p_manager.status
|
||||
for site_address, dest in main.file_server.i2p_manager.site_dests.items():
|
||||
yield "- %-34s: %s<br>" % (site_address, dest.base32())
|
||||
|
||||
# Db
|
||||
yield "<br><br><b>Db</b>:<br>"
|
||||
for db in sys.modules["Db.Db"].opened_dbs:
|
||||
|
|
|
@ -39,7 +39,8 @@ class UiWebsocket(object):
|
|||
# Add open fileserver port message or closed port error to homepage at first request after start
|
||||
self.site.page_requested = True # Dont add connection notification anymore
|
||||
file_server = sys.modules["main"].file_server
|
||||
if file_server.port_opened is None or file_server.tor_manager.start_onions is None:
|
||||
if file_server.port_opened is None or file_server.tor_manager.start_onions is None or \
|
||||
file_server.i2p_manager.start_dests is None:
|
||||
self.site.page_requested = False # Not ready yet, check next time
|
||||
elif file_server.port_opened is True:
|
||||
self.site.notifications.append([
|
||||
|
@ -66,7 +67,26 @@ class UiWebsocket(object):
|
|||
""",
|
||||
0
|
||||
])
|
||||
elif file_server.port_opened is False and file_server.tor_manager.start_onions:
|
||||
elif config.i2p == "always" and file_server.i2p_manager.start_dests:
|
||||
self.site.notifications.append([
|
||||
"done",
|
||||
"""
|
||||
I2P mode active, every connection using I2P route.<br>
|
||||
Successfully started I2P Destinations.
|
||||
""",
|
||||
10000
|
||||
])
|
||||
elif config.i2p == "always" and file_server.i2p_manager.start_dests is not False:
|
||||
self.site.notifications.append([
|
||||
"error",
|
||||
"""
|
||||
I2P mode active, every connection using I2P route.<br>
|
||||
Unable to start I2P Destinations, please check your config.
|
||||
""",
|
||||
0
|
||||
])
|
||||
elif file_server.port_opened is False:
|
||||
if file_server.tor_manager.start_onions:
|
||||
self.site.notifications.append([
|
||||
"done",
|
||||
"""
|
||||
|
@ -75,6 +95,15 @@ class UiWebsocket(object):
|
|||
""" % config.fileserver_port,
|
||||
10000
|
||||
])
|
||||
if file_server.i2p_manager.start_dests:
|
||||
self.site.notifications.append([
|
||||
"done",
|
||||
"""
|
||||
Successfully started I2P Destinations.<br>
|
||||
For faster connections open <b>%s</b> port on your router.
|
||||
""" % config.fileserver_port,
|
||||
10000
|
||||
])
|
||||
else:
|
||||
self.site.notifications.append([
|
||||
"error",
|
||||
|
@ -231,6 +260,8 @@ class UiWebsocket(object):
|
|||
"fileserver_port": config.fileserver_port,
|
||||
"tor_enabled": sys.modules["main"].file_server.tor_manager.enabled,
|
||||
"tor_status": sys.modules["main"].file_server.tor_manager.status,
|
||||
"i2p_enabled": sys.modules["main"].file_server.i2p_manager.enabled,
|
||||
"i2p_status": sys.modules["main"].file_server.i2p_manager.status,
|
||||
"ui_ip": config.ui_ip,
|
||||
"ui_port": config.ui_port,
|
||||
"version": config.version,
|
||||
|
@ -364,7 +395,8 @@ class UiWebsocket(object):
|
|||
self.response(to, "ok")
|
||||
else:
|
||||
if len(site.peers) == 0:
|
||||
if sys.modules["main"].file_server.port_opened or sys.modules["main"].file_server.tor_manager.start_onions:
|
||||
if sys.modules["main"].file_server.port_opened or sys.modules["main"].file_server.tor_manager.start_onions or \
|
||||
sys.modules["main"].file_server.i2p_manager.start_dests:
|
||||
if notification:
|
||||
self.cmd("notification", ["info", "No peers found, but your content is ready to access.", 5000])
|
||||
if callback:
|
||||
|
|
Loading…
Reference in a new issue