Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions dev/powinterrupttest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
Code for discovering how C PoW can be interrupted
"""
import ctypes
import hashlib
from multiprocessing import current_process
Expand All @@ -9,9 +12,12 @@
shutdown = 0


def signal_handler(signal, frame):
global shutdown
print("Got signal %i in %s/%s" % (signal, current_process().name, current_thread().name))
# pylint: disable=unused-argument
def signal_handler(signum, frame):
"""Signal handler"""
global shutdown # pylint: disable=global-statement
print("Got signal %i in %s/%s" % (signum, current_process().name,
current_thread().name))
if current_process().name != "MainProcess":
raise StopIteration("Interrupted")
if current_thread().name != "PyBitmessage":
Expand All @@ -31,7 +37,12 @@ def _doCPoW(target, initialHash):
nonce = bmpow(out_h, out_m)
if shutdown:
break
trialValue, = unpack('>Q', hashlib.sha512(hashlib.sha512(pack('>Q', nonce) + initialHash).digest()).digest()[0:8])
trialValue, = unpack('>Q',
hashlib.sha512(
hashlib.sha512(
pack('>Q', nonce) + initialHash).
digest()).
digest()[0:8])
if shutdown != 0:
raise StopIteration("Interrupted")
print("C PoW done")
Expand Down
42 changes: 36 additions & 6 deletions dev/ssltest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
Development code for SSL compatibility investigations
"""
import os
import select
import socket
Expand All @@ -9,8 +12,12 @@
PORT = 8912


# pylint: disable=no-member
def sslProtocolVersion():
# sslProtocolVersion
"""
Find a protocol version value with compatibility across
different python versions
"""
if sys.version_info >= (2, 7, 13):
# this means TLSv1 or higher
# in the future change to
Expand All @@ -26,26 +33,42 @@ def sslProtocolVersion():


def sslProtocolCiphers():
"""
Find protocol cipher that is compatible for PyBitmessage across
different python and OpenSSL versions
"""
if ssl.OPENSSL_VERSION_NUMBER >= 0x10100000:
return "AECDH-AES256-SHA@SECLEVEL=0"
else:
return "AECDH-AES256-SHA"


# pylint: disable=redefined-outer-name
def connect():
"""
Connect a socket
"""
sock = socket.create_connection((HOST, PORT))
return sock


# pylint: disable=redefined-outer-name
def listen():
"""
Listen on a socket
"""
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind((HOST, PORT))
sock.listen(0)
return sock


# pylint: disable=redefined-outer-name
def sslHandshake(sock, server=False):
"""
Perform SSL hadnshake
"""
if sys.version_info >= (2, 7, 9):
context = ssl.SSLContext(sslProtocolVersion())
context.set_ciphers(sslProtocolCiphers())
Expand All @@ -54,12 +77,19 @@ def sslHandshake(sock, server=False):
context.verify_mode = ssl.CERT_NONE
context.options = ssl.OP_ALL | ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3\
| ssl.OP_SINGLE_ECDH_USE | ssl.OP_CIPHER_SERVER_PREFERENCE
sslSock = context.wrap_socket(sock, server_side=server, do_handshake_on_connect=False)
sslSock = context.wrap_socket(sock, server_side=server,
do_handshake_on_connect=False)
else:
sslSock = ssl.wrap_socket(sock, keyfile=os.path.join('src', 'sslkeys', 'key.pem'),
certfile=os.path.join('src', 'sslkeys', 'cert.pem'),
server_side=server, ssl_version=sslProtocolVersion(),
do_handshake_on_connect=False, ciphers='AECDH-AES256-SHA')
sslSock = ssl.wrap_socket(sock, keyfile=os.path.join('src',
'sslkeys',
'key.pem'),
certfile=os.path.join('src',
'sslkeys',
'cert.pem'),
server_side=server,
ssl_version=sslProtocolVersion(),
do_handshake_on_connect=False,
ciphers='AECDH-AES256-SHA')

while True:
try:
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

sys.path.insert(0, os.path.abspath('../src'))

from importlib import import_module
from importlib import import_module # pylint: disable=wrong-import-position

import version # noqa:E402
import version # noqa:E402 pylint: disable=wrong-import-position


# -- Project information -----------------------------------------------------
Expand Down
27 changes: 22 additions & 5 deletions packages/collectd/pybitmessagestatus.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
#!/usr/bin/env python2.7
"""
PyBitmessage status module for collectd
Provides values for active connections and processed objects
"""

import json

import collectd
import collectd # pylint: disable=import-error
from six.moves import xmlrpc_client as xmlrpclib

pybmurl = ""
api = ""
api = None


def init_callback():
global api
"""
Initialise callback
Creates an API object
"""
global api # pylint: disable=global-statement
api = xmlrpclib.ServerProxy(pybmurl)
collectd.info('pybitmessagestatus.py init done')


def config_callback(ObjConfiguration):
global pybmurl
"""
Load module config
"""
global pybmurl # pylint: disable=global-statement
apiUsername = ""
apiPassword = ""
apiInterface = "127.0.0.1"
Expand All @@ -31,11 +42,17 @@ def config_callback(ObjConfiguration):
apiInterface = node.values[0]
elif key.lower() == "apiport" and node.values:
apiPort = node.values[0]
pybmurl = "http://{}:{}@{}:{}/".format(apiUsername, apiPassword, apiInterface, str(int(apiPort)))
pybmurl = "http://{}:{}@{}:{}/".format(apiUsername,
apiPassword,
apiInterface,
str(int(apiPort)))
collectd.info('pybitmessagestatus.py config done')


def read_callback():
"""
Read data from API
"""
try:
clientStatus = json.loads(api.clientStatus())
except (ValueError, TypeError):
Expand Down
1 change: 1 addition & 0 deletions packages/pyinstaller/hooks/pyinstaller_rthook_plugins.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Runtime PyInstaller hook to load plugins"""

# pylint: disable=unused-import
import os
import sys

Expand Down
7 changes: 3 additions & 4 deletions src/bitmessagecurses/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# * python2-pythondialog
# * dialog

# pylint: disable=global-statement,too-many-lines,no-member
import ConfigParser
import curses
import os
Expand All @@ -18,7 +19,7 @@
from textwrap import fill
from threading import Timer

from dialog import Dialog
from dialog import Dialog # pylint: disable=import-error
import helper_sent
import l10n
import network.stats
Expand All @@ -31,8 +32,6 @@
from bmconfigparser import config
from helper_sql import sqlExecute, sqlQuery

# pylint: disable=global-statement


quit_ = False
menutab = 1
Expand Down Expand Up @@ -984,7 +983,7 @@ def loadInbox():
"""Load the list of messages"""
sys.stdout = sys.__stdout__
print("Loading inbox messages...")
sys.stdout = printlog
sys.stdout = printlog # pylint: disable-redefined-variable-type

where = "toaddress || fromaddress || subject || message"
what = "%%"
Expand Down
Loading