Added trusted_peer and listen_for_connections options

This commit is contained in:
TheKysek 2017-01-14 13:42:15 +01:00
parent 55aa240d74
commit b5fce64619
3 changed files with 45 additions and 38 deletions

View File

@ -47,6 +47,7 @@ def main():
shared.core_nodes = {tuple(row) for row in reader} shared.core_nodes = {tuple(row) for row in reader}
shared.node_pool.update(shared.core_nodes) shared.node_pool.update(shared.core_nodes)
if not shared.trusted_peer:
try: try:
for item in socket.getaddrinfo('bootstrap8080.bitmessage.org', 80): for item in socket.getaddrinfo('bootstrap8080.bitmessage.org', 80):
shared.unchecked_node_pool.add((item[4][0], 8080)) shared.unchecked_node_pool.add((item[4][0], 8080))
@ -69,6 +70,7 @@ def main():
listener_ipv4 = None listener_ipv4 = None
listener_ipv6 = None listener_ipv6 = None
if not shared.listen_for_connections:
if socket.has_ipv6: if socket.has_ipv6:
try: try:
listener_ipv6 = Listener('', shared.listening_port, family=socket.AF_INET6) listener_ipv6 = Listener('', shared.listening_port, family=socket.AF_INET6)

View File

@ -63,8 +63,10 @@ class Manager(threading.Thread):
hosts.add(c.host) hosts.add(c.host)
if not c.server: if not c.server:
outgoing_connections += 1 outgoing_connections += 1
if outgoing_connections < shared.outgoing_connections and shared.send_outgoing_connections:
to_connect = set() to_connect = set()
if shared.trusted_peer:
to_connect.add(shared.trusted_peer)
if outgoing_connections < shared.outgoing_connections and shared.send_outgoing_connections and not shared.trusted_peer:
if len(shared.unchecked_node_pool) > 16: if len(shared.unchecked_node_pool) > 16:
to_connect.update(random.sample(shared.unchecked_node_pool, 16)) to_connect.update(random.sample(shared.unchecked_node_pool, 16))
else: else:

View File

@ -6,8 +6,11 @@ import threading
listening_port = 8444 listening_port = 8444
send_outgoing_connections = True send_outgoing_connections = True
listen_for_connections = True
data_directory = 'minode_data/' data_directory = 'minode_data/'
source_directory = os.path.dirname(os.path.realpath(__file__)) source_directory = os.path.dirname(os.path.realpath(__file__))
trusted_peer = None
# trusted_peer = ('127.0.0.1', 8444)
log_level = logging.DEBUG log_level = logging.DEBUG