diff --git a/Dockerfile b/Dockerfile index 90f16342..c83de87d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ -FROM ubuntu:xenial +FROM ubuntu:bionic #Base settings ENV HOME /root #Install needed packages -RUN apt update && apt install -y python3 python3-dev python3-pip tor locales +RUN apt update && apt install -y python3 python3-dev python3-pip tor locales nano RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \ locale-gen diff --git a/onionr/communicator2.py b/onionr/communicator2.py index 42be9e45..38ba2692 100755 --- a/onionr/communicator2.py +++ b/onionr/communicator2.py @@ -318,6 +318,8 @@ class OnionrCommunicatorDaemon: self.addBootstrapListToPeerList(peerList) for address in peerList: + if not config.get('tor.v3onions') and len(address) == 62: + continue if len(address) == 0 or address in tried or address in self.onlinePeers: continue if self.shutdown: diff --git a/onionr/netcontroller.py b/onionr/netcontroller.py index 19f355e4..3749ce7a 100644 --- a/onionr/netcontroller.py +++ b/onionr/netcontroller.py @@ -18,7 +18,7 @@ along with this program. If not, see . ''' -import subprocess, os, random, sys, logger, time, signal +import subprocess, os, random, sys, logger, time, signal, config from onionrblockapi import Block class NetController: @@ -33,6 +33,7 @@ class NetController: self.hsPort = hsPort self._torInstnace = '' self.myID = '' + config.reload() ''' if os.path.exists(self.torConfigLocation): torrc = open(self.torConfigLocation, 'r') @@ -47,11 +48,15 @@ class NetController: ''' Generate a torrc file for our tor instance ''' - + hsVer = '# v2 onions' + if config.get('tor.v3onions'): + hsVer = 'HiddenServiceVersion 3' + logger.info('Using v3 onions :)') if os.path.exists(self.torConfigLocation): os.remove(self.torConfigLocation) torrcData = '''SocksPort ''' + str(self.socksPort) + ''' HiddenServiceDir data/hs/ +\n''' + hsVer + '''\n HiddenServicePort 80 127.0.0.1:''' + str(self.hsPort) + ''' DataDirectory data/tordata/ ''' diff --git a/onionr/onionrcrypto.py b/onionr/onionrcrypto.py index 40dca90f..00c5a604 100644 --- a/onionr/onionrcrypto.py +++ b/onionr/onionrcrypto.py @@ -247,6 +247,10 @@ class OnionrCrypto: return result def sha3Hash(self, data): + try: + data = data.encode() + except AttributeError: + pass hasher = hashlib.sha3_256() hasher.update(data) return hasher.hexdigest() diff --git a/onionr/onionrutils.py b/onionr/onionrutils.py index 7e0abd94..951f546a 100644 --- a/onionr/onionrutils.py +++ b/onionr/onionrutils.py @@ -43,7 +43,7 @@ class OnionrUtils: self.avoidDupe = [] # list used to prevent duplicate requests per peer for certain actions self.peerProcessing = {} # dict of current peer actions: peer, actionList - + config.reload() return def getTimeBypassToken(self): @@ -128,6 +128,8 @@ class OnionrUtils: for adder in newAdderList.split(','): adder = adder.strip() if not adder in self._core.listAdders(randomOrder = False) and adder != self.getMyAddress() and not self._core._blacklist.inBlacklist(adder): + if not config.get('tor.v3onions') and len(address) == 62: + continue if self._core.addAddress(adder): logger.info('Added %s to db.' % adder, timestamp = True) retVal = True diff --git a/onionr/static-data/default_config.json b/onionr/static-data/default_config.json index fcbf733e..5458db4a 100644 --- a/onionr/static-data/default_config.json +++ b/onionr/static-data/default_config.json @@ -41,7 +41,7 @@ }, "tor" : { - + "v3onions": false }, "i2p":{