netcontroller now gets the tor hs id
parent
9d91e77ec5
commit
d2d60fe6ce
|
@ -17,7 +17,7 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
'''
|
'''
|
||||||
import subprocess, os
|
import subprocess, os, random, sys
|
||||||
class NetController:
|
class NetController:
|
||||||
'''NetController
|
'''NetController
|
||||||
This class handles hidden service setup on Tor and I2P
|
This class handles hidden service setup on Tor and I2P
|
||||||
|
@ -25,8 +25,9 @@ class NetController:
|
||||||
def __init__(self, hsPort):
|
def __init__(self, hsPort):
|
||||||
self.torConfigLocation = 'data/torrc'
|
self.torConfigLocation = 'data/torrc'
|
||||||
self.readyState = False
|
self.readyState = False
|
||||||
self.socksPort = socksPort
|
self.socksPort = random.randint(1024, 65535)
|
||||||
self.hsPort = hsPort
|
self.hsPort = hsPort
|
||||||
|
self.myID = ''
|
||||||
if os.path.exists(self.torConfigLocation):
|
if os.path.exists(self.torConfigLocation):
|
||||||
torrc = open(self.torConfigLocation, 'r')
|
torrc = open(self.torConfigLocation, 'r')
|
||||||
if not self.hsPort in torrc.read():
|
if not self.hsPort in torrc.read():
|
||||||
|
@ -35,9 +36,9 @@ class NetController:
|
||||||
def generateTorrc(self):
|
def generateTorrc(self):
|
||||||
if os.path.exists(self.torConfigLocation):
|
if os.path.exists(self.torConfigLocation):
|
||||||
os.remove(self.torConfigLocation)
|
os.remove(self.torConfigLocation)
|
||||||
torrcData = '''SOCKSPORT ''' + self.socksPort + '''
|
torrcData = '''SOCKSPORT ''' + str(self.socksPort) + '''
|
||||||
HiddenServiceData data/hs/
|
HiddenServiceDir data/hs/
|
||||||
HiddenServicePort 80 127.0.0.1:''' + self.hsPort + '''
|
HiddenServicePort 80 127.0.0.1:''' + str(self.hsPort) + '''
|
||||||
'''
|
'''
|
||||||
torrc = open(self.torConfigLocation, 'w')
|
torrc = open(self.torConfigLocation, 'w')
|
||||||
torrc.write(torrcData)
|
torrc.write(torrcData)
|
||||||
|
@ -45,7 +46,14 @@ HiddenServicePort 80 127.0.0.1:''' + self.hsPort + '''
|
||||||
return
|
return
|
||||||
|
|
||||||
def startTor(self):
|
def startTor(self):
|
||||||
if not os.path.exists(self.torConfigLocation):
|
self.generateTorrc()
|
||||||
self.generateTorrc()
|
tor = subprocess.Popen(['tor', '-f', self.torConfigLocation], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
subprocess.Popen(['tor', '-f ' + self.torConfigLocation])
|
for line in iter(tor.stdout.readline, b''):
|
||||||
|
if 'Bootstrapped 100%: Done' in line.decode():
|
||||||
|
break
|
||||||
|
print('Finished starting Tor')
|
||||||
|
self.readyState = True
|
||||||
|
myID = open('data/hs/hostname', 'r')
|
||||||
|
self.myID = myID.read()
|
||||||
|
myID.close()
|
||||||
return
|
return
|
|
@ -20,7 +20,7 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
'''
|
'''
|
||||||
import sys, os, configparser, base64, random, getpass, shutil, subprocess, requests
|
import sys, os, configparser, base64, random, getpass, shutil, subprocess, requests, time
|
||||||
import gui, api, colors, core
|
import gui, api, colors, core
|
||||||
from onionrutils import OnionrUtils
|
from onionrutils import OnionrUtils
|
||||||
from colors import Colors
|
from colors import Colors
|
||||||
|
@ -119,10 +119,10 @@ class Onionr:
|
||||||
''' Start the Onionr communication daemon
|
''' Start the Onionr communication daemon
|
||||||
'''
|
'''
|
||||||
if not os.environ.get("WERKZEUG_RUN_MAIN") == "true":
|
if not os.environ.get("WERKZEUG_RUN_MAIN") == "true":
|
||||||
net = NetController(self.config['PORT'])
|
net = NetController(self.config['CLIENT']['PORT'])
|
||||||
print('Tor is starting...')
|
print('Tor is starting...')
|
||||||
net.startTor(self.config['CLIENT']['PORT'])
|
net.startTor()
|
||||||
time.sleep(5)
|
time.sleep(1)
|
||||||
subprocess.Popen(["./communicator.py", "run"])
|
subprocess.Popen(["./communicator.py", "run"])
|
||||||
print('Started communicator')
|
print('Started communicator')
|
||||||
api.API(self.config, self.debug)
|
api.API(self.config, self.debug)
|
||||||
|
|
Loading…
Reference in New Issue