Working on the network issues

This commit is contained in:
jai.s 2019-11-15 16:01:14 +05:30
parent fdbf7ad0f2
commit a08b0707bb
No known key found for this signature in database
GPG Key ID: 360CFA25EFC67D12
5 changed files with 22 additions and 13 deletions

View File

@ -543,10 +543,12 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
self.isSSL = True self.isSSL = True
if not self.verackReceived: if not self.verackReceived:
return True return True
print('inside the bmproto line 546') print('inside the bmproto line')
print('before the value of state are :-{}'.format(self.state))
self.set_state( self.set_state(
"tls_init" if self.isSSL else "connection_fully_established", "tls_init" if self.isSSL else "connection_fully_established",
length=self.payloadLength, expectBytes=0) length=self.payloadLength, expectBytes=0)
print('After the value of state are :-{}'.format(self.state))
return False return False
def peerValidityChecks(self): # pylint: disable=too-many-return-statements def peerValidityChecks(self): # pylint: disable=too-many-return-statements

View File

@ -105,8 +105,9 @@ class Dandelion(): # pylint: disable=old-style-class
#hashMap is has any value #hashMap is has any value
# if not [hasmap for hasmap in self.hashMap.items()] ==[]: # if not [hasmap for hasmap in self.hashMap.items()] ==[]:
try: try:
if self.hashMap:
for k, v in iter({ for k, v in iter({
k: v for k, v in iter([hasmap for hasamp in self.hashMap.items()]) k: v for k, v in iter([hasmap for hasmap in self.hashMap.items()])
if v.child is None if v.child is None
}).items(): }).items():
self.hashMap[k] = Stem( self.hashMap[k] = Stem(
@ -133,12 +134,13 @@ class Dandelion(): # pylint: disable=old-style-class
if connection in self.stem: if connection in self.stem:
self.stem.remove(connection) self.stem.remove(connection)
# active mappings to pointing to the removed node # active mappings to pointing to the removed node
for k in ( for k in (
k for k, v in iter(self.nodeMap.items()) if v == connection k for k, v in iter(self.nodeMap.items()) if v == connection
): ):
self.nodeMap[k] = None self.nodeMap[k] = None
for k, v in iter({ for k, v in iter({
k: v for k, v in iter(self.hashMap.items()) k: v for k, v in iter(iter([hasmap for hasmap in self.hashMap.items()]))
if v.child == connection if v.child == connection
}).items(): }).items():
self.hashMap[k] = Stem( self.hashMap[k] = Stem(

View File

@ -26,17 +26,17 @@ class BMNetworkThread(StoppableThread):
def stopThread(self): def stopThread(self):
super(BMNetworkThread, self).stopThread() super(BMNetworkThread, self).stopThread()
for i in BMConnectionPool().listeningSockets.values(): for i in [listeningSockets for listeningSockets in BMConnectionPool().listeningSockets.values()]:
try: try:
i.close() i.close()
except: except:
pass pass
for i in BMConnectionPool().outboundConnections.values(): for i in [ outboundConnections for outboundConnections in BMConnectionPool().outboundConnections.values()]:
try: try:
i.close() i.close()
except: except:
pass pass
for i in BMConnectionPool().inboundConnections.values(): for i in [inboundConnections for inboundConnections in BMConnectionPool().inboundConnections.values()]:
try: try:
i.close() i.close()
except: except:

View File

@ -362,7 +362,7 @@ class TCPServer(AdvancedDispatcher):
"""TCP connection server for Bitmessage protocol""" """TCP connection server for Bitmessage protocol"""
def __init__(self, host='127.0.0.1', port=8444): def __init__(self, host='127.0.0.1', port=8444):
if not '_map' in dir(self): if '_map' not in dir(self):
AdvancedDispatcher.__init__(self) AdvancedDispatcher.__init__(self)
self.create_socket(socket.AF_INET, socket.SOCK_STREAM) self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.set_reuse_addr() self.set_reuse_addr()

View File

@ -67,6 +67,7 @@ class TLSDispatcher(AdvancedDispatcher): # pylint: disable=too-many-instanc
self.isSSL = False self.isSSL = False
def state_tls_init(self): def state_tls_init(self):
print()
"""Prepare sockets for TLS handshake""" """Prepare sockets for TLS handshake"""
# pylint: disable=attribute-defined-outside-init # pylint: disable=attribute-defined-outside-init
self.isSSL = True self.isSSL = True
@ -94,13 +95,16 @@ class TLSDispatcher(AdvancedDispatcher): # pylint: disable=too-many-instanc
ciphers=self.ciphers, do_handshake_on_connect=False) ciphers=self.ciphers, do_handshake_on_connect=False)
self.sslSocket.setblocking(0) self.sslSocket.setblocking(0)
self.want_read = self.want_write = True self.want_read = self.want_write = True
print('before tls file python 98 state are :- {}'.format(self.state))
self.set_state("tls_handshake") self.set_state("tls_handshake")
print('after tls file python 100 state are :- {}'.format(self.state))
return False return False
# if hasattr(self.socket, "context"): # if hasattr(self.socket, "context"):
# self.socket.context.set_ecdh_curve("secp256k1") # self.socket.context.set_ecdh_curve("secp256k1")
@staticmethod @staticmethod
def state_tls_handshake(): def state_tls_handshake():
print("tls's state_tls_handshake method in line 107")
"""Do nothing while TLS handshake is pending, as during this phase we need to react to callbacks instead""" """Do nothing while TLS handshake is pending, as during this phase we need to react to callbacks instead"""
return False return False
@ -178,6 +182,7 @@ class TLSDispatcher(AdvancedDispatcher): # pylint: disable=too-many-instanc
return return
def tls_handshake(self): def tls_handshake(self):
print('inside the tls_handshake')
"""Perform TLS handshake and handle its stages""" """Perform TLS handshake and handle its stages"""
# wait for flush # wait for flush
if self.write_buf: if self.write_buf: