fixes after new merging

This commit is contained in:
surbhi 2020-02-19 15:38:27 +05:30
commit 23a8ab2c19
No known key found for this signature in database
GPG Key ID: 88928762974D3618
47 changed files with 454 additions and 402 deletions

24
LICENSE
View File

@ -68,3 +68,27 @@ CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
===== based on namecoin.py namecoin.py python implementation by Daniel Kraft <d@domob.eu>
Copyright (C) 2013 by Daniel Kraft <d@domob.eu>
This file is part of the Bitmessage project.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,173 +0,0 @@
#!/bin/bash
# INIT
MACHINE_TYPE=`uname -m`
BASE_DIR=$(pwd)
PYTHON_VERSION=2.7.15
PYQT_VERSION=4-4.11.4-gpl-Py2.7-Qt4.8.7
OPENSSL_VERSION=1_0_2t
DIRECTORY32BIT=SoftwareDownloads32bit
DIRECTORY64BIT=SoftwareDownloads64bit
if [ ${MACHINE_TYPE} == 'x86_64' ]; then
if [ ! -d "$DIRECTORY64BIT" ]; then
mkdir SoftwareDownloads64bit
cd SoftwareDownloads64bit
else
echo "Directory already exists"
cd SoftwareDownloads64bit
fi
else
if [ ! -d "$DIRECTORY32BIT" ]; then
mkdir SoftwareDownloads32bit
cd SoftwareDownloads32bit
else
echo "Directory 32 bit alrready exists"
cd SoftwareDownloads32bit
fi
fi
#Functions
function install_wine {
wget -nc https://dl.winehq.org/wine-builds/Release.key --no-check-certificate
sudo apt-key add Release.key
sudo apt-add-repository 'https://dl.winehq.org/wine-builds/ubuntu/'
sudo apt-get -y update
sudo apt-get -y install wine1.8 winetricks
if [ ${MACHINE_TYPE} == 'x86_64' ]; then
sudo apt-get -y install wine64-development
env WINEPREFIX=$HOME/.wine64 WINEARCH=win64 winecfg
WINE="env WINEPREFIX=$HOME/.wine64 wine"
export WINEPREFIX
else
sudo apt-get -y install wine32-development
env WINEPREFIX=$HOME/.wine32 WINEARCH=win32 winecfg
WINE="env WINEPREFIX=$HOME/.wine32 wine"
export WINEPREFIX
fi
}
function install_python(){
echo "Download Python2.7"
if [ ${MACHINE_TYPE} == 'x86_64' ]; then
# For 64 bit machine
wget -nc wget http://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}.amd64.msi --no-check-certificate
echo "Install Python2.7 for 64 bit"
$WINE msiexec -i python-${PYTHON_VERSION}.amd64.msi /q /norestart
wget -nc https://download.microsoft.com/download/d/2/4/d242c3fb-da5a-4542-ad66-f9661d0a8d19/vcredist_x64.exe --no-check-certificate
$WINE vcredist_x64.exe /q /norestart
echo "Installed vcredist for 64 bit"
$WINE pip install --upgrade pip
else
# For 32 bit machine
wget -nc https://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}.msi --no-check-certificate
echo "Install Python2.7 for 32 bit"
$WINE msiexec -i python-${PYTHON_VERSION}.msi /q /norestart
echo "Installing vc_redist for 32 bit "
wget -nc https://download.microsoft.com/download/1/1/1/1116b75a-9ec3-481a-a3c8-1777b5381140/vcredist_x86.exe --no-check-certificate
$WINE vcredist_x86.exe /q /norestart
#insatlled msvcr120.dll for 32 bit system
wget -nc http://www.dll-found.com/zip/m/msvcr120.dll.zip --no-check-certificate
unzip msvcr120.dll.zip
sudo cp msvcr120.dll $HOME/.wine32/drive_c/windows/system32/
$WINE pip install --upgrade pip
fi
}
function install_pyqt(){
echo "Download PyQT"
if [ ${MACHINE_TYPE} == 'x86_64' ]; then
# For 64 bit machine
wget -nc --content-disposition https://github.com/Bitmessage/ThirdPartyLibraries/blob/master/PyQt4-4.11.4-gpl-Py2.7-Qt4.8.7-x64.exe?raw=true --no-check-certificate
$WINE PyQt4-4.11.4-gpl-Py2.7-Qt4.8.7-x64.exe /q /norestart /silent /verysiling /sp- /suppressmsgboxes
else
# For 32 bit machine
wget -nc --content-disposition https://github.com/Bitmessage/ThirdPartyLibraries/blob/master/PyQt4-4.11.4-gpl-Py2.7-Qt4.8.7-x32.exe?raw=true --no-check-certificate
$WINE PyQt4-4.11.4-gpl-Py2.7-Qt4.8.7-x32.exe /q /norestart /silent /verysiling /sp- /suppressmsgboxes
fi
}
function install_openssl(){
if [ ${MACHINE_TYPE} == 'x86_64' ]; then
wget -nc --content-disposition https://github.com/Bitmessage/ThirdPartyLibraries/blob/master/Win64OpenSSL-${OPENSSL_VERSION}.exe?raw=true --no-check-certificate
$WINE Win64OpenSSL-${OPENSSL_VERSION}.exe /q /norestart /silent /verysiling /sp- /suppressmsgboxes
else
wget -nc --content-disposition https://github.com/Bitmessage/ThirdPartyLibraries/blob/master/Win32OpenSSL-${OPENSSL_VERSION}.exe?raw=true --no-check-certificate
$WINE Win32OpenSSL-${OPENSSL_VERSION}.exe /q /norestart /silent /verysiling /sp- /suppressmsgboxes
echo "Install PyInstaller 32 bit"
fi
}
function install_pyinstaller()
{
$WINE pip install pyinstaller
echo "Install PyInstaller"
echo "Install Pyopencl"
if [ ${MACHINE_TYPE} == 'x86_64' ]; then
wget -nc https://github.com/Bitmessage/ThirdPartyLibraries/blob/master/pyopencl-2015.1-cp27-none-win_amd64.whl --no-check-certificate
$WINE pip install pyopencl-2015.1-cp27-none-win_amd64.whl
$WINE pip install msgpack-python
else
wget -nc --content-disposition https://github.com/Bitmessage/ThirdPartyLibraries/blob/master/pyopencl-2015.1-cp27-none-win_amd64one-win32.whl?raw=true --no-check-certificate
$WINE pip install msgpack-python
$WINE pip install pyopencl-2015.1-cp27-none-win32.whl
fi
echo "Install Message Pack"
}
function build_dll(){
cd $BASE_DIR
rm -rf master.zip
rm -rf PyBitmessage
git clone https://github.com/Bitmessage/PyBitmessage.git
cd PyBitmessage/src/bitmsghash
if [ ${MACHINE_TYPE} == 'x86_64' ]; then
# Do stuff for 64 bit machine
echo "Install MinGW"
sudo apt-get -y install mingw-w64
echo "Create dll"
x86_64-w64-mingw32-g++ -D_WIN32 -Wall -O3 -march=native -I$HOME/.wine64/drive_c/OpenSSL-Win64/include -I/usr/x86_64-w64-mingw32/include -L$HOME/.wine64/drive_c/OpenSSL-Win64/lib -c bitmsghash.cpp
x86_64-w64-mingw32-g++ -static-libgcc -shared bitmsghash.o -D_WIN32 -O3 -march=native -I$HOME/.wine64/drive_c/OpenSSL-Win64/include -L$HOME/.wine64/drive_c/OpenSSL-Win64 -L/usr/lib/x86_64-linux-gnu/wine -fPIC -shared -lcrypt32 -leay32 -lwsock32 -o bitmsghash64.dll -Wl,--out-implib,bitmsghash.a
echo "DLL generated successfully "
cd ..
cp -R bitmsghash ../../../src/
cd ../../../
cd packages/pyinstaller/
env WINEPREFIX=$HOME/.wine64 wine pyinstaller bitmessagemain.spec
else
echo "Install MinGW for 32 bit"
sudo apt-get install mingw-w64
echo "Create dll"
i686-w64-mingw32-g++ -D_WIN32 -Wall -m32 -O3 -march=native -I$HOME/.wine32/drive_c/OpenSSL-Win32/include -I/usr/i686-w64-mingw32/include -L$HOME/.wine32/drive_c/OpenSSL-Win32/lib -c bitmsghash.cpp
i686-w64-mingw32-g++ -static-libgcc -shared bitmsghash.o -D_WIN32 -O3 -march=native -I$HOME/.wine32/drive_c/OpenSSL-Win32/include -L$HOME/.wine32/drive_c/OpenSSL-Win32/lib/MinGW -fPIC -shared -lcrypt32 -leay32 -lwsock32 -o bitmsghash32.dll -Wl,--out-implib,bitmsghash.a
cd ..
cp -R bitmsghash ../../../src/
cd ../../../
cd packages/pyinstaller/
env WINEPREFIX=$HOME/.wine32 wine pyinstaller bitmessagemain.spec
fi
}
install_wine
install_python
install_pyqt
install_openssl
install_pyinstaller
build_dll

165
buildscripts/winbuild.sh Executable file
View File

@ -0,0 +1,165 @@
#!/bin/bash
# INIT
MACHINE_TYPE=`uname -m`
BASE_DIR=$(pwd)
PYTHON_VERSION=2.7.17
PYQT_VERSION=4-4.11.4-gpl-Py2.7-Qt4.8.7
OPENSSL_VERSION=1_0_2t
SRCPATH=~/Downloads
#Functions
function download_sources_32 {
if [ ! -d ${SRCPATH} ]; then
mkdir -p ${SRCPATH}
fi
wget -P ${SRCPATH} -c -nc --content-disposition \
https://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}.msi \
https://download.microsoft.com/download/1/1/1/1116b75a-9ec3-481a-a3c8-1777b5381140/vcredist_x86.exe \
https://github.com/Bitmessage/ThirdPartyLibraries/blob/master/PyQt${PYQT_VERSION}-x32.exe?raw=true \
https://github.com/Bitmessage/ThirdPartyLibraries/blob/master/Win32OpenSSL-${OPENSSL_VERSION}.exe?raw=true \
https://github.com/Bitmessage/ThirdPartyLibraries/blob/master/pyopencl-2015.1-cp27-none-win32.whl?raw=true
}
function download_sources_64 {
if [ ! -d ${SRCPATH} ]; then
mkdir -p ${SRCPATH}
fi
wget -P ${SRCPATH} -c -nc --content-disposition \
http://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}.amd64.msi \
https://download.microsoft.com/download/d/2/4/d242c3fb-da5a-4542-ad66-f9661d0a8d19/vcredist_x64.exe \
https://github.com/Bitmessage/ThirdPartyLibraries/blob/master/PyQt${PYQT_VERSION}-x64.exe?raw=true \
https://github.com/Bitmessage/ThirdPartyLibraries/blob/master/Win64OpenSSL-${OPENSSL_VERSION}.exe?raw=true \
https://github.com/Bitmessage/ThirdPartyLibraries/blob/master/pyopencl-2015.1-cp27-none-win_amd64.whl?raw=true
}
function download_sources {
if [ ${MACHINE_TYPE} == 'x86_64' ]; then
download_sources_64
else
download_sources_32
fi
}
function install_wine {
echo "Setting up wine"
if [ ${MACHINE_TYPE} == 'x86_64' ]; then
export WINEPREFIX=${HOME}/.wine64 WINEARCH=win64
else
export WINEPREFIX=${HOME}/.wine32 WINEARCH=win32
fi
rm -rf ${WINEPREFIX}
rm -rf packages/pyinstaller/{build,dist}
}
function install_python(){
cd ${SRCPATH}
if [ ${MACHINE_TYPE} == 'x86_64' ]; then
echo "Installing Python ${PYTHON_VERSION} 64b"
wine msiexec -i python-${PYTHON_VERSION}.amd64.msi /q /norestart
echo "Installing vcredist for 64 bit"
wine vcredist_x64.exe /q /norestart
else
echo "Installing Python ${PYTHON_VERSION} 32b"
wine msiexec -i python-${PYTHON_VERSION}.msi /q /norestart
# MSVCR 2008 required for Windows XP
cd ${SRCPATH}
echo "Installing vc_redist (2008) for 32 bit "
wine vcredist_x86.exe /Q
fi
echo "Upgrading pip"
wine python -m pip install --upgrade pip
}
function install_pyqt(){
if [ ${MACHINE_TYPE} == 'x86_64' ]; then
echo "Installing PyQt-${PYQT_VERSION} 64b"
wine PyQt${PYQT_VERSION}-x64.exe /S /WX
else
echo "Installing PyQt-${PYQT_VERSION} 32b"
wine PyQt${PYQT_VERSION}-x32.exe /S /WX
fi
}
function install_openssl(){
if [ ${MACHINE_TYPE} == 'x86_64' ]; then
echo "Installing OpenSSL ${OPENSSL_VERSION} 64b"
wine Win64OpenSSL-${OPENSSL_VERSION}.exe /q /norestart /silent /verysilent /sp- /suppressmsgboxes
else
echo "Installing OpenSSL ${OPENSSL_VERSION} 32b"
wine Win32OpenSSL-${OPENSSL_VERSION}.exe /q /norestart /silent /verysilent /sp- /suppressmsgboxes
fi
}
function install_pyinstaller()
{
cd ${BASE_DIR}
echo "Installing PyInstaller"
if [ ${MACHINE_TYPE} == 'x86_64' ]; then
wine python -m pip install pyinstaller
else
# 3.2.1 is the last version to work on XP
# see https://github.com/pyinstaller/pyinstaller/issues/2931
wine python -m pip install -I pyinstaller==3.2.1
fi
}
function install_msgpack()
{
cd ${BASE_DIR}
echo "Installing msgpack"
wine python -m pip install msgpack-python
}
function install_pyopencl()
{
cd ${SRCPATH}
echo "Installing PyOpenCL"
if [ ${MACHINE_TYPE} == 'x86_64' ]; then
wine python -m pip install pyopencl-2015.1-cp27-none-win_amd64.whl
else
wine python -m pip install pyopencl-2015.1-cp27-none-win32.whl
fi
}
function build_dll(){
cd ${BASE_DIR}
cd src/bitmsghash
if [ ${MACHINE_TYPE} == 'x86_64' ]; then
echo "Create dll"
x86_64-w64-mingw32-g++ -D_WIN32 -Wall -O3 -march=native -I$HOME/.wine64/drive_c/OpenSSL-Win64/include -I/usr/x86_64-w64-mingw32/include -L$HOME/.wine64/drive_c/OpenSSL-Win64/lib -c bitmsghash.cpp
x86_64-w64-mingw32-g++ -static-libgcc -shared bitmsghash.o -D_WIN32 -O3 -march=native -I$HOME/.wine64/drive_c/OpenSSL-Win64/include -L$HOME/.wine64/drive_c/OpenSSL-Win64 -L/usr/lib/x86_64-linux-gnu/wine -fPIC -shared -lcrypt32 -leay32 -lwsock32 -o bitmsghash64.dll -Wl,--out-implib,bitmsghash.a
else
echo "Create dll"
i686-w64-mingw32-g++ -D_WIN32 -Wall -m32 -O3 -march=native -I$HOME/.wine32/drive_c/OpenSSL-Win32/include -I/usr/i686-w64-mingw32/include -L$HOME/.wine32/drive_c/OpenSSL-Win32/lib -c bitmsghash.cpp
i686-w64-mingw32-g++ -static-libgcc -shared bitmsghash.o -D_WIN32 -O3 -march=native -I$HOME/.wine32/drive_c/OpenSSL-Win32/include -L$HOME/.wine32/drive_c/OpenSSL-Win32/lib/MinGW -fPIC -shared -lcrypt32 -leay32 -lwsock32 -o bitmsghash32.dll -Wl,--out-implib,bitmsghash.a
fi
}
function build_exe(){
cd ${BASE_DIR}
cd packages/pyinstaller
wine pyinstaller bitmessagemain.spec
}
# prepare on ubuntu
# dpkg --add-architecture i386
# apt update
# apt -y install wget wine-stable wine-development winetricks mingw-w64 wine32 wine64 xvfb
download_sources
if [ "$1" == "--download-only" ]; then
exit
fi
install_wine
install_python
install_pyqt
install_openssl
install_pyopencl
install_msgpack
install_pyinstaller
build_dll
build_exe

View File

@ -11,13 +11,13 @@ else:
sslName = 'OpenSSL-Win%s' % ("32" if arch == 32 else "64") sslName = 'OpenSSL-Win%s' % ("32" if arch == 32 else "64")
site_root = os.path.abspath(HOMEPATH) site_root = os.path.abspath(HOMEPATH)
spec_root = os.path.abspath(SPECPATH) spec_root = os.path.abspath(SPECPATH)
cdrivePath= site_root[0:3] cdrivePath = site_root[0:3]
srcPath = spec_root[:-20]+"src\\" srcPath = os.path.join(spec_root[:-20], "src")
qtPath = site_root+"\\PyQt4\\" qtBase = "PyQt4"
openSSLPath = cdrivePath+sslName+"\\" openSSLPath = os.path.join(cdrivePath, sslName)
msvcrDllPath = cdrivePath+"windows\\system32\\" msvcrDllPath = os.path.join(cdrivePath, "windows", "system32")
pythonDllPath = cdrivePath+"Python27\\" pythonDllPath = os.path.join(cdrivePath, "Python27")
outPath = spec_root+"\\bitmessagemain" outPath = os.path.join(spec_root, "bitmessagemain")
importPath = srcPath importPath = srcPath
sys.path.insert(0,importPath) sys.path.insert(0,importPath)
@ -31,9 +31,9 @@ os.rename(os.path.join(srcPath, '__init__.py'), os.path.join(srcPath, '__init__.
# -*- mode: python -*- # -*- mode: python -*-
a = Analysis( a = Analysis(
[srcPath + 'bitmessagemain.py'], [os.path.join(srcPath, 'bitmessagemain.py')],
pathex=[outPath], pathex=[outPath],
hiddenimports=['pyopencl','numpy', 'win32com' , 'setuptools.msvc' ,'_cffi_backend'], hiddenimports=['bitmessageqt.languagebox', 'pyopencl','numpy', 'win32com' , 'setuptools.msvc' ,'_cffi_backend'],
hookspath=None, hookspath=None,
runtime_hooks=None runtime_hooks=None
) )
@ -43,23 +43,32 @@ os.rename(os.path.join(srcPath, '__init__.py.backup'), os.path.join(srcPath, '__
def addTranslations(): def addTranslations():
import os import os
extraDatas = [] extraDatas = []
for file in os.listdir(srcPath + 'translations'): for file_ in os.listdir(os.path.join(srcPath, 'translations')):
if file[-3:] != ".qm": if file_[-3:] != ".qm":
continue continue
extraDatas.append((os.path.join('translations', file), os.path.join(srcPath, 'translations', file), 'DATA')) extraDatas.append((os.path.join('translations', file_),
for file in os.listdir(qtPath + 'translations'): os.path.join(srcPath, 'translations', file_), 'DATA'))
if file[0:3] != "qt_" or file[5:8] != ".qm": for libdir in sys.path:
qtdir = os.path.join(libdir, qtBase, 'translations')
if os.path.isdir(qtdir):
break
if not os.path.isdir(qtdir):
return extraDatas
for file_ in os.listdir(qtdir):
if file_[0:3] != "qt_" or file_[5:8] != ".qm":
continue continue
extraDatas.append((os.path.join('translations', file), os.path.join(qtPath, 'translations', file), 'DATA')) extraDatas.append((os.path.join('translations', file_),
os.path.join(qtdir, file_), 'DATA'))
return extraDatas return extraDatas
def addUIs(): def addUIs():
import os import os
extraDatas = [] extraDatas = []
for file in os.listdir(srcPath + 'bitmessageqt'): for file_ in os.listdir(os.path.join(srcPath, 'bitmessageqt')):
if file[-3:] != ".ui": if file_[-3:] != ".ui":
continue continue
extraDatas.append((os.path.join('ui', file), os.path.join(srcPath, 'bitmessageqt', file), 'DATA')) extraDatas.append((os.path.join('ui', file_), os.path.join(srcPath,
'bitmessageqt', file_), 'DATA'))
return extraDatas return extraDatas
# append the translations directory # append the translations directory
@ -67,10 +76,8 @@ a.datas += addTranslations()
a.datas += addUIs() a.datas += addUIs()
a.binaries += [('libeay32.dll', os.path.join(openSSLPath, 'libeay32.dll'), 'BINARY'),
a.binaries += [('libeay32.dll', openSSLPath + 'libeay32.dll', 'BINARY'), ('python27.dll', os.path.join(pythonDllPath, 'python27.dll'), 'BINARY'),
('python27.dll', pythonDllPath + 'python27.dll', 'BINARY'),
('msvcr120.dll', msvcrDllPath + 'msvcr120.dll','BINARY'),
(os.path.join('bitmsghash', 'bitmsghash%i.dll' % (arch)), os.path.join(srcPath, 'bitmsghash', 'bitmsghash%i.dll' % (arch)), 'BINARY'), (os.path.join('bitmsghash', 'bitmsghash%i.dll' % (arch)), os.path.join(srcPath, 'bitmsghash', 'bitmsghash%i.dll' % (arch)), 'BINARY'),
(os.path.join('bitmsghash', 'bitmsghash.cl'), os.path.join(srcPath, 'bitmsghash', 'bitmsghash.cl'), 'BINARY'), (os.path.join('bitmsghash', 'bitmsghash.cl'), os.path.join(srcPath, 'bitmsghash', 'bitmsghash.cl'), 'BINARY'),
(os.path.join('sslkeys', 'cert.pem'), os.path.join(srcPath, 'sslkeys', 'cert.pem'), 'BINARY'), (os.path.join('sslkeys', 'cert.pem'), os.path.join(srcPath, 'sslkeys', 'cert.pem'), 'BINARY'),
@ -93,14 +100,14 @@ exe = EXE(pyz,
name=fname, name=fname,
debug=False, debug=False,
strip=None, strip=None,
upx=True, upx=False,
console=True, icon= os.path.join(srcPath, 'images', 'can-icon.ico')) console=False, icon= os.path.join(srcPath, 'images', 'can-icon.ico'))
coll = COLLECT(exe, coll = COLLECT(exe,
a.binaries, a.binaries,
a.zipfiles, a.zipfiles,
a.datas, a.datas,
strip=False, strip=False,
upx=True, upx=False,
name='main') name='main')

View File

@ -2,14 +2,12 @@
Operations with addresses Operations with addresses
""" """
# pylint: disable=redefined-outer-name,inconsistent-return-statements # pylint: disable=redefined-outer-name,inconsistent-return-statements
import hashlib import hashlib
from binascii import hexlify, unhexlify from binascii import hexlify, unhexlify
from struct import pack, unpack from struct import pack, unpack
from debug import logger from debug import logger
ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
@ -180,7 +178,8 @@ def decodeAddress(address):
returns (status, address version number, stream number, returns (status, address version number, stream number,
data (almost certainly a ripe hash)) data (almost certainly a ripe hash))
""" """
# pylint: disable=too-many-return-statements,too-many-statements,too-many-return-statements,too-many-branches # pylint: disable=too-many-return-statements,too-many-statements
# pylint: disable=too-many-branches
address = str(address).strip() address = str(address).strip()

View File

@ -1,15 +1,11 @@
# pylint: disable=too-many-locals,too-many-lines,no-self-use,too-many-public-methods,too-many-branches
# pylint: disable=too-many-statements
# Copyright (c) 2012-2016 Jonathan Warren
# Copyright (c) 2012-2020 The Bitmessage developers
""" """
This is not what you run to run the Bitmessage API. Instead, enable the API This is not what you run to run the Bitmessage API. Instead, enable the API
( https://bitmessage.org/wiki/API ) and optionally enable daemon mode ( https://bitmessage.org/wiki/API ) and optionally enable daemon mode
( https://bitmessage.org/wiki/Daemon ) then run bitmessagemain.py. ( https://bitmessage.org/wiki/Daemon ) then run bitmessagemain.py.
""" """
# Copyright (c) 2012-2016 Jonathan Warren
# Copyright (c) 2012-2020 The Bitmessage developers
# pylint: disable=too-many-lines,no-self-use,unused-variable,unused-argument
import base64 import base64
import errno import errno
import hashlib import hashlib
@ -22,8 +18,6 @@ from binascii import hexlify, unhexlify
from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler, SimpleXMLRPCServer from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler, SimpleXMLRPCServer
from struct import pack from struct import pack
from version import softwareVersion
import defaults import defaults
import helper_inbox import helper_inbox
import helper_sent import helper_sent
@ -33,13 +27,20 @@ import queues
import shared import shared
import shutdown import shutdown
import state import state
from addresses import addBMIfNotPresent, calculateInventoryHash, decodeAddress, decodeVarint, varintDecodeError from addresses import (
addBMIfNotPresent,
calculateInventoryHash,
decodeAddress,
decodeVarint,
varintDecodeError
)
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
from debug import logger from debug import logger
from helper_ackPayload import genAckPayload from helper_ackPayload import genAckPayload
from helper_sql import SqlBulkExecute, sqlExecute, sqlQuery, sqlStoredProcedure from helper_sql import SqlBulkExecute, sqlExecute, sqlQuery, sqlStoredProcedure
from inventory import Inventory from inventory import Inventory
from network.threads import StoppableThread from network.threads import StoppableThread
from version import softwareVersion
str_chan = '[chan]' str_chan = '[chan]'
@ -136,9 +137,11 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
""" """
This is one of several classes that constitute the API This is one of several classes that constitute the API
This class was written by Vaibhav Bhatia. Modified by Jonathan Warren (Atheros). This class was written by Vaibhav Bhatia.
Modified by Jonathan Warren (Atheros).
http://code.activestate.com/recipes/501148-xmlrpc-serverclient-which-does-cookie-handling-and/ http://code.activestate.com/recipes/501148-xmlrpc-serverclient-which-does-cookie-handling-and/
""" """
# pylint: disable=too-many-public-methods
def do_POST(self): def do_POST(self):
""" """
@ -175,7 +178,8 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
# SimpleXMLRPCDispatcher. To maintain backwards compatibility, # SimpleXMLRPCDispatcher. To maintain backwards compatibility,
# check to see if a subclass implements _dispatch and dispatch # check to see if a subclass implements _dispatch and dispatch
# using that method if present. # using that method if present.
response = self.server._marshaled_dispatch( # pylint: disable=protected-access # pylint: disable=protected-access
response = self.server._marshaled_dispatch(
data, getattr(self, '_dispatch', None) data, getattr(self, '_dispatch', None)
) )
except BaseException: # This should only happen if the module is buggy except BaseException: # This should only happen if the module is buggy
@ -213,8 +217,10 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
_, encstr = self.headers.get('Authorization').split() _, encstr = self.headers.get('Authorization').split()
emailid, password = encstr.decode('base64').split(':') emailid, password = encstr.decode('base64').split(':')
return ( return (
emailid == BMConfigParser().get('bitmessagesettings', 'apiusername') and emailid == BMConfigParser().get(
password == BMConfigParser().get('bitmessagesettings', 'apipassword') 'bitmessagesettings', 'apiusername') and
password == BMConfigParser().get(
'bitmessagesettings', 'apipassword')
) )
else: else:
logger.warning( logger.warning(
@ -251,10 +257,14 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
if status == 'invalidcharacters': if status == 'invalidcharacters':
raise APIError(9, 'Invalid characters in address: ' + address) raise APIError(9, 'Invalid characters in address: ' + address)
if status == 'versiontoohigh': if status == 'versiontoohigh':
raise APIError(10, 'Address version number too high (or zero) in address: ' + address) raise APIError(
10,
'Address version number too high (or zero) in address: ' +
address)
if status == 'varintmalformed': if status == 'varintmalformed':
raise APIError(26, 'Malformed varint in address: ' + address) raise APIError(26, 'Malformed varint in address: ' + address)
raise APIError(7, 'Could not decode address: %s : %s' % (address, status)) raise APIError(
7, 'Could not decode address: %s : %s' % (address, status))
if addressVersionNumber < 2 or addressVersionNumber > 4: if addressVersionNumber < 2 or addressVersionNumber > 4:
raise APIError( raise APIError(
11, 'The address version number currently must be 2, 3 or 4.' 11, 'The address version number currently must be 2, 3 or 4.'
@ -272,10 +282,9 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
def HandleListAddresses(self, method): def HandleListAddresses(self, method):
"""Handle a request to list addresses""" """Handle a request to list addresses"""
data = '{"addresses":[' data = '{"addresses":['
for addressInKeysFile in BMConfigParser().addresses(): for addressInKeysFile in BMConfigParser().addresses():
status, addressVersionNumber, streamNumber, hash01 = decodeAddress( # pylint: disable=unused-variable status, addressVersionNumber, streamNumber, hash01 = decodeAddress(
addressInKeysFile) addressInKeysFile)
if len(data) > 20: if len(data) > 20:
data += ',' data += ','
@ -379,16 +388,19 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
elif len(params) == 3: elif len(params) == 3:
label, eighteenByteRipe, totalDifficulty = params label, eighteenByteRipe, totalDifficulty = params
nonceTrialsPerByte = int( nonceTrialsPerByte = int(
defaults.networkDefaultProofOfWorkNonceTrialsPerByte * totalDifficulty) defaults.networkDefaultProofOfWorkNonceTrialsPerByte *
totalDifficulty)
payloadLengthExtraBytes = BMConfigParser().get( payloadLengthExtraBytes = BMConfigParser().get(
'bitmessagesettings', 'defaultpayloadlengthextrabytes') 'bitmessagesettings', 'defaultpayloadlengthextrabytes')
elif len(params) == 4: elif len(params) == 4:
label, eighteenByteRipe, totalDifficulty, \ label, eighteenByteRipe, totalDifficulty, \
smallMessageDifficulty = params smallMessageDifficulty = params
nonceTrialsPerByte = int( nonceTrialsPerByte = int(
defaults.networkDefaultProofOfWorkNonceTrialsPerByte * totalDifficulty) defaults.networkDefaultProofOfWorkNonceTrialsPerByte *
totalDifficulty)
payloadLengthExtraBytes = int( payloadLengthExtraBytes = int(
defaults.networkDefaultPayloadLengthExtraBytes * smallMessageDifficulty) defaults.networkDefaultPayloadLengthExtraBytes *
smallMessageDifficulty)
else: else:
raise APIError(0, 'Too many parameters!') raise APIError(0, 'Too many parameters!')
label = self._decode(label, "base64") label = self._decode(label, "base64")
@ -406,6 +418,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
def HandleCreateDeterministicAddresses(self, params): def HandleCreateDeterministicAddresses(self, params):
"""Handle a request to create a deterministic address""" """Handle a request to create a deterministic address"""
# pylint: disable=too-many-branches, too-many-statements
if not params: if not params:
raise APIError(0, 'I need parameters!') raise APIError(0, 'I need parameters!')
@ -461,7 +474,8 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
passphrase, numberOfAddresses, addressVersionNumber, \ passphrase, numberOfAddresses, addressVersionNumber, \
streamNumber, eighteenByteRipe, totalDifficulty = params streamNumber, eighteenByteRipe, totalDifficulty = params
nonceTrialsPerByte = int( nonceTrialsPerByte = int(
defaults.networkDefaultProofOfWorkNonceTrialsPerByte * totalDifficulty) defaults.networkDefaultProofOfWorkNonceTrialsPerByte *
totalDifficulty)
payloadLengthExtraBytes = BMConfigParser().get( payloadLengthExtraBytes = BMConfigParser().get(
'bitmessagesettings', 'defaultpayloadlengthextrabytes') 'bitmessagesettings', 'defaultpayloadlengthextrabytes')
@ -470,9 +484,11 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
streamNumber, eighteenByteRipe, totalDifficulty, \ streamNumber, eighteenByteRipe, totalDifficulty, \
smallMessageDifficulty = params smallMessageDifficulty = params
nonceTrialsPerByte = int( nonceTrialsPerByte = int(
defaults.networkDefaultProofOfWorkNonceTrialsPerByte * totalDifficulty) defaults.networkDefaultProofOfWorkNonceTrialsPerByte *
totalDifficulty)
payloadLengthExtraBytes = int( payloadLengthExtraBytes = int(
defaults.networkDefaultPayloadLengthExtraBytes * smallMessageDifficulty) defaults.networkDefaultPayloadLengthExtraBytes *
smallMessageDifficulty)
else: else:
raise APIError(0, 'Too many parameters!') raise APIError(0, 'Too many parameters!')
if not passphrase: if not passphrase:
@ -606,9 +622,8 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
label = str_chan + ' ' + passphrase label = str_chan + ' ' + passphrase
except BaseException: except BaseException:
label = str_chan + ' ' + repr(passphrase) label = str_chan + ' ' + repr(passphrase)
status, addressVersionNumber, streamNumber, toRipe = (
status, addressVersionNumber, streamNumber, toRipe = self._verifyAddress( # pylint: disable=unused-variable self._verifyAddress(suppliedAddress))
suppliedAddress)
suppliedAddress = addBMIfNotPresent(suppliedAddress) suppliedAddress = addBMIfNotPresent(suppliedAddress)
queues.apiAddressGeneratorReturnQueue.queue.clear() queues.apiAddressGeneratorReturnQueue.queue.clear()
queues.addressGeneratorQueue.put(( queues.addressGeneratorQueue.put((
@ -631,8 +646,8 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
raise APIError(0, 'I need parameters.') raise APIError(0, 'I need parameters.')
elif len(params) == 1: elif len(params) == 1:
address, = params address, = params
# pylint: disable=unused-variable status, addressVersionNumber, streamNumber, toRipe = (
status, addressVersionNumber, streamNumber, toRipe = self._verifyAddress(address) self._verifyAddress(address))
address = addBMIfNotPresent(address) address = addBMIfNotPresent(address)
if not BMConfigParser().has_section(address): if not BMConfigParser().has_section(address):
raise APIError( raise APIError(
@ -653,8 +668,8 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
raise APIError(0, 'I need parameters.') raise APIError(0, 'I need parameters.')
elif len(params) == 1: elif len(params) == 1:
address, = params address, = params
# pylint: disable=unused-variable status, addressVersionNumber, streamNumber, toRipe = (
status, addressVersionNumber, streamNumber, toRipe = self._verifyAddress(address) self._verifyAddress(address))
address = addBMIfNotPresent(address) address = addBMIfNotPresent(address)
if not BMConfigParser().has_section(address): if not BMConfigParser().has_section(address):
raise APIError( raise APIError(
@ -666,7 +681,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
shared.reloadMyAddressHashes() shared.reloadMyAddressHashes()
return 'success' return 'success'
def HandleGetAllInboxMessages(self, params): # pylint: disable=unused-argument def HandleGetAllInboxMessages(self, params):
"""Handle a request to get all inbox messages""" """Handle a request to get all inbox messages"""
queryreturn = sqlQuery( queryreturn = sqlQuery(
@ -694,7 +709,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
data += ']}' data += ']}'
return data return data
def HandleGetAllInboxMessageIds(self, params): # pylint: disable=unused-argument def HandleGetAllInboxMessageIds(self, params):
"""Handle a request to get all inbox message IDs""" """Handle a request to get all inbox message IDs"""
queryreturn = sqlQuery( queryreturn = sqlQuery(
@ -753,7 +768,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
data += ']}' data += ']}'
return data return data
def HandleGetAllSentMessages(self, params): # pylint: disable=unused-argument def HandleGetAllSentMessages(self, params):
"""Handle a request to get all sent messages""" """Handle a request to get all sent messages"""
queryreturn = sqlQuery( queryreturn = sqlQuery(
@ -782,7 +797,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
data += ']}' data += ']}'
return data return data
def HandleGetAllSentMessageIds(self, params): # pylint: disable=unused-argument def HandleGetAllSentMessageIds(self, params):
"""Handle a request to get all sent message IDs""" """Handle a request to get all sent message IDs"""
queryreturn = sqlQuery( queryreturn = sqlQuery(
@ -873,7 +888,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
data = '{"sentMessages":[' data = '{"sentMessages":['
for row in queryreturn: for row in queryreturn:
msgid, toAddress, fromAddress, subject, lastactiontime, message, \ msgid, toAddress, fromAddress, subject, lastactiontime, message, \
encodingtype, status, ackdata = row # pylint: disable=unused-variable encodingtype, status, ackdata = row
subject = shared.fixPotentiallyInvalidUTF8Data(subject) subject = shared.fixPotentiallyInvalidUTF8Data(subject)
message = shared.fixPotentiallyInvalidUTF8Data(message) message = shared.fixPotentiallyInvalidUTF8Data(message)
if len(data) > 25: if len(data) > 25:
@ -952,7 +967,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
sqlExecute('''UPDATE sent SET folder='trash' WHERE msgid=?''', msgid) sqlExecute('''UPDATE sent SET folder='trash' WHERE msgid=?''', msgid)
return 'Trashed sent message (assuming message existed).' return 'Trashed sent message (assuming message existed).'
def HandleSendMessage(self, params): def HandleSendMessage(self, params): # pylint: disable=too-many-locals
"""Handle a request to send a message""" """Handle a request to send a message"""
if not params: if not params:
@ -983,7 +998,6 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
TTL = 28 * 24 * 60 * 60 TTL = 28 * 24 * 60 * 60
toAddress = addBMIfNotPresent(toAddress) toAddress = addBMIfNotPresent(toAddress)
fromAddress = addBMIfNotPresent(fromAddress) fromAddress = addBMIfNotPresent(fromAddress)
# pylint: disable=unused-variable
status, addressVersionNumber, streamNumber, toRipe = \ status, addressVersionNumber, streamNumber, toRipe = \
self._verifyAddress(toAddress) self._verifyAddress(toAddress)
self._verifyAddress(fromAddress) self._verifyAddress(fromAddress)
@ -1157,10 +1171,9 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
queues.UISignalQueue.put(('rerenderSubscriptions', '')) queues.UISignalQueue.put(('rerenderSubscriptions', ''))
return 'Deleted subscription if it existed.' return 'Deleted subscription if it existed.'
def ListSubscriptions(self, params): # pylint: disable=unused-argument def ListSubscriptions(self, params):
"""Handle a request to list susbcriptions""" """Handle a request to list susbcriptions"""
# pylint: disable=unused-variable
queryreturn = sqlQuery( queryreturn = sqlQuery(
"SELECT label, address, enabled FROM subscriptions") "SELECT label, address, enabled FROM subscriptions")
data = {'subscriptions': []} data = {'subscriptions': []}
@ -1195,12 +1208,15 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
) )
with shared.printLock: with shared.printLock:
print( print(
'(For msg message via API) Doing proof of work. Total required difficulty:', '(For msg message via API) Doing proof of work.'
'Total required difficulty:',
float( float(
requiredAverageProofOfWorkNonceTrialsPerByte requiredAverageProofOfWorkNonceTrialsPerByte
) / defaults.networkDefaultProofOfWorkNonceTrialsPerByte, ) / defaults.networkDefaultProofOfWorkNonceTrialsPerByte,
'Required small message difficulty:', 'Required small message difficulty:',
float(requiredPayloadLengthExtraBytes) / defaults.networkDefaultPayloadLengthExtraBytes, float(
requiredPayloadLengthExtraBytes
) / defaults.networkDefaultPayloadLengthExtraBytes,
) )
powStartTime = time.time() powStartTime = time.time()
initialHash = hashlib.sha512(encryptedPayload).digest() initialHash = hashlib.sha512(encryptedPayload).digest()
@ -1209,8 +1225,9 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
print '(For msg message via API) Found proof of work', trialValue, 'Nonce:', nonce print '(For msg message via API) Found proof of work', trialValue, 'Nonce:', nonce
try: try:
print( print(
'POW took', int(time.time() - powStartTime), 'seconds.', 'POW took', int(time.time() - powStartTime),
nonce / (time.time() - powStartTime), 'nonce trials per second.', 'seconds.', nonce / (time.time() - powStartTime),
'nonce trials per second.',
) )
except BaseException: except BaseException:
pass pass
@ -1237,7 +1254,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
sqlExecute("UPDATE sent SET folder='trash' WHERE ackdata=?", ackdata) sqlExecute("UPDATE sent SET folder='trash' WHERE ackdata=?", ackdata)
return 'Trashed sent message (assuming message existed).' return 'Trashed sent message (assuming message existed).'
def HandleDissimatePubKey(self, params): # pylint: disable=unused-argument def HandleDissimatePubKey(self, params):
"""Handle a request to disseminate a public key""" """Handle a request to disseminate a public key"""
# The device issuing this command to PyBitmessage supplies a pubkey # The device issuing this command to PyBitmessage supplies a pubkey
@ -1266,7 +1283,6 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
pubkeyReadPosition += 8 pubkeyReadPosition += 8
else: else:
pubkeyReadPosition += 4 pubkeyReadPosition += 4
# pylint: disable=unused-variable
addressVersion, addressVersionLength = decodeVarint( addressVersion, addressVersionLength = decodeVarint(
payload[pubkeyReadPosition:pubkeyReadPosition + 10]) payload[pubkeyReadPosition:pubkeyReadPosition + 10])
pubkeyReadPosition += addressVersionLength pubkeyReadPosition += addressVersionLength
@ -1325,7 +1341,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
data += ']}' data += ']}'
return data return data
def HandleClientStatus(self, params): # pylint: disable=unused-argument def HandleClientStatus(self, params):
"""Handle a request to get the status of the client""" """Handle a request to get the status of the client"""
connections_num = len(network.stats.connectedHostsList()) connections_num = len(network.stats.connectedHostsList())

View File

@ -13,15 +13,15 @@ TODO: fix the following (currently ignored) violations:
""" """
import xmlrpclib
import datetime import datetime
import imghdr import imghdr
import ntpath
import json import json
import socket import ntpath
import time
import sys
import os import os
import socket
import sys
import time
import xmlrpclib
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser

View File

@ -9,7 +9,6 @@ The PyBitmessage startup script
# Right now, PyBitmessage only support connecting to stream 1. It doesn't # Right now, PyBitmessage only support connecting to stream 1. It doesn't
# yet contain logic to expand into further streams. # yet contain logic to expand into further streams.
import os import os
import sys import sys
import ctypes import ctypes
@ -26,8 +25,8 @@ from struct import pack
import defaults import defaults
import depends import depends
import shared import shared
import state
import shutdown import shutdown
import state
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
from debug import logger # this should go before any threads from debug import logger # this should go before any threads
from helper_startup import ( from helper_startup import (
@ -38,14 +37,15 @@ from inventory import Inventory
from knownnodes import readKnownNodes from knownnodes import readKnownNodes
# Network objects and threads # Network objects and threads
from network import ( from network import (
BMConnectionPool, Dandelion, BMConnectionPool, Dandelion, AddrThread, AnnounceThread, BMNetworkThread,
AddrThread, AnnounceThread, BMNetworkThread, InvThread, ReceiveQueueThread, InvThread, ReceiveQueueThread, DownloadThread, UploadThread
DownloadThread, UploadThread) )
from singleinstance import singleinstance from singleinstance import singleinstance
# Synchronous threads # Synchronous threads
from threads import ( from threads import (
set_thread_name, set_thread_name, addressGenerator, objectProcessor, singleCleaner,
addressGenerator, objectProcessor, singleCleaner, singleWorker, sqlThread) singleWorker, sqlThread
)
app_dir = os.path.dirname(os.path.abspath(__file__)) app_dir = os.path.dirname(os.path.abspath(__file__))
os.chdir(app_dir) os.chdir(app_dir)
@ -88,7 +88,8 @@ def _fixSocket():
addressToString = ctypes.windll.ws2_32.WSAAddressToStringA addressToString = ctypes.windll.ws2_32.WSAAddressToStringA
def inet_ntop(family, host): def inet_ntop(family, host):
"""Converting an IP address in packed binary format to string format""" """Converting an IP address in packed
binary format to string format"""
if family == socket.AF_INET: if family == socket.AF_INET:
if len(host) != 4: if len(host) != 4:
raise ValueError("invalid IPv4 host") raise ValueError("invalid IPv4 host")
@ -110,7 +111,8 @@ def _fixSocket():
stringToAddress = ctypes.windll.ws2_32.WSAStringToAddressA stringToAddress = ctypes.windll.ws2_32.WSAStringToAddressA
def inet_pton(family, host): def inet_pton(family, host):
"""Converting an IP address in string format to a packed binary format""" """Converting an IP address in string format
to a packed binary format"""
buf = "\0" * 28 buf = "\0" * 28
lengthBuf = pack("I", len(buf)) lengthBuf = pack("I", len(buf))
if stringToAddress(str(host), if stringToAddress(str(host),
@ -151,8 +153,8 @@ def signal_handler(signum, frame):
if thread.name not in ("PyBitmessage", "MainThread"): if thread.name not in ("PyBitmessage", "MainThread"):
return return
logger.error("Got signal %i", signum) logger.error("Got signal %i", signum)
# there are possible non-UI variants to run bitmessage which should shutdown # there are possible non-UI variants to run bitmessage
# especially test-mode # which should shutdown especially test-mode
if shared.thisapp.daemon or not state.enableGUI: if shared.thisapp.daemon or not state.enableGUI:
shutdown.doCleanShutdown() shutdown.doCleanShutdown()
else: else:
@ -381,10 +383,14 @@ class Main(object):
if daemon: if daemon:
while state.shutdown == 0: while state.shutdown == 0:
time.sleep(1) time.sleep(1)
if (state.testmode and time.time() - state.last_api_response >= 30): if (
state.testmode and time.time() -
state.last_api_response >= 30
):
self.stop() self.stop()
elif not state.enableGUI: elif not state.enableGUI:
from tests import core as test_core # pylint: disable=relative-import # pylint: disable=relative-import
from tests import core as test_core
test_core_result = test_core.run() test_core_result = test_core.run()
state.enableGUI = True state.enableGUI = True
self.stop() self.stop()
@ -408,7 +414,7 @@ class Main(object):
while True: while True:
time.sleep(1) time.sleep(1)
os._exit(0) # pylint: disable=protected-access os._exit(0) # pylint: disable=protected-access
except AttributeError: except AttributeError:
# fork not implemented # fork not implemented
pass pass
@ -429,8 +435,7 @@ class Main(object):
# wait until child ready # wait until child ready
while True: while True:
time.sleep(1) time.sleep(1)
os._exit(0) # pylint: disable=protected-access
os._exit(0) # pylint: disable=protected-access
except AttributeError: except AttributeError:
# fork not implemented # fork not implemented
pass pass

View File

@ -3,8 +3,8 @@ BMConfigParser class definition and default configuration settings
""" """
import ConfigParser import ConfigParser
import shutil
import os import os
import shutil
from datetime import datetime from datetime import datetime
import state import state
@ -47,6 +47,7 @@ class BMConfigParser(ConfigParser.SafeConfigParser):
Singleton class inherited from :class:`ConfigParser.SafeConfigParser` Singleton class inherited from :class:`ConfigParser.SafeConfigParser`
with additional methods specific to bitmessage config. with additional methods specific to bitmessage config.
""" """
# pylint: disable=too-many-ancestors
_temp = {} _temp = {}
@ -58,7 +59,8 @@ class BMConfigParser(ConfigParser.SafeConfigParser):
raise ValueError("Invalid value %s" % value) raise ValueError("Invalid value %s" % value)
return ConfigParser.ConfigParser.set(self, section, option, value) return ConfigParser.ConfigParser.set(self, section, option, value)
def get(self, section, option, raw=False, variables=None): # pylint: disable=arguments-differ def get(self, section, option, raw=False, variables=None):
# pylint: disable=arguments-differ
try: try:
if section == "bitmessagesettings" and option == "timeformat": if section == "bitmessagesettings" and option == "timeformat":
return ConfigParser.ConfigParser.get( return ConfigParser.ConfigParser.get(
@ -94,7 +96,8 @@ class BMConfigParser(ConfigParser.SafeConfigParser):
return False return False
def safeGetInt(self, section, field, default=0): def safeGetInt(self, section, field, default=0):
"""Return value as integer, default on exceptions, 0 if default missing""" """Return value as integer, default on exceptions,
0 if default missing"""
try: try:
return self.getint(section, field) return self.getint(section, field)
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError, except (ConfigParser.NoSectionError, ConfigParser.NoOptionError,
@ -109,8 +112,10 @@ class BMConfigParser(ConfigParser.SafeConfigParser):
ValueError, AttributeError): ValueError, AttributeError):
return default return default
def items(self, section, raw=False, variables=None): # pylint: disable=arguments-differ def items(self, section, raw=False, variables=None):
"""Return section variables as parent, but override the "raw" argument to always True""" """Return section variables as parent,
but override the "raw" argument to always True"""
# pylint: disable=arguments-differ
return ConfigParser.ConfigParser.items(self, section, True, variables) return ConfigParser.ConfigParser.items(self, section, True, variables)
@staticmethod @staticmethod

View File

@ -1,6 +1,6 @@
"""Building osx.""" """Building osx."""
from glob import glob
import os import os
from glob import glob
from PyQt4 import QtCore from PyQt4 import QtCore
from setuptools import setup from setuptools import setup
@ -13,8 +13,14 @@ DATA_FILES = [
('bitmsghash', ['bitmsghash/bitmsghash.cl', 'bitmsghash/bitmsghash.so']), ('bitmsghash', ['bitmsghash/bitmsghash.cl', 'bitmsghash/bitmsghash.so']),
('translations', glob('translations/*.qm')), ('translations', glob('translations/*.qm')),
('ui', glob('bitmessageqt/*.ui')), ('ui', glob('bitmessageqt/*.ui')),
('translations', glob(str(QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.TranslationsPath)) + '/qt_??.qm')), (
('translations', glob(str(QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.TranslationsPath)) + '/qt_??_??.qm')), 'translations',
glob(os.path.join(str(QtCore.QLibraryInfo.location(
QtCore.QLibraryInfo.TranslationsPath)), 'qt_??.qm'))),
(
'translations',
glob(os.path.join(str(QtCore.QLibraryInfo.location(
QtCore.QLibraryInfo.TranslationsPath)), 'qt_??_??.qm'))),
] ]
setup( setup(

View File

@ -1,21 +1,22 @@
""" """
A thread for creating addresses A thread for creating addresses
""" """
import time
import hashlib import hashlib
import time
from binascii import hexlify from binascii import hexlify
from pyelliptic import arithmetic
from pyelliptic.openssl import OpenSSL
import tr
import queues
import state
import shared
import defaults import defaults
import highlevelcrypto import highlevelcrypto
from bmconfigparser import BMConfigParser import queues
import shared
import state
import tr
from addresses import decodeAddress, encodeAddress, encodeVarint from addresses import decodeAddress, encodeAddress, encodeVarint
from bmconfigparser import BMConfigParser
from fallback import RIPEMD160Hash from fallback import RIPEMD160Hash
from network import StoppableThread from network import StoppableThread
from pyelliptic import arithmetic
from pyelliptic.openssl import OpenSSL
class addressGenerator(StoppableThread): class addressGenerator(StoppableThread):
@ -35,7 +36,8 @@ class addressGenerator(StoppableThread):
Process the requests for addresses generation Process the requests for addresses generation
from `.queues.addressGeneratorQueue` from `.queues.addressGeneratorQueue`
""" """
# pylint: disable=too-many-locals, too-many-branches, protected-access, too-many-statements # pylint: disable=too-many-locals, too-many-branches
# pylint: disable=protected-access, too-many-statements
while state.shutdown == 0: while state.shutdown == 0:
queueValue = queues.addressGeneratorQueue.get() queueValue = queues.addressGeneratorQueue.get()
nonceTrialsPerByte = 0 nonceTrialsPerByte = 0

View File

@ -1,6 +1,9 @@
""" """
The objectProcessor thread, of which there is only one, processes the network objects The objectProcessor thread, of which there is only one,
processes the network objects
""" """
# pylint: disable=too-many-locals,too-many-return-statements
# pylint: disable=too-many-branches,too-many-statements
import hashlib import hashlib
import logging import logging
import random import random
@ -9,31 +12,28 @@ import time
from binascii import hexlify from binascii import hexlify
from subprocess import call # nosec from subprocess import call # nosec
import highlevelcrypto
import knownnodes
import shared
from addresses import (
calculateInventoryHash, decodeAddress, decodeVarint, encodeAddress,
encodeVarint, varintDecodeError
)
from bmconfigparser import BMConfigParser
import helper_bitcoin import helper_bitcoin
import helper_inbox import helper_inbox
import helper_msgcoding import helper_msgcoding
import helper_sent import helper_sent
from helper_sql import SqlBulkExecute, sqlExecute, sqlQuery import highlevelcrypto
from helper_ackPayload import genAckPayload import knownnodes
from network import bmproto import l10n
from network.node import Peer
import protocol import protocol
import queues import queues
import shared
import state import state
import tr import tr
from addresses import (
calculateInventoryHash, decodeAddress, decodeVarint,
encodeAddress, encodeVarint, varintDecodeError
)
from bmconfigparser import BMConfigParser
from fallback import RIPEMD160Hash from fallback import RIPEMD160Hash
from helper_ackPayload import genAckPayload
import l10n from helper_sql import SqlBulkExecute, sqlExecute, sqlQuery
from network import bmproto
from network.node import Peer
# pylint: disable=too-many-locals, too-many-return-statements, too-many-branches, too-many-statements # pylint: disable=too-many-locals, too-many-return-statements, too-many-branches, too-many-statements
logger = logging.getLogger('default') logger = logging.getLogger('default')
@ -647,7 +647,8 @@ class objectProcessor(threading.Thread):
if decodeAddress(toAddress)[1] >= 3 \ if decodeAddress(toAddress)[1] >= 3 \
and not BMConfigParser().safeGetBoolean(toAddress, 'chan'): and not BMConfigParser().safeGetBoolean(toAddress, 'chan'):
# If I'm not friendly with this person: # If I'm not friendly with this person:
if not shared.isAddressInMyAddressBookSubscriptionsListOrWhitelist(fromAddress): if not shared.isAddressInMyAddressBookSubscriptionsListOrWhitelist(
fromAddress):
requiredNonceTrialsPerByte = BMConfigParser().getint( requiredNonceTrialsPerByte = BMConfigParser().getint(
toAddress, 'noncetrialsperbyte') toAddress, 'noncetrialsperbyte')
requiredPayloadLengthExtraBytes = BMConfigParser().getint( requiredPayloadLengthExtraBytes = BMConfigParser().getint(

View File

@ -30,7 +30,7 @@ import queues
import state import state
import tr import tr
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
from helper_sql import sqlQuery, sqlExecute from helper_sql import sqlExecute, sqlQuery
from inventory import Inventory from inventory import Inventory
from network import BMConnectionPool, StoppableThread from network import BMConnectionPool, StoppableThread

View File

@ -3,6 +3,8 @@ Thread for performing PoW
""" """
# pylint: disable=protected-access,too-many-branches,too-many-statements # pylint: disable=protected-access,too-many-branches,too-many-statements
# pylint: disable=no-self-use,too-many-lines,too-many-locals,relative-import # pylint: disable=no-self-use,too-many-lines,too-many-locals,relative-import
from __future__ import division from __future__ import division
import hashlib import hashlib
@ -23,7 +25,9 @@ import queues
import shared import shared
import state import state
import tr import tr
from addresses import calculateInventoryHash, decodeAddress, decodeVarint, encodeVarint from addresses import (
calculateInventoryHash, decodeAddress, decodeVarint, encodeVarint
)
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
from helper_sql import sqlExecute, sqlQuery from helper_sql import sqlExecute, sqlQuery
from inventory import Inventory from inventory import Inventory
@ -239,11 +243,13 @@ class singleWorker(StoppableThread):
return payload return payload
def doPOWForMyV2Pubkey(self, adressHash): def doPOWForMyV2Pubkey(self, adressHash):
""" This function also broadcasts out the pubkey message once it is done with the POW""" """ This function also broadcasts out the pubkey
message once it is done with the POW"""
# Look up my stream number based on my address hash # Look up my stream number based on my address hash
myAddress = shared.myAddressesByHash[adressHash] myAddress = shared.myAddressesByHash[adressHash]
# status # status
_, addressVersionNumber, streamNumber, adressHash = decodeAddress(myAddress) _, addressVersionNumber, streamNumber, adressHash = (
decodeAddress(myAddress))
# 28 days from now plus or minus five minutes # 28 days from now plus or minus five minutes
TTL = int(28 * 24 * 60 * 60 + helper_random.randomrandrange(-300, 300)) TTL = int(28 * 24 * 60 * 60 + helper_random.randomrandrange(-300, 300))

View File

@ -22,8 +22,9 @@ class smtpDeliver(StoppableThread):
_instance = None _instance = None
def stopThread(self): def stopThread(self):
# pylint: disable=no-member
try: try:
queues.UISignallerQueue.put(("stopThread", "data")) # pylint: disable=no-member queues.UISignallerQueue.put(("stopThread", "data"))
except: except:
pass pass
super(smtpDeliver, self).stopThread() super(smtpDeliver, self).stopThread()
@ -37,6 +38,7 @@ class smtpDeliver(StoppableThread):
def run(self): def run(self):
# pylint: disable=too-many-branches,too-many-statements,too-many-locals # pylint: disable=too-many-branches,too-many-statements,too-many-locals
# pylint: disable=deprecated-lambda
while state.shutdown == 0: while state.shutdown == 0:
command, data = queues.UISignalQueue.get() command, data = queues.UISignalQueue.get()
if command == 'writeNewAddressToTable': if command == 'writeNewAddressToTable':
@ -59,9 +61,9 @@ class smtpDeliver(StoppableThread):
msg = MIMEText(body, 'plain', 'utf-8') msg = MIMEText(body, 'plain', 'utf-8')
msg['Subject'] = Header(subject, 'utf-8') msg['Subject'] = Header(subject, 'utf-8')
msg['From'] = fromAddress + '@' + SMTPDOMAIN msg['From'] = fromAddress + '@' + SMTPDOMAIN
toLabel = map( # pylint: disable=deprecated-lambda toLabel = map(
lambda y: BMConfigParser().safeGet(y, "label"), lambda y: BMConfigParser().safeGet(y, "label"),
filter( # pylint: disable=deprecated-lambda filter(
lambda x: x == toAddress, BMConfigParser().addresses()) lambda x: x == toAddress, BMConfigParser().addresses())
) )
if toLabel: if toLabel:

View File

@ -76,8 +76,9 @@ class smtpServerPyBitmessage(smtpd.SMTPServer):
# print >> DEBUGSTREAM, 'Incoming connection from %s' % repr(addr) # print >> DEBUGSTREAM, 'Incoming connection from %s' % repr(addr)
self.channel = smtpServerChannel(self, conn, addr) self.channel = smtpServerChannel(self, conn, addr)
def send(self, fromAddress, toAddress, subject, message): # pylint: disable=arguments-differ def send(self, fromAddress, toAddress, subject, message):
"""Send a bitmessage""" """Send a bitmessage"""
# pylint: disable=arguments-differ
streamNumber, ripe = decodeAddress(toAddress)[2:] streamNumber, ripe = decodeAddress(toAddress)[2:]
stealthLevel = BMConfigParser().safeGetInt('bitmessagesettings', 'ackstealthlevel') stealthLevel = BMConfigParser().safeGetInt('bitmessagesettings', 'ackstealthlevel')
ackdata = genAckPayload(streamNumber, stealthLevel) ackdata = genAckPayload(streamNumber, stealthLevel)
@ -114,8 +115,9 @@ class smtpServerPyBitmessage(smtpd.SMTPServer):
return ret return ret
def process_message(self, peer, mailfrom, rcpttos, data): # pylint: disable=too-many-locals, too-many-branches def process_message(self, peer, mailfrom, rcpttos, data):
"""Process an email""" """Process an email"""
# pylint: disable=too-many-locals, too-many-branches
# print 'Receiving message from:', peer # print 'Receiving message from:', peer
p = re.compile(".*<([^>]+)>") p = re.compile(".*<([^>]+)>")
if not hasattr(self.channel, "auth") or not self.channel.auth: if not hasattr(self.channel, "auth") or not self.channel.auth:

View File

@ -2,15 +2,12 @@
sqlThread is defined here sqlThread is defined here
""" """
import threading
from bmconfigparser import BMConfigParser
import sqlite3
import time
import shutil # used for moving the messages.dat file
import sys
import os import os
from debug import logger import shutil # used for moving the messages.dat file
import sqlite3
import sys
import threading
import time
import helper_sql import helper_sql
import helper_startup import helper_startup
@ -18,6 +15,8 @@ import paths
import queues import queues
import state import state
import tr import tr
from bmconfigparser import BMConfigParser
from debug import logger
# pylint: disable=attribute-defined-outside-init,protected-access # pylint: disable=attribute-defined-outside-init,protected-access
@ -27,7 +26,7 @@ class sqlThread(threading.Thread):
def __init__(self): def __init__(self):
threading.Thread.__init__(self, name="SQL") threading.Thread.__init__(self, name="SQL")
def run(self): # pylint: disable=too-many-locals, too-many-branches, too-many-statements def run(self): # pylint: disable=too-many-locals, too-many-branches, too-many-statements
"""Process SQL queries from `.helper_sql.sqlSubmitQueue`""" """Process SQL queries from `.helper_sql.sqlSubmitQueue`"""
self.conn = sqlite3.connect(state.appdata + 'messages.dat') self.conn = sqlite3.connect(state.appdata + 'messages.dat')
self.conn.text_factory = str self.conn.text_factory = str

View File

@ -231,12 +231,13 @@ def check_sqlite():
conn.close() conn.close()
def check_openssl(): # pylint: disable=too-many-branches, too-many-return-statements def check_openssl():
"""Do openssl dependency check. """Do openssl dependency check.
Here we are checking for openssl with its all dependent libraries Here we are checking for openssl with its all dependent libraries
and version checking. and version checking.
""" """
# pylint: disable=too-many-branches, too-many-return-statements
# pylint: disable=protected-access, redefined-outer-name # pylint: disable=protected-access, redefined-outer-name
ctypes = try_import('ctypes') ctypes = try_import('ctypes')
if not ctypes: if not ctypes:

View File

@ -5,8 +5,8 @@ This module is for generating ack payload
from binascii import hexlify from binascii import hexlify
from struct import pack from struct import pack
import highlevelcrypto
import helper_random import helper_random
import highlevelcrypto
from addresses import encodeVarint from addresses import encodeVarint

View File

@ -5,6 +5,11 @@ Message encoding end decoding functions
import string import string
import zlib import zlib
import messagetypes
from bmconfigparser import BMConfigParser
from debug import logger
from tr import _translate
try: try:
import msgpack import msgpack
except ImportError: except ImportError:
@ -13,11 +18,6 @@ except ImportError:
except ImportError: except ImportError:
import fallback.umsgpack.umsgpack as msgpack import fallback.umsgpack.umsgpack as msgpack
import messagetypes
from bmconfigparser import BMConfigParser
from debug import logger
from tr import _translate
BITMESSAGE_ENCODING_IGNORE = 0 BITMESSAGE_ENCODING_IGNORE = 0
BITMESSAGE_ENCODING_TRIVIAL = 1 BITMESSAGE_ENCODING_TRIVIAL = 1
BITMESSAGE_ENCODING_SIMPLE = 2 BITMESSAGE_ENCODING_SIMPLE = 2

View File

@ -2,7 +2,9 @@
import os import os
import random import random
from pyelliptic.openssl import OpenSSL from pyelliptic.openssl import OpenSSL
NoneType = type(None) NoneType = type(None)

View File

@ -16,8 +16,8 @@ SQLite objects can only be used from one thread.
or isn't thread-safe. or isn't thread-safe.
""" """
import threading
import Queue import Queue
import threading
sqlSubmitQueue = Queue.Queue() sqlSubmitQueue = Queue.Queue()
"""the queue for SQL""" """the queue for SQL"""

View File

@ -1,8 +1,8 @@
"""The Inventory singleton""" """The Inventory singleton"""
# TODO make this dynamic, and watch out for frozen, like with messagetypes # TODO make this dynamic, and watch out for frozen, like with messagetypes
import storage.sqlite
import storage.filesystem import storage.filesystem
import storage.sqlite
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
from singleton import Singleton from singleton import Singleton

View File

@ -7,7 +7,6 @@ import time
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
logger = logging.getLogger('default') logger = logging.getLogger('default')

View File

@ -1,5 +1,6 @@
"""This module is for thread start.""" """This module is for thread start."""
import state import state
from bitmessagemain import main
if __name__ == '__main__': if __name__ == '__main__':
state.kivy = True state.kivy = True

View File

@ -1,6 +1,6 @@
import logging import logging
from importlib import import_module from importlib import import_module
from os import path, listdir from os import listdir, path
from string import lower from string import lower
try: try:
from kivy.utils import platform from kivy.utils import platform

View File

@ -1,28 +1,7 @@
# pylint: disable=too-many-branches,protected-access
""" """
Copyright (C) 2013 by Daniel Kraft <d@domob.eu>
Namecoin queries Namecoin queries
""" """
# This file is part of the Bitmessage project. # pylint: disable=too-many-branches,protected-access
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import base64 import base64
import httplib import httplib
@ -31,11 +10,11 @@ import os
import socket import socket
import sys import sys
from addresses import decodeAddress
from debug import logger
import defaults import defaults
import tr # translate import tr # translate
from addresses import decodeAddress
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
from debug import logger
configSection = "bitmessagesettings" configSection = "bitmessagesettings"

View File

@ -4,7 +4,6 @@ Announce myself (node address)
import time import time
import state import state
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
from network.assemble import assemble_addr from network.assemble import assemble_addr
from network.connectionpool import BMConnectionPool from network.connectionpool import BMConnectionPool

View File

@ -19,9 +19,9 @@ from bmconfigparser import BMConfigParser
from inventory import Inventory from inventory import Inventory
from network.advanceddispatcher import AdvancedDispatcher from network.advanceddispatcher import AdvancedDispatcher
from network.bmobject import ( from network.bmobject import (
BMObject, BMObjectInsufficientPOWError, BMObjectInvalidDataError, BMObject, BMObjectAlreadyHaveError, BMObjectExpiredError,
BMObjectExpiredError, BMObjectUnwantedStreamError, BMObjectInsufficientPOWError, BMObjectInvalidDataError,
BMObjectInvalidError, BMObjectAlreadyHaveError BMObjectInvalidError, BMObjectUnwantedStreamError
) )
from network.constants import ( from network.constants import (
ADDRESS_ALIVE, MAX_MESSAGE_SIZE, MAX_OBJECT_COUNT, ADDRESS_ALIVE, MAX_MESSAGE_SIZE, MAX_OBJECT_COUNT,
@ -30,8 +30,8 @@ from network.constants import (
from network.dandelion import Dandelion from network.dandelion import Dandelion
from network.proxy import ProxyError from network.proxy import ProxyError
from node import Node, Peer from node import Node, Peer
from objectracker import missingObjects, ObjectTracker from objectracker import ObjectTracker, missingObjects
from queues import objectProcessorQueue, portCheckerQueue, invQueue, addrQueue from queues import invQueue, objectProcessorQueue, portCheckerQueue
from randomtrackingdict import RandomTrackingDict from randomtrackingdict import RandomTrackingDict
logger = logging.getLogger('default') logger = logging.getLogger('default')
@ -466,8 +466,9 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
} }
# since we don't track peers outside of knownnodes, # since we don't track peers outside of knownnodes,
# only spread if in knownnodes to prevent flood # only spread if in knownnodes to prevent flood
addrQueue.put((stream, peer, seenTime, # DISABLED TO WORKAROUND FLOOD/LEAK
self.destination)) # addrQueue.put((stream, peer, seenTime,
# self.destination))
return True return True
def bm_command_portcheck(self): def bm_command_portcheck(self):

View File

@ -6,8 +6,8 @@ import Queue
import socket import socket
import state import state
from network.connectionpool import BMConnectionPool
from network.advanceddispatcher import UnknownStateError from network.advanceddispatcher import UnknownStateError
from network.connectionpool import BMConnectionPool
from queues import receiveDataQueue from queues import receiveDataQueue
from threads import StoppableThread from threads import StoppableThread

View File

@ -5,7 +5,7 @@ SOCKS4a proxy module
import socket import socket
import struct import struct
from proxy import Proxy, ProxyError, GeneralProxyError from proxy import GeneralProxyError, Proxy, ProxyError
class Socks4aError(ProxyError): class Socks4aError(ProxyError):

View File

@ -7,11 +7,10 @@ import socket
import ssl import ssl
import sys import sys
from network.advanceddispatcher import AdvancedDispatcher
import network.asyncore_pollchoose as asyncore import network.asyncore_pollchoose as asyncore
from queues import receiveDataQueue
import paths import paths
from network.advanceddispatcher import AdvancedDispatcher
from queues import receiveDataQueue
logger = logging.getLogger('default') logger = logging.getLogger('default')

3
src/nohup.out Normal file
View File

@ -0,0 +1,3 @@
python: can't open file 'main.py.py': [Errno 2] No such file or directory
[WARNING] [Config ] Older configuration version detected (21 instead of 20)
[WARNING] [Config ] Upgrading configuration in progress.

View File

@ -2,14 +2,14 @@
""" """
Module for Proof of Work using OpenCL Module for Proof of Work using OpenCL
""" """
from struct import pack, unpack
import hashlib import hashlib
import os import os
from struct import pack, unpack
from bmconfigparser import BMConfigParser
import paths import paths
from state import shutdown from bmconfigparser import BMConfigParser
from debug import logger from debug import logger
from state import shutdown
libAvailable = True libAvailable = True
ctx = False ctx = False

View File

@ -10,7 +10,6 @@ from datetime import datetime
from shutil import move from shutil import move
from kivy.utils import platform from kivy.utils import platform
logger = logging.getLogger('default') logger = logging.getLogger('default')
# When using py2exe or py2app, the variable frozen is added to the sys # When using py2exe or py2app, the variable frozen is added to the sys

View File

@ -6,7 +6,7 @@ A menu plugin showing QR-Code for bitmessage address in modal dialog.
import urllib import urllib
import qrcode import qrcode
from PyQt4 import QtGui, QtCore from PyQt4 import QtCore, QtGui
from pybitmessage.tr import _translate from pybitmessage.tr import _translate

View File

@ -11,8 +11,8 @@ Configure tor proxy and hidden service with
* otherwise use stem's 'BEST' version and save onion keys to the new * otherwise use stem's 'BEST' version and save onion keys to the new
section using *onionhostname* as name for future use. section using *onionhostname* as name for future use.
""" """
import os
import logging import logging
import os
import random # noseq import random # noseq
import tempfile import tempfile

View File

@ -3,9 +3,8 @@
Sound theme plugin using pycanberra Sound theme plugin using pycanberra
""" """
from pybitmessage.bitmessageqt import sound
import pycanberra import pycanberra
from pybitmessage.bitmessageqt import sound
_canberra = pycanberra.Canberra() _canberra = pycanberra.Canberra()

View File

@ -11,7 +11,7 @@ import socket
import sys import sys
import time import time
from binascii import hexlify from binascii import hexlify
from struct import pack, unpack, Struct from struct import Struct, pack, unpack
import defaults import defaults
import highlevelcrypto import highlevelcrypto

View File

@ -9,11 +9,11 @@ For modern cryptography with ECC, AES, HMAC, Blowfish, ...
This is an abandoned package maintained inside of the PyBitmessage. This is an abandoned package maintained inside of the PyBitmessage.
""" """
from .openssl import OpenSSL from .cipher import Cipher
from .ecc import ECC from .ecc import ECC
from .eccblind import ECCBlind from .eccblind import ECCBlind
from .cipher import Cipher
from .hash import hmac_sha256, hmac_sha512, pbkdf2 from .hash import hmac_sha256, hmac_sha512, pbkdf2
from .openssl import OpenSSL
__version__ = '1.3' __version__ = '1.3'

View File

@ -7,10 +7,10 @@
This module loads openssl libs with ctypes and incapsulates This module loads openssl libs with ctypes and incapsulates
needed openssl functionality in class _OpenSSL. needed openssl functionality in class _OpenSSL.
""" """
# pylint: disable=protected-access
import sys
import ctypes import ctypes
from kivy.utils import platform from kivy.utils import platform
import sys
# pylint: disable=protected-access
OpenSSL = None OpenSSL = None

View File

@ -11,8 +11,8 @@ Return a PIL Image class instance which have generated identicon image.
""" """
from PyQt4 import QtGui from PyQt4 import QtGui
from PyQt4.QtCore import QSize, QPointF, Qt from PyQt4.QtCore import QPointF, QSize, Qt
from PyQt4.QtGui import QPixmap, QPainter, QPolygonF from PyQt4.QtGui import QPainter, QPixmap, QPolygonF
class IdenticonRendererBase(object): class IdenticonRendererBase(object):

View File

@ -10,13 +10,14 @@ from __future__ import division
# Libraries. # Libraries.
import hashlib import hashlib
import os import os
import sys
import stat import stat
import threading
import subprocess import subprocess
import sys
import threading
from binascii import hexlify from binascii import hexlify
from pyelliptic import arithmetic from pyelliptic import arithmetic
from kivy.utils import platform from kivy.utils import platform
# Project imports. # Project imports.
import highlevelcrypto import highlevelcrypto
import state import state
@ -25,6 +26,8 @@ from bmconfigparser import BMConfigParser
from debug import logger from debug import logger
from helper_sql import sqlQuery from helper_sql import sqlQuery
from pyelliptic import arithmetic
verbose = 1 verbose = 1
# This is obsolete with the change to protocol v3 # This is obsolete with the change to protocol v3
@ -118,7 +121,7 @@ def decodeWalletImportFormat(WIFstring):
' 6 characters of the PRIVATE key: %s', ' 6 characters of the PRIVATE key: %s',
str(WIFstring)[:6] str(WIFstring)[:6]
) )
os._exit(0) # pylint: disable=protected-access os._exit(0) # pylint: disable=protected-access
# return "" # return ""
elif privkey[0] == '\x80': # checksum passed elif privkey[0] == '\x80': # checksum passed
return privkey[1:] return privkey[1:]
@ -128,7 +131,7 @@ def decodeWalletImportFormat(WIFstring):
' the checksum passed but the key doesn\'t begin with hex 80.' ' the checksum passed but the key doesn\'t begin with hex 80.'
' Here is the PRIVATE key: %s', WIFstring ' Here is the PRIVATE key: %s', WIFstring
) )
os._exit(0) # pylint: disable=protected-access os._exit(0) # pylint: disable=protected-access
def reloadMyAddressHashes(): def reloadMyAddressHashes():

View File

@ -1,14 +1,14 @@
""" """
Module for using filesystem (directory with files) for inventory storage Module for using filesystem (directory with files) for inventory storage
""" """
import string
import time
from binascii import hexlify, unhexlify from binascii import hexlify, unhexlify
from os import listdir, makedirs, path, remove, rmdir from os import listdir, makedirs, path, remove, rmdir
import string
from threading import RLock from threading import RLock
import time
from paths import lookupAppdataFolder from paths import lookupAppdataFolder
from storage import InventoryStorage, InventoryItem from storage import InventoryItem, InventoryStorage
class FilesystemInventory(InventoryStorage): class FilesystemInventory(InventoryStorage):

View File

@ -5,8 +5,8 @@ import sqlite3
import time import time
from threading import RLock from threading import RLock
from helper_sql import sqlQuery, SqlBulkExecute, sqlExecute from helper_sql import SqlBulkExecute, sqlExecute, sqlQuery
from storage import InventoryStorage, InventoryItem from storage import InventoryItem, InventoryStorage
class SqliteInventory(InventoryStorage): # pylint: disable=too-many-ancestors class SqliteInventory(InventoryStorage): # pylint: disable=too-many-ancestors

View File

@ -15,6 +15,12 @@ There are also other threads in the `.network` package.
import threading import threading
from class_addressGenerator import addressGenerator
from class_objectProcessor import objectProcessor
from class_singleCleaner import singleCleaner
from class_singleWorker import singleWorker
from class_sqlThread import sqlThread
try: try:
import prctl import prctl
except ImportError: except ImportError:
@ -33,12 +39,6 @@ else:
threading.Thread.__bootstrap_original__ = threading.Thread._Thread__bootstrap threading.Thread.__bootstrap_original__ = threading.Thread._Thread__bootstrap
threading.Thread._Thread__bootstrap = _thread_name_hack threading.Thread._Thread__bootstrap = _thread_name_hack
from class_addressGenerator import addressGenerator
from class_objectProcessor import objectProcessor
from class_singleCleaner import singleCleaner
from class_singleWorker import singleWorker
from class_sqlThread import sqlThread
__all__ = [ __all__ = [
"addressGenerator", "objectProcessor", "singleCleaner", "singleWorker", "addressGenerator", "objectProcessor", "singleCleaner", "singleWorker",

View File

@ -25,7 +25,8 @@ class translateClass:
return self.text return self.text
def _translate(context, text, disambiguation=None, encoding=None, n=None): # pylint: disable=unused-argument def _translate(context, text, disambiguation=None, encoding=None, n=None):
# pylint: disable=unused-argument
return translateText(context, text, n) return translateText(context, text, n)
@ -45,7 +46,7 @@ def translateText(context, text, n=None):
' or by searching Google for \'PyQt Download\'.'\ ' or by searching Google for \'PyQt Download\'.'\
' If you want to run in daemon mode, see https://bitmessage.org/wiki/Daemon' ' If you want to run in daemon mode, see https://bitmessage.org/wiki/Daemon'
print 'Error message:', err print 'Error message:', err
os._exit(0) # pylint: disable=protected-access os._exit(0) # pylint: disable=protected-access
if n is None: if n is None:
return QtGui.QApplication.translate(context, text) return QtGui.QApplication.translate(context, text)
return QtGui.QApplication.translate(context, text, None, QtCore.QCoreApplication.CodecForTr, n) return QtGui.QApplication.translate(context, text, None, QtCore.QCoreApplication.CodecForTr, n)