99import time
1010import random
1111
12- import asyncore_pollchoose as asyncore
13- import knownnodes
12+ from . import asyncore_pollchoose as asyncore
13+ from . import knownnodes
1414import protocol
1515import state
1616from bmconfigparser import config
17- from connectionchooser import chooseConnection
18- from node import Peer
19- from proxy import Proxy
20- from tcp import (
21- bootstrap , Socks4aBMConnection , Socks5BMConnection ,
22- TCPConnection , TCPServer )
23- from udp import UDPSocket
17+ from .connectionchooser import chooseConnection
18+ from .node import Peer
19+ from .proxy import Proxy
2420
2521logger = logging .getLogger ('default' )
2622
@@ -123,6 +119,7 @@ def isAlreadyConnected(self, nodeid):
123119
124120 def addConnection (self , connection ):
125121 """Add a connection object to our internal dict"""
122+ from .udp import UDPSocket
126123 if isinstance (connection , UDPSocket ):
127124 return
128125 if connection .isOutbound :
@@ -136,6 +133,8 @@ def addConnection(self, connection):
136133
137134 def removeConnection (self , connection ):
138135 """Remove a connection from our internal dict"""
136+ from .tcp import TCPServer
137+ from .udp import UDPSocket
139138 if isinstance (connection , UDPSocket ):
140139 del self .udpSockets [connection .listening .host ]
141140 elif isinstance (connection , TCPServer ):
@@ -177,6 +176,7 @@ def getListeningIP():
177176
178177 def startListening (self , bind = None ):
179178 """Open a listening socket and start accepting connections on it"""
179+ from .tcp import TCPServer
180180 if bind is None :
181181 bind = self .getListeningIP ()
182182 port = config .safeGetInt ("bitmessagesettings" , "port" )
@@ -189,6 +189,7 @@ def startUDPSocket(self, bind=None):
189189 Open an UDP socket. Depending on settings, it can either only
190190 accept incoming UDP packets, or also be able to send them.
191191 """
192+ from .udp import UDPSocket
192193 if bind is None :
193194 host = self .getListeningIP ()
194195 udpSocket = UDPSocket (host = host , announcing = True )
@@ -201,6 +202,9 @@ def startUDPSocket(self, bind=None):
201202
202203 def startBootstrappers (self ):
203204 """Run the process of resolving bootstrap hostnames"""
205+ from .tcp import (
206+ bootstrap , Socks4aBMConnection , Socks5BMConnection ,
207+ TCPConnection )
204208 proxy_type = config .safeGet (
205209 'bitmessagesettings' , 'socksproxytype' )
206210 # A plugins may be added here
@@ -252,6 +256,9 @@ def loop(self): # pylint: disable=too-many-branches,too-many-statements
252256 ):
253257 acceptConnections = False
254258
259+ from .tcp import (
260+ Socks4aBMConnection , Socks5BMConnection , TCPConnection )
261+
255262 # pylint: disable=too-many-nested-blocks
256263 if spawnConnections :
257264 if not knownnodes .knownNodesActual :
@@ -401,4 +408,4 @@ def loop(self): # pylint: disable=too-many-branches,too-many-statements
401408 self .removeConnection (i )
402409
403410
404- pool = BMConnectionPool ()
411+ pool = None
0 commit comments