diff --git a/nomadnet/NomadNetworkApp.py b/nomadnet/NomadNetworkApp.py index 65a5e4f..e837fc0 100644 --- a/nomadnet/NomadNetworkApp.py +++ b/nomadnet/NomadNetworkApp.py @@ -263,7 +263,7 @@ class NomadNetworkApp: RNS.log("LXMF Router ready to receive on: "+RNS.prettyhexrep(self.lxmf_destination.hash)) if self.enable_node: - self.message_router.set_message_storage_limit(gigabytes=self.message_storage_limit) + self.message_router.set_message_storage_limit(megabytes=self.message_storage_limit) for dest_str in self.prioritised_lxmf_destinations: try: dest_hash = bytes.fromhex(dest_str) @@ -679,11 +679,11 @@ class NomadNetworkApp: self.prioritised_lxmf_destinations = [] if not "message_storage_limit" in self.config["node"]: - self.message_storage_limit = 2 + self.message_storage_limit = 2000 else: value = self.config["node"].as_float("message_storage_limit") - if value < 0.064: - value = 0.064 + if value < 0.005: + value = 0.005 self.message_storage_limit = value @@ -817,14 +817,14 @@ announce_at_start = Yes # The maximum amount of storage to use for # the LXMF Propagation Node message store, -# specified in gigabytes. When this limit +# specified in megabytes. When this limit # is reached, LXMF will periodically remove # messages in its message store. By default, # LXMF prioritises keeping messages that are # new and small. Large and old messages will # be removed first. This setting is optional # and defaults to 2 gigabytes. -# message_storage_limit = 2 +# message_storage_limit = 2000 # You can tell the LXMF message router to # prioritise storage for one or more @@ -833,6 +833,6 @@ announce_at_start = Yes # keeping messages for destinations specified # with this option. This setting is optional, # and generally you do not need to use it. -# prioritise_destinations = 10bc7624c27032a18639, ba780a6dff4cc1391db8 +# prioritise_destinations = 41d20c727598a3fbbdf9106133a3a0ed, d924b81822ca24e68e2effea99bcb8cf '''.splitlines() \ No newline at end of file diff --git a/nomadnet/ui/textui/Conversations.py b/nomadnet/ui/textui/Conversations.py index 5b296b9..6d2895b 100644 --- a/nomadnet/ui/textui/Conversations.py +++ b/nomadnet/ui/textui/Conversations.py @@ -14,7 +14,7 @@ class ConversationListDisplayShortcuts(): def __init__(self, app): self.app = app - self.widget = urwid.AttrMap(urwid.Text("[Enter] Open [C-e] Peer Info [C-x] Delete [C-r] Sync [C-n] New"), "shortcutbar") + self.widget = urwid.AttrMap(urwid.Text("[C-e] Peer Info [C-x] Delete [C-r] Sync [C-n] New [C-g] Fullscreen"), "shortcutbar") class ConversationDisplayShortcuts(): def __init__(self, app): diff --git a/nomadnet/ui/textui/Guide.py b/nomadnet/ui/textui/Guide.py index fe6324b..0e7bdd2 100644 --- a/nomadnet/ui/textui/Guide.py +++ b/nomadnet/ui/textui/Guide.py @@ -596,9 +596,9 @@ Determines where the node server will look for downloadable files. Must be a rea < >>> -`!message_storage_limit = 2`! +`!message_storage_limit = 2000`! >>>> -Configures the maximum amount of storage, in gigabytes, the LXMF Propagation Node will use to store messages. +Configures the maximum amount of storage, in megabytes, that the LXMF Propagation Node will use to store messages. < >>> diff --git a/nomadnet/ui/textui/Network.py b/nomadnet/ui/textui/Network.py index 9ea6a5c..e261583 100644 --- a/nomadnet/ui/textui/Network.py +++ b/nomadnet/ui/textui/Network.py @@ -13,7 +13,7 @@ class NetworkDisplayShortcuts(): self.app = app g = app.ui.glyphs - self.widget = urwid.AttrMap(urwid.Text("[C-l] Nodes/Announces [C-x] Remove [C-w] Disconnect [C-d] Back [C-f] Forward [C-r] Reload [C-u] URL"), "shortcutbar") + self.widget = urwid.AttrMap(urwid.Text("[C-l] Nodes/Announces [C-x] Remove [C-w] Disconnect [C-d] Back [C-f] Forward [C-r] Reload [C-u] URL [C-g] Fullscreen"), "shortcutbar") # "[C-"+g["arrow_u"]+g["arrow_d"]+"] Navigate Lists" @@ -827,7 +827,7 @@ class NodeAnnounceTime(urwid.WidgetWrap): if self.app.peer_settings["node_last_announce"] != None: self.last_announce_string = pretty_date(int(self.app.peer_settings["node_last_announce"])) - self.display_widget.set_text("Last Announce : "+self.last_announce_string) + self.display_widget.set_text("Last Announce : "+self.last_announce_string) def update_time_callback(self, loop=None, user_data=None): self.update_time() @@ -858,7 +858,7 @@ class NodeActiveConnections(urwid.WidgetWrap): if self.app.node != None: self.stat_string = str(len(self.app.node.destination.links)) - self.display_widget.set_text("Connections Now : "+self.stat_string) + self.display_widget.set_text("Conneced Now : "+self.stat_string) def update_stat_callback(self, loop=None, user_data=None): self.update_stat() @@ -874,6 +874,48 @@ class NodeActiveConnections(urwid.WidgetWrap): def stop(self): self.started = False +class NodeStorageStats(urwid.WidgetWrap): + def __init__(self, app): + self.started = False + self.app = app + self.timeout = self.app.config["textui"]["animation_interval"] + self.display_widget = urwid.Text("") + self.update_stat() + + urwid.WidgetWrap.__init__(self, self.display_widget) + + def update_stat(self): + self.stat_string = "None" + if self.app.node != None: + + limit = self.app.message_router.message_storage_limit + used = self.app.message_router.message_storage_size() + + if limit != None: + pct = round((used/limit)*100, 1) + pct_str = str(pct)+"%, " + limit_str = " of "+RNS.prettysize(limit) + else: + limit_str = "" + pct_str = "" + + self.stat_string = pct_str+RNS.prettysize(used)+limit_str + + self.display_widget.set_text("LXMF Storage : "+self.stat_string) + + def update_stat_callback(self, loop=None, user_data=None): + self.update_stat() + if self.started: + self.app.ui.loop.set_alarm_in(self.timeout, self.update_stat_callback) + + def start(self): + was_started = self.started + self.started = True + if not was_started: + self.update_stat_callback() + + def stop(self): + self.started = False class NodeTotalConnections(urwid.WidgetWrap): def __init__(self, app): @@ -890,7 +932,7 @@ class NodeTotalConnections(urwid.WidgetWrap): if self.app.node != None: self.stat_string = str(self.app.peer_settings["node_connects"]) - self.display_widget.set_text("Total Connections : "+self.stat_string) + self.display_widget.set_text("Total Connects : "+self.stat_string) def update_stat_callback(self, loop=None, user_data=None): self.update_stat() @@ -922,7 +964,7 @@ class NodeTotalPages(urwid.WidgetWrap): if self.app.node != None: self.stat_string = str(self.app.peer_settings["served_page_requests"]) - self.display_widget.set_text("Served Pages : "+self.stat_string) + self.display_widget.set_text("Served Pages : "+self.stat_string) def update_stat_callback(self, loop=None, user_data=None): self.update_stat() @@ -954,7 +996,7 @@ class NodeTotalFiles(urwid.WidgetWrap): if self.app.node != None: self.stat_string = str(self.app.peer_settings["served_file_requests"]) - self.display_widget.set_text("Served Files : "+self.stat_string) + self.display_widget.set_text("Served Files : "+self.stat_string) def update_stat_callback(self, loop=None, user_data=None): self.update_stat() @@ -1071,6 +1113,7 @@ class NodeInfo(urwid.WidgetWrap): conns_timer = None pages_timer = None files_timer = None + storage_timer = None def __init__(self, app, parent): self.app = app @@ -1144,6 +1187,13 @@ class NodeInfo(urwid.WidgetWrap): self.t_active_links = NodeInfo.links_timer self.t_active_links.update_stat() + if NodeInfo.storage_timer == None: + self.t_storage_stats = NodeStorageStats(self.app) + NodeInfo.storage_timer = self.t_storage_stats + else: + self.t_active_links = NodeInfo.links_timer + self.t_active_links.update_stat() + if NodeInfo.conns_timer == None: self.t_total_connections = NodeTotalConnections(self.app) NodeInfo.conns_timer = self.t_total_connections @@ -1179,6 +1229,7 @@ class NodeInfo(urwid.WidgetWrap): e_lxmf, urwid.Divider(g["divider1"]), self.t_last_announce, + self.t_storage_stats, self.t_active_links, self.t_total_connections, self.t_total_pages,