tor now exits properly on STOP command
This commit is contained in:
parent
ead0741e03
commit
4510dbfd82
@ -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, random, sys, logger, time
|
import subprocess, os, random, sys, logger, time, signal
|
||||||
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
|
||||||
@ -27,6 +27,7 @@ class NetController:
|
|||||||
self.readyState = False
|
self.readyState = False
|
||||||
self.socksPort = random.randint(1024, 65535)
|
self.socksPort = random.randint(1024, 65535)
|
||||||
self.hsPort = hsPort
|
self.hsPort = hsPort
|
||||||
|
self._torInstnace = ''
|
||||||
self.myID = ''
|
self.myID = ''
|
||||||
'''
|
'''
|
||||||
if os.path.exists(self.torConfigLocation):
|
if os.path.exists(self.torConfigLocation):
|
||||||
@ -66,4 +67,20 @@ HiddenServicePort 80 127.0.0.1:''' + str(self.hsPort) + '''
|
|||||||
myID = open('data/hs/hostname', 'r')
|
myID = open('data/hs/hostname', 'r')
|
||||||
self.myID = myID.read()
|
self.myID = myID.read()
|
||||||
myID.close()
|
myID.close()
|
||||||
|
torPidFile = open('data/torPid.txt', 'w')
|
||||||
|
torPidFile.write(str(tor.pid))
|
||||||
|
torPidFile.close()
|
||||||
return
|
return
|
||||||
|
def killTor(self):
|
||||||
|
try:
|
||||||
|
pid = open('data/torPid.txt', 'r')
|
||||||
|
pidN = pid.read()
|
||||||
|
pid.close()
|
||||||
|
except FileNotFoundError:
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
int(pidN)
|
||||||
|
except:
|
||||||
|
return
|
||||||
|
os.kill(int(pidN), signal.SIGTERM)
|
||||||
|
os.remove('data/torPid.txt')
|
@ -134,11 +134,13 @@ class Onionr:
|
|||||||
def killDaemon(self):
|
def killDaemon(self):
|
||||||
'''Shutdown the Onionr Daemon'''
|
'''Shutdown the Onionr Daemon'''
|
||||||
logger.warn('Killing the running daemon')
|
logger.warn('Killing the running daemon')
|
||||||
|
net = NetController(self.config['CLIENT']['PORT'])
|
||||||
try:
|
try:
|
||||||
self.onionrUtils.localCommand('shutdown')
|
self.onionrUtils.localCommand('shutdown')
|
||||||
except requests.exceptions.ConnectionError:
|
except requests.exceptions.ConnectionError:
|
||||||
pass
|
pass
|
||||||
self.onionrCore.daemonQueueAdd('shutdown')
|
self.onionrCore.daemonQueueAdd('shutdown')
|
||||||
|
net.killTor()
|
||||||
return
|
return
|
||||||
def showStats(self):
|
def showStats(self):
|
||||||
'''Display statistics and exit'''
|
'''Display statistics and exit'''
|
||||||
|
Loading…
Reference in New Issue
Block a user