fix flake8 issue function name should be lower case.

This commit is contained in:
Mahendra 2018-03-22 16:17:30 +05:30
parent 9fa6f8e2b5
commit 343a2a50ce
No known key found for this signature in database
GPG Key ID: A672D8FAAEE398B3
3 changed files with 14 additions and 14 deletions

View File

@ -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

View File

@ -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

View File

@ -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)