work on net controller

master
Kevin Froman 2018-01-19 03:16:38 -06:00
parent 388752c079
commit 9d91e77ec5
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
4 changed files with 26 additions and 7 deletions

View File

@ -3,6 +3,6 @@ python:
- "3.6.4" - "3.6.4"
# install dependencies # install dependencies
install: install:
- sudo apt install gnupg - sudo apt install gnupg tor
- pip install -r requirements.txt - pip install -r requirements.txt
script: ./test.sh script: ./test.sh

View File

@ -20,7 +20,7 @@
import sqlite3, os, time, math, gnupg, base64, tarfile, getpass, simplecrypt import sqlite3, os, time, math, gnupg, base64, tarfile, getpass, simplecrypt
from Crypto.Cipher import AES from Crypto.Cipher import AES
from Crypto import Random from Crypto import Random
import netcontroller
class Core: class Core:
def __init__(self): def __init__(self):

View File

@ -17,21 +17,35 @@
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 import subprocess, os
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
''' '''
def __init__(self, hsPort, socksPort): def __init__(self, hsPort):
self.torConfigLocation = 'data/torrc' self.torConfigLocation = 'data/torrc'
self.readyState = False self.readyState = False
self.socksPort = socksPort
self.hsPort = hsPort
if os.path.exists(self.torConfigLocation):
torrc = open(self.torConfigLocation, 'r')
if not self.hsPort in torrc.read():
os.remove(self.torConfigLocation)
return return
def generateTorrc(self): def generateTorrc(self):
torrcData = '''SOCKSPORT if os.path.exists(self.torConfigLocation):
os.remove(self.torConfigLocation)
torrcData = '''SOCKSPORT ''' + self.socksPort + '''
HiddenServiceData data/hs/
HiddenServicePort 80 127.0.0.1:''' + self.hsPort + '''
''' '''
torrc = open(self.torConfigLocation, 'w')
torrc.write(torrcData)
torrc.close()
return return
def startTor(self): def startTor(self):
if not os.path.exists(self.torConfigLocation):
self.generateTorrc()
subprocess.Popen(['tor', '-f ' + self.torConfigLocation]) subprocess.Popen(['tor', '-f ' + self.torConfigLocation])
return return

View File

@ -24,6 +24,7 @@ import sys, os, configparser, base64, random, getpass, shutil, subprocess, reque
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
from netcontroller import NetController
class Onionr: class Onionr:
def __init__(self): def __init__(self):
@ -118,6 +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'])
print('Tor is starting...')
net.startTor(self.config['CLIENT']['PORT'])
time.sleep(5)
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)