mirror of
https://github.com/markqvist/NomadNet.git
synced 2024-10-01 01:26:07 -04:00
Added option to disable propagation node for pageserving-only nodes
This commit is contained in:
parent
0fb9e180ba
commit
8d72a83411
@ -122,6 +122,7 @@ class NomadNetworkApp:
|
|||||||
|
|
||||||
self.peer_announce_at_start = True
|
self.peer_announce_at_start = True
|
||||||
self.try_propagation_on_fail = True
|
self.try_propagation_on_fail = True
|
||||||
|
self.disable_propagation = False
|
||||||
|
|
||||||
self.periodic_lxmf_sync = True
|
self.periodic_lxmf_sync = True
|
||||||
self.lxmf_sync_interval = 360*60
|
self.lxmf_sync_interval = 360*60
|
||||||
@ -308,15 +309,27 @@ class NomadNetworkApp:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Cannot prioritise "+str(dest_str)+", it is not a valid destination hash", RNS.LOG_ERROR)
|
RNS.log("Cannot prioritise "+str(dest_str)+", it is not a valid destination hash", RNS.LOG_ERROR)
|
||||||
|
|
||||||
|
if self.disable_propagation:
|
||||||
|
if os.path.isfile(self.pnannouncedpath):
|
||||||
|
try:
|
||||||
|
RNS.log("Sending indication to peered LXMF Propagation Node that this node is no longer participating", RNS.LOG_DEBUG)
|
||||||
|
self.message_router.disable_propagation()
|
||||||
|
os.unlink(self.pnannouncedpath)
|
||||||
|
except Exception as e:
|
||||||
|
RNS.log("An error ocurred while indicating that this LXMF Propagation Node is no longer participating. The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||||
|
else:
|
||||||
self.message_router.enable_propagation()
|
self.message_router.enable_propagation()
|
||||||
try:
|
try:
|
||||||
with open(self.pnannouncedpath, "wb") as pnf:
|
with open(self.pnannouncedpath, "wb") as pnf:
|
||||||
pnf.write(msgpack.packb(time.time()))
|
pnf.write(msgpack.packb(time.time()))
|
||||||
pnf.close()
|
pnf.close()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("An error ocurred while writing Propagation Node announce timestamp. The contained exception was: "+str(e), RNS.LOG_ERROR)
|
RNS.log("An error ocurred while writing Propagation Node announce timestamp. The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||||
|
|
||||||
|
if not self.disable_propagation:
|
||||||
RNS.log("LXMF Propagation Node started on: "+RNS.prettyhexrep(self.message_router.propagation_destination.hash))
|
RNS.log("LXMF Propagation Node started on: "+RNS.prettyhexrep(self.message_router.propagation_destination.hash))
|
||||||
|
|
||||||
self.node = nomadnet.Node(self)
|
self.node = nomadnet.Node(self)
|
||||||
else:
|
else:
|
||||||
self.node = None
|
self.node = None
|
||||||
@ -788,6 +801,11 @@ class NomadNetworkApp:
|
|||||||
else:
|
else:
|
||||||
self.node_name = self.config["node"]["node_name"]
|
self.node_name = self.config["node"]["node_name"]
|
||||||
|
|
||||||
|
if not "disable_propagation" in self.config["node"]:
|
||||||
|
self.disable_propagation = False
|
||||||
|
else:
|
||||||
|
self.disable_propagation = self.config["node"].as_bool("disable_propagation")
|
||||||
|
|
||||||
if not "announce_at_start" in self.config["node"]:
|
if not "announce_at_start" in self.config["node"]:
|
||||||
self.node_announce_at_start = False
|
self.node_announce_at_start = False
|
||||||
else:
|
else:
|
||||||
@ -1003,6 +1021,14 @@ announce_interval = 360
|
|||||||
# Whether to announce when the node starts.
|
# Whether to announce when the node starts.
|
||||||
announce_at_start = Yes
|
announce_at_start = Yes
|
||||||
|
|
||||||
|
# By default, when Nomad Network is hosting a
|
||||||
|
# node, it will also act as an LXMF propagation
|
||||||
|
# node. If there is already a large amount of
|
||||||
|
# propagation nodes on the network, or you
|
||||||
|
# simply want to run a pageserving-only node,
|
||||||
|
# you can disable running a propagation node.
|
||||||
|
# disable_propagation = False
|
||||||
|
|
||||||
# The maximum amount of storage to use for
|
# The maximum amount of storage to use for
|
||||||
# the LXMF Propagation Node message store,
|
# the LXMF Propagation Node message store,
|
||||||
# specified in megabytes. When this limit
|
# specified in megabytes. When this limit
|
||||||
|
@ -620,6 +620,12 @@ Determines where the node server will look for hosted pages. Must be a readable
|
|||||||
Determines where the node server will look for downloadable files. Must be a readable filesystem path.
|
Determines where the node server will look for downloadable files. Must be a readable filesystem path.
|
||||||
<
|
<
|
||||||
|
|
||||||
|
>>>
|
||||||
|
`!disable_propagation = no`!
|
||||||
|
>>>>
|
||||||
|
By default, when Nomad Network is hosting a node, it will also run an LXMF propagation node. If there is already a large amount of propagation nodes on the network, or you simply want to run a pageserving-only node, you can disable running a propagation node.
|
||||||
|
<
|
||||||
|
|
||||||
>>>
|
>>>
|
||||||
`!message_storage_limit = 2000`!
|
`!message_storage_limit = 2000`!
|
||||||
>>>>
|
>>>>
|
||||||
|
@ -977,12 +977,12 @@ class NodeStorageStats(urwid.WidgetWrap):
|
|||||||
|
|
||||||
def update_stat(self):
|
def update_stat(self):
|
||||||
self.stat_string = "None"
|
self.stat_string = "None"
|
||||||
if self.app.node != None:
|
if self.app.node != None and not self.app.disable_propagation:
|
||||||
|
|
||||||
limit = self.app.message_router.message_storage_limit
|
limit = self.app.message_router.message_storage_limit
|
||||||
used = self.app.message_router.message_storage_size()
|
used = self.app.message_router.message_storage_size()
|
||||||
|
|
||||||
if limit != None:
|
if limit != None and used != None:
|
||||||
pct = round((used/limit)*100, 1)
|
pct = round((used/limit)*100, 1)
|
||||||
pct_str = str(pct)+"%, "
|
pct_str = str(pct)+"%, "
|
||||||
limit_str = " of "+RNS.prettysize(limit)
|
limit_str = " of "+RNS.prettysize(limit)
|
||||||
@ -1313,6 +1313,7 @@ class NodeInfo(urwid.WidgetWrap):
|
|||||||
connect_button = urwid.Button("Browse", on_press=connect_query)
|
connect_button = urwid.Button("Browse", on_press=connect_query)
|
||||||
reset_button = urwid.Button("Rst Stats", on_press=stats_query)
|
reset_button = urwid.Button("Rst Stats", on_press=stats_query)
|
||||||
|
|
||||||
|
if not self.app.disable_propagation:
|
||||||
pile = urwid.Pile([
|
pile = urwid.Pile([
|
||||||
t_id,
|
t_id,
|
||||||
e_name,
|
e_name,
|
||||||
@ -1336,6 +1337,28 @@ class NodeInfo(urwid.WidgetWrap):
|
|||||||
("weight", 7, announce_button),
|
("weight", 7, announce_button),
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
|
else:
|
||||||
|
pile = urwid.Pile([
|
||||||
|
t_id,
|
||||||
|
e_name,
|
||||||
|
urwid.Divider(g["divider1"]),
|
||||||
|
self.t_last_announce,
|
||||||
|
self.t_storage_stats,
|
||||||
|
self.t_active_links,
|
||||||
|
self.t_total_connections,
|
||||||
|
self.t_total_pages,
|
||||||
|
self.t_total_files,
|
||||||
|
urwid.Divider(g["divider1"]),
|
||||||
|
urwid.Columns([
|
||||||
|
("weight", 5, urwid.Button("Back", on_press=show_peer_info)),
|
||||||
|
("weight", 0.5, urwid.Text("")),
|
||||||
|
("weight", 6, connect_button),
|
||||||
|
("weight", 0.5, urwid.Text("")),
|
||||||
|
("weight", 8, reset_button),
|
||||||
|
("weight", 0.5, urwid.Text("")),
|
||||||
|
("weight", 7, announce_button),
|
||||||
|
])
|
||||||
|
])
|
||||||
else:
|
else:
|
||||||
pile = urwid.Pile([
|
pile = urwid.Pile([
|
||||||
urwid.Text("\n"+g["info"], align="center"),
|
urwid.Text("\n"+g["info"], align="center"),
|
||||||
|
Loading…
Reference in New Issue
Block a user