Add I2P information to UI

This commit is contained in:
str4d 2016-08-01 17:22:06 +12:00
parent feebcd0662
commit 74cb52a175
3 changed files with 48 additions and 7 deletions

View file

@ -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,15 +67,43 @@ 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",
"""
Successfully started Tor onion hidden services.<br>
For faster connections open <b>%s</b> port on your router.
""" % config.fileserver_port,
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",
"""
Successfully started Tor onion hidden services.<br>
For faster connections open <b>%s</b> port on your router.
""" % 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: