fix flake8 issue function name should be lower case.
This commit is contained in:
parent
9fa6f8e2b5
commit
343a2a50ce
|
@ -16,22 +16,22 @@ from addresses import encodeVarint
|
||||||
def genAckPayload(streamNumber=1, stealthLevel=0):
|
def genAckPayload(streamNumber=1, stealthLevel=0):
|
||||||
if (stealthLevel==2): # Generate privacy-enhanced payload
|
if (stealthLevel==2): # Generate privacy-enhanced payload
|
||||||
# Generate a dummy privkey and derive the pubkey
|
# 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
|
# Generate a dummy message of random length
|
||||||
# (the smallest possible standard-formatted message is 234 bytes)
|
# (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)
|
# Encrypt the message using standard BM encryption (ECIES)
|
||||||
ackdata = highlevelcrypto.encrypt(dummyMessage, dummyPubKeyHex)
|
ackdata = highlevelcrypto.encrypt(dummyMessage, dummyPubKeyHex)
|
||||||
acktype = 2 # message
|
acktype = 2 # message
|
||||||
version = 1
|
version = 1
|
||||||
|
|
||||||
elif (stealthLevel==1): # Basic privacy payload (random getpubkey)
|
elif (stealthLevel==1): # Basic privacy payload (random getpubkey)
|
||||||
ackdata = helper_random.randomBytes(32)
|
ackdata = helper_random.randombytes(32)
|
||||||
acktype = 0 # getpubkey
|
acktype = 0 # getpubkey
|
||||||
version = 4
|
version = 4
|
||||||
|
|
||||||
else: # Minimum viable payload (non stealth)
|
else: # Minimum viable payload (non stealth)
|
||||||
ackdata = helper_random.randomBytes(32)
|
ackdata = helper_random.randombytes(32)
|
||||||
acktype = 2 # message
|
acktype = 2 # message
|
||||||
version = 1
|
version = 1
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ from pyelliptic.openssl import OpenSSL
|
||||||
NoneType = type(None)
|
NoneType = type(None)
|
||||||
|
|
||||||
|
|
||||||
def randomBytes(n):
|
def randombytes(n):
|
||||||
"""Method randomBytes."""
|
"""Method randombytes."""
|
||||||
try:
|
try:
|
||||||
return os.urandom(n)
|
return os.urandom(n)
|
||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
|
@ -13,7 +13,7 @@ def randomBytes(n):
|
||||||
|
|
||||||
|
|
||||||
def randomshuffle(population):
|
def randomshuffle(population):
|
||||||
"""Method randomShuffle.
|
"""Method randomshuffle.
|
||||||
|
|
||||||
shuffle the sequence x in place.
|
shuffle the sequence x in place.
|
||||||
shuffles the elements in list in place,
|
shuffles the elements in list in place,
|
||||||
|
@ -28,7 +28,7 @@ def randomshuffle(population):
|
||||||
|
|
||||||
|
|
||||||
def randomsample(population, k):
|
def randomsample(population, k):
|
||||||
"""Method randomSample.
|
"""Method randomsample.
|
||||||
|
|
||||||
return a k length list of unique elements
|
return a k length list of unique elements
|
||||||
chosen from the population sequence.
|
chosen from the population sequence.
|
||||||
|
@ -40,7 +40,7 @@ def randomsample(population, k):
|
||||||
|
|
||||||
|
|
||||||
def randomrandrange(x, y=None):
|
def randomrandrange(x, y=None):
|
||||||
"""Method randomRandrange.
|
"""Method randomrandrange.
|
||||||
|
|
||||||
return a randomly selected element from
|
return a randomly selected element from
|
||||||
range(start, stop). This is equivalent to
|
range(start, stop). This is equivalent to
|
||||||
|
|
|
@ -11,7 +11,7 @@ import traceback
|
||||||
|
|
||||||
from addresses import calculateInventoryHash
|
from addresses import calculateInventoryHash
|
||||||
from debug import logger
|
from debug import logger
|
||||||
from helper_random import randomBytes
|
from helper_random import randombytes
|
||||||
import helper_random
|
import helper_random
|
||||||
from inventory import Inventory
|
from inventory import Inventory
|
||||||
import knownnodes
|
import knownnodes
|
||||||
|
@ -50,7 +50,7 @@ class TCPConnection(BMProto, TLSDispatcher):
|
||||||
TLSDispatcher.__init__(self, sock, server_side=True)
|
TLSDispatcher.__init__(self, sock, server_side=True)
|
||||||
self.connectedAt = time.time()
|
self.connectedAt = time.time()
|
||||||
logger.debug("Received connection from %s:%i", self.destination.host, self.destination.port)
|
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:
|
elif address is not None and sock is not None:
|
||||||
TLSDispatcher.__init__(self, sock, server_side=False)
|
TLSDispatcher.__init__(self, sock, server_side=False)
|
||||||
self.isOutbound = True
|
self.isOutbound = True
|
||||||
|
@ -195,7 +195,7 @@ class TCPConnection(BMProto, TLSDispatcher):
|
||||||
if e.errno in asyncore._DISCONNECTED:
|
if e.errno in asyncore._DISCONNECTED:
|
||||||
logger.debug("%s:%i: Connection failed: %s" % (self.destination.host, self.destination.port, str(e)))
|
logger.debug("%s:%i: Connection failed: %s" % (self.destination.host, self.destination.port, str(e)))
|
||||||
return
|
return
|
||||||
self.nodeid = randomBytes(8)
|
self.nodeid = randombytes(8)
|
||||||
self.append_write_buf(protocol.assembleVersionMessage(self.destination.host, self.destination.port, \
|
self.append_write_buf(protocol.assembleVersionMessage(self.destination.host, self.destination.port, \
|
||||||
network.connectionpool.BMConnectionPool().streams, False, nodeid=self.nodeid))
|
network.connectionpool.BMConnectionPool().streams, False, nodeid=self.nodeid))
|
||||||
#print "%s:%i: Sending version" % (self.destination.host, self.destination.port)
|
#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):
|
def state_proxy_handshake_done(self):
|
||||||
Socks5Connection.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, \
|
self.append_write_buf(protocol.assembleVersionMessage(self.destination.host, self.destination.port, \
|
||||||
network.connectionpool.BMConnectionPool().streams, False, nodeid=self.nodeid))
|
network.connectionpool.BMConnectionPool().streams, False, nodeid=self.nodeid))
|
||||||
self.set_state("bm_header", expectBytes=protocol.Header.size)
|
self.set_state("bm_header", expectBytes=protocol.Header.size)
|
||||||
|
@ -249,7 +249,7 @@ class Socks4aBMConnection(Socks4aConnection, TCPConnection):
|
||||||
|
|
||||||
def state_proxy_handshake_done(self):
|
def state_proxy_handshake_done(self):
|
||||||
Socks4aConnection.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, \
|
self.append_write_buf(protocol.assembleVersionMessage(self.destination.host, self.destination.port, \
|
||||||
network.connectionpool.BMConnectionPool().streams, False, nodeid=self.nodeid))
|
network.connectionpool.BMConnectionPool().streams, False, nodeid=self.nodeid))
|
||||||
self.set_state("bm_header", expectBytes=protocol.Header.size)
|
self.set_state("bm_header", expectBytes=protocol.Header.size)
|
||||||
|
|
Reference in New Issue
Block a user