test version

This commit is contained in:
2024-08-01 03:18:45 +01:00
commit e21cecd178
28 changed files with 1263 additions and 0 deletions

12
util/README.md Normal file
View File

@@ -0,0 +1,12 @@
## Utils
This folder contains various scripts to let you perform
functions on your tor instance. Many of these are from the
[Stem Website](https://stem.torproject.org) which has
additional documentation on functions you can perform.
Other examples:
Use tor-prompt to interact with a docker process:
```tor-prompt -i 172.16.0.3:9051``

42
util/control_port.py Normal file
View File

@@ -0,0 +1,42 @@
# Connects to the control port to test that the private network is working
import getpass
import sys
import stem
import stem.connection
from stem.control import Controller
if __name__ == '__main__':
try:
controller = Controller.from_port()
except stem.SocketError as exc:
print("Unable to connect to tor on port 9051: %s" % exc)
sys.exit(1)
try:
controller.authenticate()
except stem.connection.MissingPassword:
pw = getpass.getpass("Controller password: ")
try:
controller.authenticate(password = pw)
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("List of DAs found:")
for desc in controller.get_network_statuses():
print("found relay %s (%s)" % (desc.nickname, desc.address))
print("List of Relays Found:")
for desc in controller.get_microdescriptors():
print("found relay %s (%s)" % (desc.identifier, desc.or_addresses))
print("Tor is running version %s" % controller.get_version())
controller.close()

8
util/get_consensus.py Normal file
View File

@@ -0,0 +1,8 @@
from stem.control import Controller
with Controller.from_port(port = 9051) as controller:
controller.authenticate("password")
print("List of relays found on the network:")
for desc in controller.get_network_statuses():
print("%s (%s) at %s" % (desc.nickname, desc.fingerprint, desc.address))

9
util/read_consensus.py Normal file
View 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)