2019-12-23 07:51:24 +00:00
|
|
|
"""Onionr - Private P2P Communication.
|
2019-07-11 07:39:35 +00:00
|
|
|
|
2019-12-23 07:51:24 +00:00
|
|
|
add bootstrap peers to the communicator peer list
|
|
|
|
"""
|
2020-07-27 00:12:52 +00:00
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
|
2019-12-23 07:51:24 +00:00
|
|
|
from utils import readstatic, gettransports
|
|
|
|
from coredb import keydb
|
|
|
|
"""
|
2019-07-11 07:39:35 +00:00
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2019-12-23 07:51:24 +00:00
|
|
|
"""
|
|
|
|
|
2019-07-18 17:40:48 +00:00
|
|
|
bootstrap_peers = readstatic.read_static('bootstrap-nodes.txt').split(',')
|
2019-11-05 11:29:15 +00:00
|
|
|
|
2019-12-23 07:51:24 +00:00
|
|
|
|
2020-07-31 01:15:36 +00:00
|
|
|
def add_bootstrap_list_to_peer_list(kv, peerList, db_only=False):
|
2019-12-23 07:51:24 +00:00
|
|
|
"""Add the bootstrap list to the peer list (no duplicates)."""
|
2019-07-18 17:40:48 +00:00
|
|
|
for i in bootstrap_peers:
|
2020-07-27 00:12:52 +00:00
|
|
|
if i not in peerList and i not in kv.get('offlinePeers') \
|
2019-12-23 07:51:24 +00:00
|
|
|
and i not in gettransports.get() and len(str(i).strip()) > 0:
|
|
|
|
if not db_only:
|
|
|
|
peerList.append(i)
|
2019-11-10 02:30:07 +00:00
|
|
|
keydb.addkeys.add_address(i)
|