WIP: Handling a new pylint design checker message #17
|
@ -20,22 +20,19 @@ class ConnectionBase(threading.Thread):
|
||||||
Common code for the connection thread
|
Common code for the connection thread
|
||||||
with minimum command handlers to reuse
|
with minimum command handlers to reuse
|
||||||
"""
|
"""
|
||||||
def __init__(
|
def __init__(self, host, port, s=None, server=False):
|
||||||
self, host, port, s=None, network='ip', server=False,
|
|
||||||
i2p_remote_dest=b''
|
|
||||||
):
|
|
||||||
self.host = host
|
self.host = host
|
||||||
self.port = port
|
self.port = port
|
||||||
self.network = network
|
self.network = 'i2p' if port == 'i2p' else 'ip'
|
||||||
self.i2p_remote_dest = i2p_remote_dest
|
|
||||||
|
|
||||||
if self.network == 'i2p':
|
self.host_print = (
|
||||||
self.host_print = self.i2p_remote_dest[:8].decode()
|
self.host[:8].decode() if self.network == 'i2p' else self.host)
|
||||||
else:
|
|
||||||
self.host_print = self.host
|
|
||||||
|
|
||||||
super().__init__(name='Connection to {}:{}'.format(host, port))
|
super().__init__(name='Connection to {}:{}'.format(host, port))
|
||||||
|
|
||||||
|
self.s = s
|
||||||
|
self.server = server
|
||||||
|
|
||||||
self.send_queue = queue.Queue()
|
self.send_queue = queue.Queue()
|
||||||
|
|
||||||
self.vectors_to_get = set()
|
self.vectors_to_get = set()
|
||||||
|
@ -43,22 +40,13 @@ class ConnectionBase(threading.Thread):
|
||||||
|
|
||||||
self.vectors_requested = {}
|
self.vectors_requested = {}
|
||||||
|
|
||||||
self.status = 'ready'
|
self.status = 'connected' if bool(s) else 'ready'
|
||||||
|
|
||||||
self.tls = False
|
|
||||||
|
|
||||||
self.verack_received = False
|
self.verack_received = False
|
||||||
self.verack_sent = False
|
self.verack_sent = False
|
||||||
|
|
||||||
self.s = s
|
|
||||||
|
|
||||||
self.remote_version = None
|
self.remote_version = None
|
||||||
|
|
||||||
self.server = server
|
|
||||||
|
|
||||||
if bool(s):
|
|
||||||
self.status = 'connected'
|
|
||||||
|
|
||||||
self.buffer_receive = b''
|
self.buffer_receive = b''
|
||||||
self.buffer_send = b''
|
self.buffer_send = b''
|
||||||
|
|
||||||
|
@ -238,7 +226,7 @@ class ConnectionBase(threading.Thread):
|
||||||
logging.debug('ssl.SSLError reason: %s', e.reason)
|
logging.debug('ssl.SSLError reason: %s', e.reason)
|
||||||
shared.node_pool.discard((self.host, self.port))
|
shared.node_pool.discard((self.host, self.port))
|
||||||
return
|
return
|
||||||
self.tls = True
|
|
||||||
logging.debug(
|
logging.debug(
|
||||||
'Established TLS connection with %s:%s (%s)',
|
'Established TLS connection with %s:%s (%s)',
|
||||||
self.host_print, self.port, self.s.version())
|
self.host_print, self.port, self.s.version())
|
||||||
|
|
|
@ -28,9 +28,7 @@ class I2PDialer(I2PThread):
|
||||||
logging.debug('Connecting to %s', self.destination)
|
logging.debug('Connecting to %s', self.destination)
|
||||||
self._connect()
|
self._connect()
|
||||||
if not self.state.shutting_down and self.success:
|
if not self.state.shutting_down and self.success:
|
||||||
c = self.state.connection(
|
c = self.state.connection(self.destination, 'i2p', self.s, False)
|
||||||
self.destination, 'i2p', self.s, 'i2p',
|
|
||||||
False, self.destination)
|
|
||||||
c.start()
|
c.start()
|
||||||
self.state.connections.add(c)
|
self.state.connections.add(c)
|
||||||
|
|
||||||
|
|
|
@ -45,8 +45,7 @@ class I2PListener(I2PThread):
|
||||||
logging.debug('Rejecting duplicate I2P connection.')
|
logging.debug('Rejecting duplicate I2P connection.')
|
||||||
self.s.close()
|
self.s.close()
|
||||||
else:
|
else:
|
||||||
c = self.state.connection(
|
c = self.state.connection(destination, 'i2p', self.s, True)
|
||||||
destination, 'i2p', self.s, 'i2p', True, destination)
|
|
||||||
c.start()
|
c.start()
|
||||||
self.state.connections.add(c)
|
self.state.connections.add(c)
|
||||||
c = None
|
c = None
|
||||||
|
|
Loading…
Reference in New Issue
Block a user