From 659d45bb1514ec7296b0f7aad09b258afb320e6a Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Mon, 21 May 2018 18:41:00 +0300 Subject: [PATCH] Create default knownnodes if cannot read from file --- src/knownnodes.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/knownnodes.py b/src/knownnodes.py index 5d14c8dc..5755efc0 100644 --- a/src/knownnodes.py +++ b/src/knownnodes.py @@ -17,6 +17,18 @@ knownNodesTrimAmount = 2000 # forget a node after rating is this low knownNodesForgetRating = -0.5 +DEFAULT_NODES = ( + state.Peer('5.45.99.75', 8444), + state.Peer('75.167.159.54', 8444), + state.Peer('95.165.168.168', 8444), + state.Peer('85.180.139.241', 8444), + state.Peer('158.222.217.190', 8080), + state.Peer('178.62.12.187', 8448), + state.Peer('24.188.198.204', 8111), + state.Peer('109.147.204.113', 1195), + state.Peer('178.11.46.221', 8444) +) + def json_serialize_knownnodes(output): """ @@ -70,6 +82,12 @@ def addKnownNode(stream, peer, lastseen=None, is_self=False): } +def createDefaultKnownNodes(): + for peer in DEFAULT_NODES: + addKnownNode(1, peer) + saveKnownNodes() + + def readKnownNodes(): try: with open(state.appdata + 'knownnodes.dat', 'rb') as source: @@ -82,6 +100,7 @@ def readKnownNodes(): except (IOError, OSError, KeyError): logger.debug( 'Failed to read nodes from knownnodes.dat', exc_info=True) + createDefaultKnownNodes() config = BMConfigParser() # if config.safeGetInt('bitmessagesettings', 'settingsversion') > 10: