Merge branch 'py3' into py3qt
This commit is contained in:
commit
74a453ba31
|
@ -22,7 +22,7 @@ RUN apt-get -y update -qq \
|
||||||
RUN apt-get -y install -qq --no-install-recommends openjdk-17-jdk \
|
RUN apt-get -y install -qq --no-install-recommends openjdk-17-jdk \
|
||||||
&& apt-get -y autoremove
|
&& apt-get -y autoremove
|
||||||
|
|
||||||
RUN pip install pip install buildozer cython virtualenv
|
RUN pip install buildozer cython virtualenv
|
||||||
|
|
||||||
|
|
||||||
ENV ANDROID_NDK_HOME="${ANDROID_HOME}/android-ndk"
|
ENV ANDROID_NDK_HOME="${ANDROID_HOME}/android-ndk"
|
||||||
|
|
|
@ -1,9 +1,32 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
export LC_ALL=en_US.UTF-8
|
export LC_ALL=en_US.UTF-8
|
||||||
export LANG=en_US.UTF-8
|
export LANG=en_US.UTF-8
|
||||||
|
|
||||||
|
# buildozer OOM workaround
|
||||||
|
mkdir -p ~/.gradle
|
||||||
|
echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8" \
|
||||||
|
> ~/.gradle/gradle.properties
|
||||||
|
|
||||||
|
# workaround for symlink
|
||||||
|
rm -rf src/pybitmessage
|
||||||
|
mkdir -p src/pybitmessage
|
||||||
|
cp src/*.py src/pybitmessage
|
||||||
|
cp -r src/bitmessagekivy src/backend src/mockbm src/pybitmessage
|
||||||
|
|
||||||
pushd packages/android
|
pushd packages/android
|
||||||
buildozer android debug || exit $?
|
|
||||||
|
BUILDMODE=debug
|
||||||
|
|
||||||
|
if [ "$BUILDBOT_JOBNAME" = "android" -a \
|
||||||
|
"$BUILDBOT_REPOSITORY" = "https://github.com/Bitmessage/PyBitmessage" -a \
|
||||||
|
"$BUILDBOT_BRANCH" = "v0.6" ]; then
|
||||||
|
sed -e 's/android.release_artifact *=.*/release_artifact = aab/' -i "" buildozer.spec
|
||||||
|
BUILDMODE=release
|
||||||
|
fi
|
||||||
|
|
||||||
|
buildozer android $BUILDMODE || exit $?
|
||||||
popd
|
popd
|
||||||
|
|
||||||
mkdir -p ../out
|
mkdir -p ../out
|
||||||
cp packages/android/bin/*.apk ../out
|
RELEASE_ARTIFACT=$(grep release_artifact packages/android/buildozer.spec |cut -d= -f2|tr -Cd 'a-z')
|
||||||
|
cp packages/android/bin/*.${RELEASE_ARTIFACT} ../out
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
RELEASE_ARTIFACT=$(grep release_artifact packages/android/buildozer.spec |cut -d= -f2|tr -Cd 'a-z')
|
||||||
|
|
||||||
|
if [ $RELEASE_ARTIFACT = "aab" ]; then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
unzip -p packages/android/bin/*.apk assets/private.tar \
|
unzip -p packages/android/bin/*.apk assets/private.tar \
|
||||||
| tar --list -z > package.list
|
| tar --list -z > package.list
|
||||||
cat package.list
|
cat package.list
|
||||||
|
|
|
@ -24,3 +24,5 @@ RUN wget -qO appimage-builder-x86_64.AppImage \
|
||||||
https://github.com/AppImageCrafters/appimage-builder/releases/download/v1.1.0/appimage-builder-1.1.0-x86_64.AppImage
|
https://github.com/AppImageCrafters/appimage-builder/releases/download/v1.1.0/appimage-builder-1.1.0-x86_64.AppImage
|
||||||
|
|
||||||
ADD . .
|
ADD . .
|
||||||
|
|
||||||
|
CMD .buildbot/tox-bionic/build.sh
|
||||||
|
|
|
@ -20,3 +20,7 @@ RUN python3.8 -m pip install --upgrade pip tox virtualenv
|
||||||
ENV LANG en_US.UTF-8
|
ENV LANG en_US.UTF-8
|
||||||
ENV LANGUAGE en_US:en
|
ENV LANGUAGE en_US:en
|
||||||
ENV LC_ALL en_US.UTF-8
|
ENV LC_ALL en_US.UTF-8
|
||||||
|
|
||||||
|
ADD . .
|
||||||
|
|
||||||
|
CMD .buildbot/tox-bionic/test.sh
|
||||||
|
|
|
@ -13,3 +13,5 @@ RUN apt-get install -yq --no-install-suggests --no-install-recommends \
|
||||||
RUN python3.9 -m pip install --upgrade pip tox virtualenv
|
RUN python3.9 -m pip install --upgrade pip tox virtualenv
|
||||||
|
|
||||||
ADD . .
|
ADD . .
|
||||||
|
|
||||||
|
CMD .buildbot/tox-focal/test.sh
|
||||||
|
|
|
@ -10,3 +10,7 @@ RUN apt-get install -yq --no-install-suggests --no-install-recommends \
|
||||||
python3-dev python3-pip language-pack-en qt5dxcb-plugin tor xvfb
|
python3-dev python3-pip language-pack-en qt5dxcb-plugin tor xvfb
|
||||||
|
|
||||||
RUN pip install tox
|
RUN pip install tox
|
||||||
|
|
||||||
|
ADD . .
|
||||||
|
|
||||||
|
CMD .buildbot/tox-jammy/test.sh
|
||||||
|
|
11
docker-test.sh
Executable file
11
docker-test.sh
Executable file
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
DOCKERFILE=.buildbot/tox-bionic/Dockerfile
|
||||||
|
|
||||||
|
docker build -t pybm/tox -f $DOCKERFILE .
|
||||||
|
|
||||||
|
if [ $? -gt 0 ]; then
|
||||||
|
docker build --no-cache -t pybm/tox -f $DOCKERFILE .
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker run --rm -it pybm/tox
|
|
@ -1,19 +1,19 @@
|
||||||
[app]
|
[app]
|
||||||
|
|
||||||
# (str) Title of your application
|
# (str) Title of your application
|
||||||
title = mockone
|
title = PyBitmessage Mock
|
||||||
|
|
||||||
# (str) Package name
|
# (str) Package name
|
||||||
package.name = mock
|
package.name = pybitmessagemock
|
||||||
|
|
||||||
# (str) Package domain (needed for android/ios packaging)
|
# (str) Package domain (needed for android/ios packaging)
|
||||||
package.domain = org.mock
|
package.domain = at.bitmessage
|
||||||
|
|
||||||
# (str) Source code where the main.py live
|
# (str) Source code where the main.py live
|
||||||
source.dir = ../../src
|
source.dir = ../../src
|
||||||
|
|
||||||
# (list) Source files to include (let empty to include all the files)
|
# (list) Source files to include (let empty to include all the files)
|
||||||
source.include_exts = py,png,jpg,kv,atlas,tflite,sql
|
source.include_exts = py,png,jpg,kv,atlas,tflite,sql,json
|
||||||
|
|
||||||
# (list) List of inclusions using pattern matching
|
# (list) List of inclusions using pattern matching
|
||||||
#source.include_patterns = assets/*,images/*.png
|
#source.include_patterns = assets/*,images/*.png
|
||||||
|
@ -28,7 +28,7 @@ source.include_exts = py,png,jpg,kv,atlas,tflite,sql
|
||||||
#source.exclude_patterns = license,images/*/*.jpg
|
#source.exclude_patterns = license,images/*/*.jpg
|
||||||
|
|
||||||
# (str) Application versioning (method 1)
|
# (str) Application versioning (method 1)
|
||||||
version = 0.1
|
version = 0.1.1
|
||||||
|
|
||||||
# (str) Application versioning (method 2)
|
# (str) Application versioning (method 2)
|
||||||
# version.regex = __version__ = ['"](.*)['"]
|
# version.regex = __version__ = ['"](.*)['"]
|
||||||
|
@ -36,7 +36,7 @@ version = 0.1
|
||||||
|
|
||||||
# (list) Application requirements
|
# (list) Application requirements
|
||||||
# comma separated e.g. requirements = sqlite3,kivy
|
# comma separated e.g. requirements = sqlite3,kivy
|
||||||
requirements = python3,kivy
|
requirements = python3,kivy,sqlite3,kivymd==1.0.2,Pillow,opencv,kivy-garden.qrcode,qrcode,typing_extensions,libpng
|
||||||
|
|
||||||
# (str) Custom source folders for requirements
|
# (str) Custom source folders for requirements
|
||||||
# Sets custom source for any requirements with recipes
|
# Sets custom source for any requirements with recipes
|
||||||
|
@ -92,7 +92,7 @@ fullscreen = 0
|
||||||
|
|
||||||
# (int) Android API to use (targetSdkVersion AND compileSdkVersion)
|
# (int) Android API to use (targetSdkVersion AND compileSdkVersion)
|
||||||
# note: when changing, Dockerfile also needs to be changed to install corresponding build tools
|
# note: when changing, Dockerfile also needs to be changed to install corresponding build tools
|
||||||
android.api = 28
|
android.api = 33
|
||||||
|
|
||||||
# (int) Minimum API required. You will need to set the android.ndk_api to be as low as this value.
|
# (int) Minimum API required. You will need to set the android.ndk_api to be as low as this value.
|
||||||
android.minapi = 21
|
android.minapi = 21
|
||||||
|
@ -243,6 +243,8 @@ android.allow_backup = True
|
||||||
# Usage example : android.manifest_placeholders = [myCustomUrl:\"org.kivy.customurl\"]
|
# Usage example : android.manifest_placeholders = [myCustomUrl:\"org.kivy.customurl\"]
|
||||||
# android.manifest_placeholders = [:]
|
# android.manifest_placeholders = [:]
|
||||||
|
|
||||||
|
android.release_artifact = apk
|
||||||
|
|
||||||
#
|
#
|
||||||
# Python for android (p4a) specific
|
# Python for android (p4a) specific
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
coverage
|
coverage
|
||||||
psutil
|
psutil
|
||||||
pycryptodome
|
pycryptodome
|
||||||
PyQt5;python_version>="3.7"
|
PyQt5;python_version>="3.7" and platform_machine=="x86_64"
|
||||||
mock;python_version<="2.7"
|
mock;python_version<="2.7"
|
||||||
python_prctl;platform_system=="Linux"
|
python_prctl;platform_system=="Linux"
|
||||||
six
|
six
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
DOCKERFILE=packages/docker/Dockerfile.bionic
|
|
||||||
|
|
||||||
# explicitly mark appimage stage because it builds in any case
|
|
||||||
docker build --target appimage -t pybm/appimage -f $DOCKERFILE .
|
|
||||||
|
|
||||||
if [ $? -gt 0 ]; then
|
|
||||||
docker build --no-cache --target appimage -t pybm/appimage -f $DOCKERFILE .
|
|
||||||
fi
|
|
||||||
|
|
||||||
docker build --target tox -t pybm/tox -f $DOCKERFILE .
|
|
||||||
docker run --rm -t pybm/tox
|
|
|
@ -103,7 +103,7 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
connectionpool = None
|
connectionpool = None
|
||||||
|
|
||||||
from network import stats, StoppableThread
|
from network import stats, StoppableThread, invQueue
|
||||||
from version import softwareVersion
|
from version import softwareVersion
|
||||||
|
|
||||||
try: # TODO: write tests for XML vulnerabilities
|
try: # TODO: write tests for XML vulnerabilities
|
||||||
|
@ -1383,7 +1383,7 @@ class BMRPCDispatcher(object):
|
||||||
logger.info(
|
logger.info(
|
||||||
'Broadcasting inv for msg(API disseminatePreEncryptedMsg'
|
'Broadcasting inv for msg(API disseminatePreEncryptedMsg'
|
||||||
' command): %s', hexlify(inventoryHash))
|
' command): %s', hexlify(inventoryHash))
|
||||||
queues.invQueue.put((toStreamNumber, inventoryHash))
|
invQueue.put((toStreamNumber, inventoryHash))
|
||||||
return hexlify(inventoryHash).decode()
|
return hexlify(inventoryHash).decode()
|
||||||
|
|
||||||
@command('trashSentMessageByAckData')
|
@command('trashSentMessageByAckData')
|
||||||
|
@ -1440,7 +1440,7 @@ class BMRPCDispatcher(object):
|
||||||
logger.info(
|
logger.info(
|
||||||
'broadcasting inv within API command disseminatePubkey with'
|
'broadcasting inv within API command disseminatePubkey with'
|
||||||
' hash: %s', hexlify(inventoryHash))
|
' hash: %s', hexlify(inventoryHash))
|
||||||
queues.invQueue.put((pubkeyStreamNumber, inventoryHash))
|
invQueue.put((pubkeyStreamNumber, inventoryHash))
|
||||||
|
|
||||||
@command(
|
@command(
|
||||||
'getMessageDataByDestinationHash', 'getMessageDataByDestinationTag')
|
'getMessageDataByDestinationHash', 'getMessageDataByDestinationTag')
|
||||||
|
|
|
@ -8,6 +8,8 @@ import tempfile
|
||||||
from time import time, sleep
|
from time import time, sleep
|
||||||
from six.moves import getcwdb
|
from six.moves import getcwdb
|
||||||
|
|
||||||
|
from requests.exceptions import ChunkedEncodingError
|
||||||
|
|
||||||
from telenium.tests import TeleniumTestCase
|
from telenium.tests import TeleniumTestCase
|
||||||
from telenium.client import TeleniumHttpException
|
from telenium.client import TeleniumHttpException
|
||||||
|
|
||||||
|
@ -55,7 +57,10 @@ class TeleniumTestProcess(TeleniumTestCase):
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
"""Ensures that pybitmessage stopped and removes files"""
|
"""Ensures that pybitmessage stopped and removes files"""
|
||||||
# pylint: disable=no-member
|
# pylint: disable=no-member
|
||||||
|
try:
|
||||||
super(TeleniumTestProcess, cls).tearDownClass()
|
super(TeleniumTestProcess, cls).tearDownClass()
|
||||||
|
except ChunkedEncodingError:
|
||||||
|
pass
|
||||||
cleanup()
|
cleanup()
|
||||||
|
|
||||||
def assert_wait_no_except(self, selector, timeout=-1, value='inbox'):
|
def assert_wait_no_except(self, selector, timeout=-1, value='inbox'):
|
||||||
|
|
|
@ -31,7 +31,7 @@ from addresses import (
|
||||||
from bmconfigparser import config
|
from bmconfigparser import config
|
||||||
from helper_sql import (
|
from helper_sql import (
|
||||||
sql_ready, sql_timeout, SqlBulkExecute, sqlExecute, sqlQuery)
|
sql_ready, sql_timeout, SqlBulkExecute, sqlExecute, sqlQuery)
|
||||||
from network import knownnodes
|
from network import knownnodes, invQueue
|
||||||
from network.node import Peer
|
from network.node import Peer
|
||||||
from tr import _translate
|
from tr import _translate
|
||||||
from dbcompat import dbstr
|
from dbcompat import dbstr
|
||||||
|
@ -738,7 +738,7 @@ class objectProcessor(threading.Thread):
|
||||||
inventoryHash = highlevelcrypto.calculateInventoryHash(ackPayload)
|
inventoryHash = highlevelcrypto.calculateInventoryHash(ackPayload)
|
||||||
state.Inventory[inventoryHash] = (
|
state.Inventory[inventoryHash] = (
|
||||||
objectType, toStreamNumber, ackPayload, expiresTime, b'')
|
objectType, toStreamNumber, ackPayload, expiresTime, b'')
|
||||||
queues.invQueue.put((toStreamNumber, inventoryHash))
|
invQueue.put((toStreamNumber, inventoryHash))
|
||||||
|
|
||||||
# Display timing data
|
# Display timing data
|
||||||
timeRequiredToAttemptToDecryptMessage = time.time(
|
timeRequiredToAttemptToDecryptMessage = time.time(
|
||||||
|
|
|
@ -28,7 +28,7 @@ import state
|
||||||
from addresses import decodeAddress, decodeVarint, encodeVarint
|
from addresses import decodeAddress, decodeVarint, encodeVarint
|
||||||
from bmconfigparser import config
|
from bmconfigparser import config
|
||||||
from helper_sql import sqlExecute, sqlQuery
|
from helper_sql import sqlExecute, sqlQuery
|
||||||
from network import knownnodes, StoppableThread
|
from network import knownnodes, StoppableThread, invQueue
|
||||||
from six.moves import configparser, queue
|
from six.moves import configparser, queue
|
||||||
from six.moves.reprlib import repr
|
from six.moves.reprlib import repr
|
||||||
import six
|
import six
|
||||||
|
@ -304,7 +304,7 @@ class singleWorker(StoppableThread):
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
'broadcasting inv with hash: %s', hexlify(inventoryHash))
|
'broadcasting inv with hash: %s', hexlify(inventoryHash))
|
||||||
|
|
||||||
queues.invQueue.put((streamNumber, inventoryHash))
|
invQueue.put((streamNumber, inventoryHash))
|
||||||
queues.UISignalQueue.put(('updateStatusBar', ''))
|
queues.UISignalQueue.put(('updateStatusBar', ''))
|
||||||
try:
|
try:
|
||||||
config.set(
|
config.set(
|
||||||
|
@ -393,7 +393,7 @@ class singleWorker(StoppableThread):
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
'broadcasting inv with hash: %s', hexlify(inventoryHash))
|
'broadcasting inv with hash: %s', hexlify(inventoryHash))
|
||||||
|
|
||||||
queues.invQueue.put((streamNumber, inventoryHash))
|
invQueue.put((streamNumber, inventoryHash))
|
||||||
queues.UISignalQueue.put(('updateStatusBar', ''))
|
queues.UISignalQueue.put(('updateStatusBar', ''))
|
||||||
try:
|
try:
|
||||||
config.set(
|
config.set(
|
||||||
|
@ -487,7 +487,7 @@ class singleWorker(StoppableThread):
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
'broadcasting inv with hash: %s', hexlify(inventoryHash))
|
'broadcasting inv with hash: %s', hexlify(inventoryHash))
|
||||||
|
|
||||||
queues.invQueue.put((streamNumber, inventoryHash))
|
invQueue.put((streamNumber, inventoryHash))
|
||||||
queues.UISignalQueue.put(('updateStatusBar', ''))
|
queues.UISignalQueue.put(('updateStatusBar', ''))
|
||||||
try:
|
try:
|
||||||
config.set(
|
config.set(
|
||||||
|
@ -541,7 +541,7 @@ class singleWorker(StoppableThread):
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
'sending inv (within sendOnionPeerObj function) for object: %s',
|
'sending inv (within sendOnionPeerObj function) for object: %s',
|
||||||
hexlify(inventoryHash))
|
hexlify(inventoryHash))
|
||||||
queues.invQueue.put((streamNumber, inventoryHash))
|
invQueue.put((streamNumber, inventoryHash))
|
||||||
|
|
||||||
def sendBroadcast(self):
|
def sendBroadcast(self):
|
||||||
"""
|
"""
|
||||||
|
@ -720,7 +720,7 @@ class singleWorker(StoppableThread):
|
||||||
' for object: %s',
|
' for object: %s',
|
||||||
hexlify(inventoryHash)
|
hexlify(inventoryHash)
|
||||||
)
|
)
|
||||||
queues.invQueue.put((streamNumber, inventoryHash))
|
invQueue.put((streamNumber, inventoryHash))
|
||||||
|
|
||||||
queues.UISignalQueue.put((
|
queues.UISignalQueue.put((
|
||||||
'updateSentItemStatusByAckdata', (
|
'updateSentItemStatusByAckdata', (
|
||||||
|
@ -1356,7 +1356,7 @@ class singleWorker(StoppableThread):
|
||||||
'Broadcasting inv for my msg(within sendmsg function): %s',
|
'Broadcasting inv for my msg(within sendmsg function): %s',
|
||||||
hexlify(inventoryHash)
|
hexlify(inventoryHash)
|
||||||
)
|
)
|
||||||
queues.invQueue.put((toStreamNumber, inventoryHash))
|
invQueue.put((toStreamNumber, inventoryHash))
|
||||||
|
|
||||||
# Update the sent message in the sent table with the
|
# Update the sent message in the sent table with the
|
||||||
# necessary information.
|
# necessary information.
|
||||||
|
@ -1496,7 +1496,7 @@ class singleWorker(StoppableThread):
|
||||||
state.Inventory[inventoryHash] = (
|
state.Inventory[inventoryHash] = (
|
||||||
objectType, streamNumber, payload, embeddedTime, '')
|
objectType, streamNumber, payload, embeddedTime, '')
|
||||||
self.logger.info('sending inv (for the getpubkey message)')
|
self.logger.info('sending inv (for the getpubkey message)')
|
||||||
queues.invQueue.put((streamNumber, inventoryHash))
|
invQueue.put((streamNumber, inventoryHash))
|
||||||
|
|
||||||
# wait 10% past expiration
|
# wait 10% past expiration
|
||||||
sleeptill = int(time.time() + TTL * 1.1)
|
sleeptill = int(time.time() + TTL * 1.1)
|
||||||
|
|
|
@ -11,11 +11,17 @@ import hashlib
|
||||||
import os
|
import os
|
||||||
from binascii import hexlify
|
from binascii import hexlify
|
||||||
|
|
||||||
import pyelliptic
|
try:
|
||||||
from pyelliptic import OpenSSL
|
import pyelliptic
|
||||||
from pyelliptic import arithmetic as a
|
from fallback import RIPEMD160Hash
|
||||||
|
from pyelliptic import OpenSSL
|
||||||
|
from pyelliptic import arithmetic as a
|
||||||
|
except ImportError:
|
||||||
|
from pybitmessage import pyelliptic
|
||||||
|
from pybitmessage.fallback import RIPEMD160Hash
|
||||||
|
from pybitmessage.pyelliptic import OpenSSL
|
||||||
|
from pybitmessage.pyelliptic import arithmetic as a
|
||||||
|
|
||||||
from fallback import RIPEMD160Hash
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'decodeWalletImportFormat', 'deterministic_keys',
|
'decodeWalletImportFormat', 'deterministic_keys',
|
||||||
|
|
13
src/main-android-live.py
Normal file
13
src/main-android-live.py
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
"""This module is for thread start."""
|
||||||
|
import state
|
||||||
|
import sys
|
||||||
|
from bitmessagemain import main
|
||||||
|
from termcolor import colored
|
||||||
|
print(colored('kivy is not supported at the moment for this version..', 'red'))
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
state.kivy = True
|
||||||
|
print("Kivy Loading......")
|
||||||
|
main()
|
36
src/main.py
36
src/main.py
|
@ -1,13 +1,31 @@
|
||||||
"""This module is for thread start."""
|
# pylint: disable=unused-import, wrong-import-position, ungrouped-imports
|
||||||
|
# flake8: noqa:E401, E402
|
||||||
|
|
||||||
|
"""Mock kivy app with mock threads."""
|
||||||
|
|
||||||
|
import os
|
||||||
|
from kivy.config import Config
|
||||||
|
from mockbm import multiqueue
|
||||||
import state
|
import state
|
||||||
import sys
|
|
||||||
from bitmessagemain import main
|
from mockbm.class_addressGenerator import FakeAddressGenerator # noqa:E402
|
||||||
from termcolor import colored
|
from bitmessagekivy.mpybit import NavigateApp # noqa:E402
|
||||||
print(colored('kivy is not supported at the moment for this version..', 'red'))
|
from mockbm import network # noqa:E402
|
||||||
sys.exit()
|
|
||||||
|
stats = network.stats
|
||||||
|
objectracker = network.objectracker
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def main():
|
||||||
state.kivy = True
|
"""main method for starting threads"""
|
||||||
print("Kivy Loading......")
|
addressGeneratorThread = FakeAddressGenerator()
|
||||||
|
addressGeneratorThread.daemon = True
|
||||||
|
addressGeneratorThread.start()
|
||||||
|
state.kivyapp = NavigateApp()
|
||||||
|
state.kivyapp.run()
|
||||||
|
addressGeneratorThread.stopThread()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
os.environ['INSTALL_TESTS'] = "True"
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -1,17 +1,24 @@
|
||||||
"""
|
"""
|
||||||
Network subsystem package
|
Network subsystem package
|
||||||
"""
|
"""
|
||||||
|
from six.moves import queue
|
||||||
from .dandelion import Dandelion
|
from .dandelion import Dandelion
|
||||||
from .threads import StoppableThread
|
from .threads import StoppableThread
|
||||||
|
from .multiqueue import MultiQueue
|
||||||
|
|
||||||
dandelion_ins = Dandelion()
|
dandelion_ins = Dandelion()
|
||||||
|
|
||||||
|
# network queues
|
||||||
|
invQueue = MultiQueue()
|
||||||
|
addrQueue = MultiQueue()
|
||||||
|
portCheckerQueue = queue.Queue()
|
||||||
|
receiveDataQueue = queue.Queue()
|
||||||
|
|
||||||
__all__ = ["StoppableThread"]
|
__all__ = ["StoppableThread"]
|
||||||
|
|
||||||
|
|
||||||
def start(config, state):
|
def start(config, state):
|
||||||
"""Start network threads"""
|
"""Start network threads"""
|
||||||
import state
|
|
||||||
from .announcethread import AnnounceThread
|
from .announcethread import AnnounceThread
|
||||||
from network import connectionpool
|
from network import connectionpool
|
||||||
from .addrthread import AddrThread
|
from .addrthread import AddrThread
|
||||||
|
|
|
@ -7,7 +7,7 @@ from six.moves import queue
|
||||||
# magic imports!
|
# magic imports!
|
||||||
from network import connectionpool
|
from network import connectionpool
|
||||||
from protocol import assembleAddrMessage
|
from protocol import assembleAddrMessage
|
||||||
from queues import addrQueue # FIXME: init with queue
|
from network import addrQueue # FIXME: init with queue
|
||||||
|
|
||||||
from .threads import StoppableThread
|
from .threads import StoppableThread
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import protocol
|
||||||
import state
|
import state
|
||||||
import network.connectionpool # use long name to address recursive import
|
import network.connectionpool # use long name to address recursive import
|
||||||
from bmconfigparser import config
|
from bmconfigparser import config
|
||||||
from queues import invQueue, objectProcessorQueue, portCheckerQueue
|
from queues import objectProcessorQueue
|
||||||
from randomtrackingdict import RandomTrackingDict
|
from randomtrackingdict import RandomTrackingDict
|
||||||
from network.advanceddispatcher import AdvancedDispatcher
|
from network.advanceddispatcher import AdvancedDispatcher
|
||||||
from network.bmobject import (
|
from network.bmobject import (
|
||||||
|
@ -28,7 +28,7 @@ from network.bmobject import (
|
||||||
)
|
)
|
||||||
from network.proxy import ProxyError
|
from network.proxy import ProxyError
|
||||||
|
|
||||||
from network import dandelion_ins
|
from network import dandelion_ins, invQueue, portCheckerQueue
|
||||||
from .node import Node, Peer
|
from .node import Node, Peer
|
||||||
from .objectracker import ObjectTracker, missingObjects
|
from .objectracker import ObjectTracker, missingObjects
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,14 @@ Select which node to connect to
|
||||||
import logging
|
import logging
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
from six.moves import queue
|
||||||
|
|
||||||
from network import knownnodes
|
from network import knownnodes
|
||||||
import protocol
|
import protocol
|
||||||
import state
|
import state
|
||||||
|
|
||||||
from bmconfigparser import config
|
from bmconfigparser import config
|
||||||
from queues import queue, portCheckerQueue
|
from network import portCheckerQueue
|
||||||
|
|
||||||
logger = logging.getLogger('default')
|
logger = logging.getLogger('default')
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,7 @@ import addresses
|
||||||
import protocol
|
import protocol
|
||||||
import state
|
import state
|
||||||
from network import connectionpool
|
from network import connectionpool
|
||||||
from network import dandelion_ins
|
from network import dandelion_ins, invQueue
|
||||||
from queues import invQueue
|
|
||||||
from .threads import StoppableThread
|
from .threads import StoppableThread
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,11 @@
|
||||||
A queue with multiple internal subqueues.
|
A queue with multiple internal subqueues.
|
||||||
Elements are added into a random subqueue, and retrieval rotates
|
Elements are added into a random subqueue, and retrieval rotates
|
||||||
"""
|
"""
|
||||||
|
import random
|
||||||
from collections import deque
|
from collections import deque
|
||||||
|
|
||||||
from six.moves import queue
|
from six.moves import queue
|
||||||
|
|
||||||
try:
|
|
||||||
import helper_random
|
|
||||||
except ImportError:
|
|
||||||
from . import helper_random
|
|
||||||
|
|
||||||
|
|
||||||
class MultiQueue(queue.Queue):
|
class MultiQueue(queue.Queue):
|
||||||
"""A base queue class"""
|
"""A base queue class"""
|
||||||
|
@ -38,7 +33,7 @@ class MultiQueue(queue.Queue):
|
||||||
# Put a new item in the queue
|
# Put a new item in the queue
|
||||||
def _put(self, item):
|
def _put(self, item):
|
||||||
# self.queue.append(item)
|
# self.queue.append(item)
|
||||||
self.queues[helper_random.randomrandrange(self.queueCount)].append(
|
self.queues[random.randrange(self.queueCount)].append( # nosec B311
|
||||||
(item))
|
(item))
|
||||||
|
|
||||||
# Get an item from the queue
|
# Get an item from the queue
|
|
@ -7,7 +7,7 @@ import socket
|
||||||
|
|
||||||
from network import connectionpool
|
from network import connectionpool
|
||||||
from network.advanceddispatcher import UnknownStateError
|
from network.advanceddispatcher import UnknownStateError
|
||||||
from queues import receiveDataQueue
|
from network import receiveDataQueue
|
||||||
from .threads import StoppableThread
|
from .threads import StoppableThread
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@ import state
|
||||||
import network.connectionpool # use long name to address recursive import
|
import network.connectionpool # use long name to address recursive import
|
||||||
from bmconfigparser import config
|
from bmconfigparser import config
|
||||||
from highlevelcrypto import randomBytes
|
from highlevelcrypto import randomBytes
|
||||||
from network import dandelion_ins
|
from network import dandelion_ins, invQueue, receiveDataQueue
|
||||||
from queues import invQueue, receiveDataQueue, UISignalQueue
|
from queues import UISignalQueue
|
||||||
from tr import _translate
|
from tr import _translate
|
||||||
|
|
||||||
from network import asyncore_pollchoose as asyncore
|
from network import asyncore_pollchoose as asyncore
|
||||||
|
|
|
@ -11,7 +11,7 @@ import six
|
||||||
import network.asyncore_pollchoose as asyncore
|
import network.asyncore_pollchoose as asyncore
|
||||||
import paths
|
import paths
|
||||||
from network.advanceddispatcher import AdvancedDispatcher
|
from network.advanceddispatcher import AdvancedDispatcher
|
||||||
from queues import receiveDataQueue
|
from network import receiveDataQueue
|
||||||
|
|
||||||
logger = logging.getLogger('default')
|
logger = logging.getLogger('default')
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@ import time
|
||||||
import protocol
|
import protocol
|
||||||
import state
|
import state
|
||||||
import network.connectionpool # use long name to address recursive import
|
import network.connectionpool # use long name to address recursive import
|
||||||
from queues import receiveDataQueue
|
|
||||||
|
|
||||||
|
from network import receiveDataQueue
|
||||||
from .bmproto import BMProto
|
from .bmproto import BMProto
|
||||||
from .node import Peer
|
from .node import Peer
|
||||||
from .objectracker import ObjectTracker
|
from .objectracker import ObjectTracker
|
||||||
|
|
|
@ -806,6 +806,10 @@ def loadOpenSSL():
|
||||||
'libcrypto.dylib', '/usr/local/opt/openssl/lib/libcrypto.dylib'])
|
'libcrypto.dylib', '/usr/local/opt/openssl/lib/libcrypto.dylib'])
|
||||||
elif 'win32' in sys.platform or 'win64' in sys.platform:
|
elif 'win32' in sys.platform or 'win64' in sys.platform:
|
||||||
libdir.append('libeay32.dll')
|
libdir.append('libeay32.dll')
|
||||||
|
# kivy
|
||||||
|
elif 'ANDROID_ARGUMENT' in environ:
|
||||||
|
libdir.append('libcrypto1.1.so')
|
||||||
|
libdir.append('libssl1.1.so')
|
||||||
else:
|
else:
|
||||||
libdir.append('libcrypto.so')
|
libdir.append('libcrypto.so')
|
||||||
libdir.append('libssl.so')
|
libdir.append('libssl.so')
|
||||||
|
|
|
@ -5,11 +5,6 @@ import time
|
||||||
|
|
||||||
from six.moves import queue
|
from six.moves import queue
|
||||||
|
|
||||||
try:
|
|
||||||
from multiqueue import MultiQueue
|
|
||||||
except ImportError:
|
|
||||||
from .multiqueue import MultiQueue
|
|
||||||
|
|
||||||
|
|
||||||
class ObjectProcessorQueue(queue.Queue):
|
class ObjectProcessorQueue(queue.Queue):
|
||||||
"""Special queue class using lock for `.threads.objectProcessor`"""
|
"""Special queue class using lock for `.threads.objectProcessor`"""
|
||||||
|
@ -44,10 +39,6 @@ addressGeneratorQueue = queue.Queue()
|
||||||
#: `.network.ReceiveQueueThread` instances dump objects they hear
|
#: `.network.ReceiveQueueThread` instances dump objects they hear
|
||||||
#: on the network into this queue to be processed.
|
#: on the network into this queue to be processed.
|
||||||
objectProcessorQueue = ObjectProcessorQueue()
|
objectProcessorQueue = ObjectProcessorQueue()
|
||||||
invQueue = MultiQueue()
|
|
||||||
addrQueue = MultiQueue()
|
|
||||||
portCheckerQueue = queue.Queue()
|
|
||||||
receiveDataQueue = queue.Queue()
|
|
||||||
#: The address generator thread uses this queue to get information back
|
#: The address generator thread uses this queue to get information back
|
||||||
#: to the API thread.
|
#: to the API thread.
|
||||||
apiAddressGeneratorReturnQueue = queue.Queue()
|
apiAddressGeneratorReturnQueue = queue.Queue()
|
||||||
|
|
|
@ -38,7 +38,7 @@ class TestFilesystemInventory(TestPartialRun):
|
||||||
embedded_time = int(time.time() + TTL)
|
embedded_time = int(time.time() + TTL)
|
||||||
msg = struct.pack('>Q', embedded_time) + os.urandom(166)
|
msg = struct.pack('>Q', embedded_time) + os.urandom(166)
|
||||||
invhash = highlevelcrypto.calculateInventoryHash(msg)
|
invhash = highlevelcrypto.calculateInventoryHash(msg)
|
||||||
self.inventory[invhash] = (2, 1, msg, embedded_time, b'')
|
self.inventory[bytes(invhash)] = (2, 1, msg, embedded_time, b'')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""Test cases for multiqueue"""
|
"""Test cases for multiqueue"""
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
from pybitmessage.multiqueue import MultiQueue
|
from pybitmessage.network.multiqueue import MultiQueue
|
||||||
|
|
||||||
|
|
||||||
class TestMultiQueue(unittest.TestCase):
|
class TestMultiQueue(unittest.TestCase):
|
||||||
|
|
|
@ -63,6 +63,8 @@ class TestProtocol(TestSocketInet):
|
||||||
|
|
||||||
def test_check_local(self):
|
def test_check_local(self):
|
||||||
"""Check the logic of TCPConnection.local"""
|
"""Check the logic of TCPConnection.local"""
|
||||||
|
self.assertFalse(
|
||||||
|
protocol.checkIPAddress(protocol.encodeHost('127.0.0.1')))
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
protocol.checkIPAddress(protocol.encodeHost('127.0.0.1'), True))
|
protocol.checkIPAddress(protocol.encodeHost('127.0.0.1'), True))
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
|
|
Reference in New Issue
Block a user