Merge branch 'v0.6' into v0.6
commit
e0efb7fd2f
@ -0,0 +1,49 @@
|
||||
# A container for PyBitmessage daemon
|
||||
|
||||
FROM ubuntu:xenial
|
||||
|
||||
RUN apt-get update
|
||||
|
||||
# Install dependencies
|
||||
RUN apt-get install -yq --no-install-suggests --no-install-recommends \
|
||||
python-msgpack dh-python python-all-dev build-essential libssl-dev \
|
||||
python-stdeb fakeroot python-pip libcap-dev
|
||||
|
||||
RUN pip install --upgrade pip
|
||||
|
||||
EXPOSE 8444 8442
|
||||
|
||||
ENV HOME /home/bitmessage
|
||||
ENV BITMESSAGE_HOME ${HOME}
|
||||
|
||||
ENV VER 0.6.3.2
|
||||
|
||||
WORKDIR ${HOME}
|
||||
ADD . ${HOME}
|
||||
|
||||
# Install tests dependencies
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
# Build and install deb
|
||||
RUN python2 setup.py sdist \
|
||||
&& py2dsc-deb dist/pybitmessage-${VER}.tar.gz \
|
||||
&& dpkg -i deb_dist/python-pybitmessage_${VER}-1_amd64.deb
|
||||
|
||||
# Create a user
|
||||
RUN useradd bitmessage && chown -R bitmessage ${HOME}
|
||||
|
||||
USER bitmessage
|
||||
|
||||
# Generate default config
|
||||
RUN src/bitmessagemain.py -t && mv keys.dat /tmp
|
||||
|
||||
# Clean HOME
|
||||
RUN rm -rf ${HOME}/*
|
||||
|
||||
# Setup environment
|
||||
RUN mv /tmp/keys.dat . \
|
||||
&& APIPASS=$(tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo) \
|
||||
&& echo "\napiusername: api\napipassword: $APIPASS" \
|
||||
&& echo "apienabled = true\napiinterface = 0.0.0.0\napiusername = api\napipassword = $APIPASS" >> keys.dat
|
||||
|
||||
CMD ["pybitmessage", "-d"]
|
@ -1,3 +1,4 @@
|
||||
include COPYING
|
||||
include README.md
|
||||
include requirements.txt
|
||||
recursive-include desktop *
|
||||
|
@ -1,109 +0,0 @@
|
||||
"""
|
||||
Helper Generic perform generic operations for threading.
|
||||
|
||||
Also perform some conversion operations.
|
||||
"""
|
||||
|
||||
|
||||
import socket
|
||||
import sys
|
||||
import threading
|
||||
import traceback
|
||||
import multiprocessing
|
||||
from binascii import hexlify, unhexlify
|
||||
|
||||
import shared
|
||||
import state
|
||||
import queues
|
||||
import shutdown
|
||||
from debug import logger
|
||||
|
||||
|
||||
def powQueueSize():
|
||||
curWorkerQueue = queues.workerQueue.qsize()
|
||||
for thread in threading.enumerate():
|
||||
try:
|
||||
if thread.name == "singleWorker":
|
||||
curWorkerQueue += thread.busy
|
||||
except Exception as err:
|
||||
logger.info('Thread error %s', err)
|
||||
return curWorkerQueue
|
||||
|
||||
|
||||
def convertIntToString(n):
|
||||
a = __builtins__.hex(n)
|
||||
if a[-1:] == 'L':
|
||||
a = a[:-1]
|
||||
if (len(a) % 2) == 0:
|
||||
return unhexlify(a[2:])
|
||||
else:
|
||||
return unhexlify('0' + a[2:])
|
||||
|
||||
|
||||
def convertStringToInt(s):
|
||||
return int(hexlify(s), 16)
|
||||
|
||||
|
||||
def allThreadTraceback(frame):
|
||||
id2name = dict([(th.ident, th.name) for th in threading.enumerate()])
|
||||
code = []
|
||||
for threadId, stack in sys._current_frames().items():
|
||||
code.append(
|
||||
'\n# Thread: %s(%d)' % (id2name.get(threadId, ''), threadId))
|
||||
for filename, lineno, name, line in traceback.extract_stack(stack):
|
||||
code.append(
|
||||
'File: "%s", line %d, in %s' % (filename, lineno, name))
|
||||
if line:
|
||||
code.append(' %s' % (line.strip()))
|
||||
print('\n'.join(code))
|
||||
|
||||
|
||||
def signal_handler(signal, frame):
|
||||
process = multiprocessing.current_process()
|
||||
logger.error(
|
||||
'Got signal %i in %s/%s',
|
||||
signal, process.name, threading.current_thread().name
|
||||
)
|
||||
if process.name == "RegExParser":
|
||||
# on Windows this isn't triggered, but it's fine,
|
||||
# it has its own process termination thing
|
||||
raise SystemExit
|
||||
if "PoolWorker" in process.name:
|
||||
raise SystemExit
|
||||
if threading.current_thread().name not in ("PyBitmessage", "MainThread"):
|
||||
return
|
||||
logger.error("Got signal %i", signal)
|
||||
if shared.thisapp.daemon or not state.enableGUI: # FIXME redundant?
|
||||
shutdown.doCleanShutdown()
|
||||
else:
|
||||
allThreadTraceback(frame)
|
||||
print('Unfortunately you cannot use Ctrl+C when running the UI'
|
||||
' because the UI captures the signal.')
|
||||
|
||||
|
||||
def isHostInPrivateIPRange(host):
|
||||
if ":" in host: # IPv6
|
||||
hostAddr = socket.inet_pton(socket.AF_INET6, host)
|
||||
if hostAddr == ('\x00' * 15) + '\x01':
|
||||
return False
|
||||
if hostAddr[0] == '\xFE' and (ord(hostAddr[1]) & 0xc0) == 0x80:
|
||||
return False
|
||||
if (ord(hostAddr[0]) & 0xfe) == 0xfc:
|
||||
return False
|
||||
elif ".onion" not in host:
|
||||
if host[:3] == '10.':
|
||||
return True
|
||||
if host[:4] == '172.':
|
||||
if host[6] == '.':
|
||||
if int(host[4:6]) >= 16 and int(host[4:6]) <= 31:
|
||||
return True
|
||||
if host[:8] == '192.168.':
|
||||
return True
|
||||
# Multicast
|
||||
if host[:3] >= 224 and host[:3] <= 239 and host[4] == '.':
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def addDataPadding(data, desiredMsgLength=12, paddingChar='\x00'):
|
||||
return data + paddingChar * (desiredMsgLength - len(data))
|
Loading…
Reference in New Issue