work on net controller
parent
388752c079
commit
9d91e77ec5
|
@ -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
|
||||||
|
|
|
@ -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):
|
||||||
|
@ -155,4 +155,4 @@ class Core:
|
||||||
generate and return an HMAC key
|
generate and return an HMAC key
|
||||||
'''
|
'''
|
||||||
key = base64.b64encode(os.urandom(32))
|
key = base64.b64encode(os.urandom(32))
|
||||||
return key
|
return key
|
|
@ -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
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue