From 343a2a50ce2b6ac2dea6e91369970744c47cf60a Mon Sep 17 00:00:00 2001 From: Mahendra Date: Thu, 22 Mar 2018 16:17:30 +0530 Subject: [PATCH] fix flake8 issue function name should be lower case. --- src/helper_ackPayload.py | 8 ++++---- src/helper_random.py | 10 +++++----- src/network/tcp.py | 10 +++++----- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/helper_ackPayload.py b/src/helper_ackPayload.py index ef99ec2a..7a2b955e 100644 --- a/src/helper_ackPayload.py +++ b/src/helper_ackPayload.py @@ -16,22 +16,22 @@ from addresses import encodeVarint def genAckPayload(streamNumber=1, stealthLevel=0): if (stealthLevel==2): # Generate privacy-enhanced payload # Generate a dummy privkey and derive the pubkey - dummyPubKeyHex = highlevelcrypto.privToPub(hexlify(helper_random.randomBytes(32))) + dummyPubKeyHex = highlevelcrypto.privToPub(hexlify(helper_random.randombytes(32))) # Generate a dummy message of random length # (the smallest possible standard-formatted message is 234 bytes) - dummyMessage = helper_random.randomBytes(random.randint(234, 800)) + dummyMessage = helper_random.randombytes(random.randint(234, 800)) # Encrypt the message using standard BM encryption (ECIES) ackdata = highlevelcrypto.encrypt(dummyMessage, dummyPubKeyHex) acktype = 2 # message version = 1 elif (stealthLevel==1): # Basic privacy payload (random getpubkey) - ackdata = helper_random.randomBytes(32) + ackdata = helper_random.randombytes(32) acktype = 0 # getpubkey version = 4 else: # Minimum viable payload (non stealth) - ackdata = helper_random.randomBytes(32) + ackdata = helper_random.randombytes(32) acktype = 2 # message version = 1 diff --git a/src/helper_random.py b/src/helper_random.py index 56501871..33a3e285 100644 --- a/src/helper_random.py +++ b/src/helper_random.py @@ -4,8 +4,8 @@ from pyelliptic.openssl import OpenSSL NoneType = type(None) -def randomBytes(n): - """Method randomBytes.""" +def randombytes(n): + """Method randombytes.""" try: return os.urandom(n) except NotImplementedError: @@ -13,7 +13,7 @@ def randomBytes(n): def randomshuffle(population): - """Method randomShuffle. + """Method randomshuffle. shuffle the sequence x in place. shuffles the elements in list in place, @@ -28,7 +28,7 @@ def randomshuffle(population): def randomsample(population, k): - """Method randomSample. + """Method randomsample. return a k length list of unique elements chosen from the population sequence. @@ -40,7 +40,7 @@ def randomsample(population, k): def randomrandrange(x, y=None): - """Method randomRandrange. + """Method randomrandrange. return a randomly selected element from range(start, stop). This is equivalent to diff --git a/src/network/tcp.py b/src/network/tcp.py index f0bfb886..6a09c6f9 100644 --- a/src/network/tcp.py +++ b/src/network/tcp.py @@ -11,7 +11,7 @@ import traceback from addresses import calculateInventoryHash from debug import logger -from helper_random import randomBytes +from helper_random import randombytes import helper_random from inventory import Inventory import knownnodes @@ -50,7 +50,7 @@ class TCPConnection(BMProto, TLSDispatcher): TLSDispatcher.__init__(self, sock, server_side=True) self.connectedAt = time.time() logger.debug("Received connection from %s:%i", self.destination.host, self.destination.port) - self.nodeid = randomBytes(8) + self.nodeid = randombytes(8) elif address is not None and sock is not None: TLSDispatcher.__init__(self, sock, server_side=False) self.isOutbound = True @@ -195,7 +195,7 @@ class TCPConnection(BMProto, TLSDispatcher): if e.errno in asyncore._DISCONNECTED: logger.debug("%s:%i: Connection failed: %s" % (self.destination.host, self.destination.port, str(e))) return - self.nodeid = randomBytes(8) + self.nodeid = randombytes(8) self.append_write_buf(protocol.assembleVersionMessage(self.destination.host, self.destination.port, \ network.connectionpool.BMConnectionPool().streams, False, nodeid=self.nodeid)) #print "%s:%i: Sending version" % (self.destination.host, self.destination.port) @@ -234,7 +234,7 @@ class Socks5BMConnection(Socks5Connection, TCPConnection): def state_proxy_handshake_done(self): Socks5Connection.state_proxy_handshake_done(self) - self.nodeid = randomBytes(8) + self.nodeid = randombytes(8) self.append_write_buf(protocol.assembleVersionMessage(self.destination.host, self.destination.port, \ network.connectionpool.BMConnectionPool().streams, False, nodeid=self.nodeid)) self.set_state("bm_header", expectBytes=protocol.Header.size) @@ -249,7 +249,7 @@ class Socks4aBMConnection(Socks4aConnection, TCPConnection): def state_proxy_handshake_done(self): Socks4aConnection.state_proxy_handshake_done(self) - self.nodeid = randomBytes(8) + self.nodeid = randombytes(8) self.append_write_buf(protocol.assembleVersionMessage(self.destination.host, self.destination.port, \ network.connectionpool.BMConnectionPool().streams, False, nodeid=self.nodeid)) self.set_state("bm_header", expectBytes=protocol.Header.size)