Skip to content
This repository has been archived by the owner on Mar 12, 2021. It is now read-only.

Commit

Permalink
Build tools update
Browse files Browse the repository at this point in the history
  • Loading branch information
SusmithKrishnan committed Sep 23, 2020
1 parent 3ff84b2 commit fc6daec
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 23 deletions.
26 changes: 24 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,27 @@ echo "Installing prerequisites "
sudo apt-get install tor python3-pip -y
echo "Installing dependencies "
sudo pip3 install -r requirements.txt
pyinstaller --onefile torghost.py
sudo cp -r dist/torghost /usr/bin/
mkdir build
cd build
cython3 ../torghost.py --embed -o torghost.c --verbose
if [ $? -eq 0 ]; then
echo [SUCCESS] Generated C code
else
echo [ERROR] Build failed. Unable to generate C code using cython3
exit 1
fi
gcc -Os -I /usr/include/python3.8 -o torghost torghost.c -lpython3.8 -lpthread -lm -lutil -ldl
if [ $? -eq 0 ]; then
echo [SUCCESS] Compiled to static binay
else
echo [ERROR] Build failed
exit 1
fi
sudo cp -r torghost /usr/bin/
if [ $? -eq 0 ]; then
echo [SUCCESS] Copied binary to /usr/bin
else
echo [ERROR] Unable to copy
ecit 1
fi

6 changes: 0 additions & 6 deletions install.sh

This file was deleted.

6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
stem==1.7.1
PyInstaller>=3.6
requests==2.22.0
stem>=1.7.1
requests>=2.22.0
cython
26 changes: 14 additions & 12 deletions torghost.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
import signal
from stem import Signal
from stem.control import Controller
from packaging import version

VERSION = "3.1.0"
VERSION = "3.1.1"

IP_API = "https://api.ipify.org/?format=json"

Expand Down Expand Up @@ -50,9 +51,9 @@ def logo():
| |/ _ \| '__| | _| '_ \ / _ \/ __| __|
| | (_) | | | |_| | | | | (_) \__ \ |_
|_|\___/|_| \____|_| |_|\___/|___/\__|
v3.1.0 - github.com/SusmithKrishnan/torghost
{V} - github.com/SusmithKrishnan/torghost
""")
""".format(V=VERSION))
print(bcolors.ENDC)


Expand Down Expand Up @@ -120,19 +121,19 @@ def start_torghost():
print(t() + ' DNS resolv.conf file already configured')
else:
with open(resolv, 'w') as myfile:
print(t() + ' Configuring DNS resolv.conf file.. ',)
print(t() + ' Configuring DNS resolv.conf file.. '),
myfile.write(resolvString)
print(bcolors.GREEN + '[done]' + bcolors.ENDC)

print(t() + ' Stopping tor service ',)
print(t() + ' Stopping tor service '),
os.system('sudo systemctl stop tor')
os.system('sudo fuser -k 9051/tcp > /dev/null 2>&1')
print(bcolors.GREEN + '[done]' + bcolors.ENDC)
print(t() + ' Starting new tor daemon ',)
print(t() + ' Starting new tor daemon '),
os.system('sudo -u debian-tor tor -f /etc/tor/torghostrc > /dev/null'
)
print(bcolors.GREEN + '[done]' + bcolors.ENDC)
print(t() + ' setting up iptables rules',)
print(t() + ' setting up iptables rules'),

iptables_rules = \
"""
Expand Down Expand Up @@ -167,7 +168,7 @@ def start_torghost():

def stop_torghost():
print(bcolors.RED + t() + 'STOPPING torghost' + bcolors.ENDC)
print(t() + ' Flushing iptables, resetting to default',)
print(t() + ' Flushing iptables, resetting to default'),
os.system('mv /etc/resolv.conf.bak /etc/resolv.conf')
IpFlush = \
"""
Expand All @@ -182,7 +183,7 @@ def stop_torghost():
os.system(IpFlush)
os.system('sudo fuser -k 9051/tcp > /dev/null 2>&1')
print(bcolors.GREEN + '[done]' + bcolors.ENDC)
print(t() + ' Restarting Network manager',)
print(t() + ' Restarting Network manager'),
os.system('service network-manager restart')
print(bcolors.GREEN + '[done]' + bcolors.ENDC)
print(t() + ' Fetching current IP...')
Expand All @@ -193,7 +194,7 @@ def stop_torghost():
def switch_tor():
print(t() + ' Please wait...')
time.sleep(7)
print(t() + ' Requesting new circuit...',)
print(t() + ' Requesting new circuit...'),
with Controller.from_port(port=9051) as controller:
controller.authenticate()
controller.signal(Signal.NEWNYM)
Expand All @@ -206,7 +207,8 @@ def check_update():
print(t() + ' Checking for update...')
jsonRes = get(LATEST_RELEASE_API).json()
newversion = jsonRes["tag_name"][1:]
if newversion != VERSION:
print(newversion)
if version.parse(newversion) > version.parse(VERSION):
print(t() + bcolors.GREEN + ' New update available!' + bcolors.ENDC)
print(t() + ' Your current TorGhost version : ' + bcolors.GREEN + VERSION + bcolors.ENDC)
print(t() + ' Latest TorGhost version available : ' + bcolors.GREEN + newversion + bcolors.ENDC)
Expand Down Expand Up @@ -235,7 +237,7 @@ def main():
try:
(opts, args) = getopt.getopt(sys.argv[1:], 'srxhu', [
'start', 'stop', 'switch', 'help', 'update'])
except (getopt.GetoptError, err):
except (getopt.GetoptError):
usage()
sys.exit(2)
for (o, a) in opts:
Expand Down

0 comments on commit fc6daec

Please sign in to comment.