mirror of
https://github.com/antitree/private-tor-network
synced 2024-11-16 04:03:49 +00:00
Modifying to support control port on the host
This commit is contained in:
parent
6ab84f60e9
commit
ac294636cc
31
util/control_port.py
Normal file
31
util/control_port.py
Normal file
@ -0,0 +1,31 @@
|
||||
# Connects to the control port to test that the private network is working
|
||||
import sys
|
||||
import getpass
|
||||
import stem.connection
|
||||
import stem.socket
|
||||
|
||||
try:
|
||||
control_socket = stem.socket.ControlPort(port = 9051)
|
||||
except stem.SocketError as exc:
|
||||
print 'Unable to connect to port 9051 (%s)' % exc
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
stem.connection.authenticate(control_socket)
|
||||
except stem.connection.IncorrectSocketType:
|
||||
print 'Please check in your torrc that 9051 is the ControlPort.'
|
||||
print 'Maybe you configured it to be the ORPort or SocksPort instead?'
|
||||
sys.exit(1)
|
||||
except stem.connection.MissingPassword:
|
||||
controller_password = getpass.getpass('Controller password: ')
|
||||
|
||||
try:
|
||||
stem.connection.authenticate_password(control_socket, controller_password)
|
||||
except stem.connection.PasswordAuthFailed:
|
||||
print 'Unable to authenticate, password is incorrect'
|
||||
sys.exit(1)
|
||||
except stem.connection.AuthenticationFailure as exc:
|
||||
print 'Unable to authenticate: %s' % exc
|
||||
sys.exit(1)
|
||||
|
||||
print("Successfully authenticated")
|
7
util/get_consensus.py
Normal file
7
util/get_consensus.py
Normal file
@ -0,0 +1,7 @@
|
||||
from stem.control import Controller
|
||||
|
||||
with Controller.from_port(port = 9051) as controller:
|
||||
controller.authenticate("balls")
|
||||
|
||||
for desc in controller.get_network_statuses():
|
||||
print("found relay %s (%s)" % (desc.nickname, desc.fingerprint))
|
9
util/read_consensus.py
Normal file
9
util/read_consensus.py
Normal file
@ -0,0 +1,9 @@
|
||||
from stem.descriptor import parse_file
|
||||
import sys
|
||||
|
||||
try:
|
||||
path = sys.argv[1]
|
||||
for desc in parse_file(path):
|
||||
print('found relay %s (%s)' % (desc.nickname, desc.fingerprint))
|
||||
except IOError:
|
||||
print("File not found. make sure you supply it with a cached consensus file location: %s" % path)
|
Loading…
Reference in New Issue
Block a user