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
if not self.verackReceived:
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(
"tls_init" if self.isSSL else "connection_fully_established",
length=self.payloadLength, expectBytes=0)
print('After the value of state are :-{}'.format(self.state))
return False
def peerValidityChecks(self): # pylint: disable=too-many-return-statements

View File

@ -105,13 +105,14 @@ class Dandelion(): # pylint: disable=old-style-class
#hashMap is has any value
# if not [hasmap for hasmap in self.hashMap.items()] ==[]:
try:
for k, v in iter({
k: v for k, v in iter([hasmap for hasamp in self.hashMap.items()])
if v.child is None
}).items():
self.hashMap[k] = Stem(
connection, v.stream, self.poissonTimeout())
invQueue.put((v.stream, k, v.child))
if self.hashMap:
for k, v in iter({
k: v for k, v in iter([hasmap for hasmap in self.hashMap.items()])
if v.child is None
}).items():
self.hashMap[k] = Stem(
connection, v.stream, self.poissonTimeout())
invQueue.put((v.stream, k, v.child))
except AttributeError:
pass
@ -133,12 +134,13 @@ class Dandelion(): # pylint: disable=old-style-class
if connection in self.stem:
self.stem.remove(connection)
# active mappings to pointing to the removed node
for k in (
k for k, v in iter(self.nodeMap.items()) if v == connection
):
self.nodeMap[k] = None
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
}).items():
self.hashMap[k] = Stem(

View File

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

View File

@ -362,7 +362,7 @@ class TCPServer(AdvancedDispatcher):
"""TCP connection server for Bitmessage protocol"""
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)
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.set_reuse_addr()

View File

@ -67,6 +67,7 @@ class TLSDispatcher(AdvancedDispatcher): # pylint: disable=too-many-instanc
self.isSSL = False
def state_tls_init(self):
print()
"""Prepare sockets for TLS handshake"""
# pylint: disable=attribute-defined-outside-init
self.isSSL = True
@ -94,13 +95,16 @@ class TLSDispatcher(AdvancedDispatcher): # pylint: disable=too-many-instanc
ciphers=self.ciphers, do_handshake_on_connect=False)
self.sslSocket.setblocking(0)
self.want_read = self.want_write = True
print('before tls file python 98 state are :- {}'.format(self.state))
self.set_state("tls_handshake")
print('after tls file python 100 state are :- {}'.format(self.state))
return False
# if hasattr(self.socket, "context"):
# self.socket.context.set_ecdh_curve("secp256k1")
@staticmethod
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"""
return False
@ -178,6 +182,7 @@ class TLSDispatcher(AdvancedDispatcher): # pylint: disable=too-many-instanc
return
def tls_handshake(self):
print('inside the tls_handshake')
"""Perform TLS handshake and handle its stages"""
# wait for flush
if self.write_buf: