Move DNS seeds resolution to helper_startup
This commit is contained in:
parent
4f9a98ce5d
commit
ae24a3b17d
|
@ -390,3 +390,18 @@ def start_proxyconfig():
|
|||
logger.info(
|
||||
'Started proxy config plugin %s in %s sec',
|
||||
proxy_type, time.time() - proxyconfig_start)
|
||||
|
||||
|
||||
def enumerate_bootstrap_servers():
|
||||
"""Generator of (IP, port) pairs resolved from dns seeds"""
|
||||
for port in [8080, 8444]:
|
||||
for item in socket.getaddrinfo(
|
||||
'bootstrap%s.bitmessage.org' % port, port, type=socket.SOCK_STREAM
|
||||
):
|
||||
try:
|
||||
peer = item[4]
|
||||
socket.inet_aton(peer[0])
|
||||
except (TypeError, socket.error):
|
||||
continue
|
||||
else:
|
||||
yield peer[:2]
|
||||
|
|
|
@ -25,6 +25,7 @@ import helper_addressbook
|
|||
from bmconfigparser import BMConfigParser
|
||||
from helper_msgcoding import MsgEncode, MsgDecode
|
||||
from helper_sql import sqlQuery
|
||||
from helper_startup import enumerate_bootstrap_servers
|
||||
from network import asyncore_pollchoose as asyncore, knownnodes
|
||||
from network.bmproto import BMProto
|
||||
from network.connectionpool import BMConnectionPool
|
||||
|
@ -237,16 +238,8 @@ class TestCore(unittest.TestCase):
|
|||
def test_connection(self):
|
||||
"""test connection to bootstrap servers"""
|
||||
self._initiate_bootstrap()
|
||||
for port in [8080, 8444]:
|
||||
for item in socket.getaddrinfo(
|
||||
'bootstrap%s.bitmessage.org' % port, 80):
|
||||
try:
|
||||
addr = item[4][0]
|
||||
socket.inet_aton(item[4][0])
|
||||
except (TypeError, socket.error):
|
||||
continue
|
||||
else:
|
||||
knownnodes.addKnownNode(1, Peer(addr, port))
|
||||
for peer in enumerate_bootstrap_servers():
|
||||
knownnodes.addKnownNode(1, Peer(*peer))
|
||||
self._check_connection(True)
|
||||
|
||||
def test_bootstrap(self):
|
||||
|
|
Reference in New Issue
Block a user