work on net controller
This commit is contained in:
		
							parent
							
								
									388752c079
								
							
						
					
					
						commit
						9d91e77ec5
					
				
					 4 changed files with 26 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -3,6 +3,6 @@ python:
 | 
			
		|||
        - "3.6.4"
 | 
			
		||||
# install dependencies
 | 
			
		||||
install:
 | 
			
		||||
        - sudo apt install gnupg
 | 
			
		||||
        - sudo apt install gnupg tor
 | 
			
		||||
        - pip install -r requirements.txt
 | 
			
		||||
script: ./test.sh
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,7 +20,7 @@
 | 
			
		|||
import sqlite3, os, time, math, gnupg, base64, tarfile, getpass, simplecrypt
 | 
			
		||||
from Crypto.Cipher import AES
 | 
			
		||||
from Crypto import Random
 | 
			
		||||
 | 
			
		||||
import netcontroller
 | 
			
		||||
 | 
			
		||||
class Core:
 | 
			
		||||
    def __init__(self):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,21 +17,35 @@
 | 
			
		|||
    You should have received a copy of the GNU General Public License
 | 
			
		||||
    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 | 
			
		||||
'''
 | 
			
		||||
import subprocess
 | 
			
		||||
import subprocess, os
 | 
			
		||||
class NetController:
 | 
			
		||||
    '''NetController
 | 
			
		||||
    This class handles hidden service setup on Tor and I2P
 | 
			
		||||
    '''
 | 
			
		||||
    def __init__(self, hsPort, socksPort):
 | 
			
		||||
    def __init__(self, hsPort):
 | 
			
		||||
        self.torConfigLocation = 'data/torrc'
 | 
			
		||||
        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
 | 
			
		||||
    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
 | 
			
		||||
 | 
			
		||||
    def startTor(self):
 | 
			
		||||
        if not os.path.exists(self.torConfigLocation):
 | 
			
		||||
            self.generateTorrc()
 | 
			
		||||
        subprocess.Popen(['tor', '-f ' + self.torConfigLocation])
 | 
			
		||||
        return
 | 
			
		||||
| 
						 | 
				
			
			@ -24,6 +24,7 @@ import sys, os, configparser, base64, random, getpass, shutil, subprocess, reque
 | 
			
		|||
import gui, api, colors, core
 | 
			
		||||
from onionrutils import OnionrUtils
 | 
			
		||||
from colors import Colors
 | 
			
		||||
from netcontroller import NetController
 | 
			
		||||
 | 
			
		||||
class Onionr:
 | 
			
		||||
    def __init__(self):
 | 
			
		||||
| 
						 | 
				
			
			@ -118,6 +119,10 @@ class Onionr:
 | 
			
		|||
        ''' Start the Onionr communication daemon
 | 
			
		||||
        '''
 | 
			
		||||
        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"])
 | 
			
		||||
            print('Started communicator')
 | 
			
		||||
        api.API(self.config, self.debug)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue