58 lines
1.7 KiB
Python
Executable File
58 lines
1.7 KiB
Python
Executable File
#!/usr/local/bin/python3.sh
|
|
# -*- mode: python; indent-tabs-mode: nil; py-indent-offset: 4; coding: utf-8 -*-
|
|
__doc__ = """List Outdated Relays
|
|
|
|
Time marches on. Tor makes new releases, and at some point needs to drop
|
|
support for old ones. Below is the script we used on ticket 9476 to reach out
|
|
to relay operators that needed to upgrade.
|
|
|
|
https://stem.torproject.org/tutorials/examples/outdated_relays.html
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import logging
|
|
|
|
import stem.interpreter.commands
|
|
from stem.descriptor.remote import DescriptorDownloader
|
|
from stem_examples.tor_controller import get_controller
|
|
from stem.version import Version
|
|
|
|
from tor_controller import set_socks_proxy, unset_socks_proxy
|
|
|
|
LOG = logging.getLogger()
|
|
|
|
def iMain(lArgs=None):
|
|
if not lArgs:
|
|
lArgs = ['GETINFO' 'version']
|
|
password = os.environ.get('TOR_CONTROLLER_PASSWORD', '')
|
|
if os.path.exists('/run/tor/control'):
|
|
controller = get_controller(password=password, unix='/run/tor/control')
|
|
else:
|
|
controller = get_controller(password=password, port=9051)
|
|
interpreter = stem.interpreter.commands.ControlInterpreter(controller)
|
|
run_cmd = ' '.join(lArgs)
|
|
interpreter.run_command(run_cmd, print_response = True)
|
|
return 0
|
|
|
|
if __name__ == '__main__':
|
|
# set_socks_proxy()
|
|
from stem_examples.stem_utils import vsetup_logging
|
|
if os.environ.get('DEBUG', ''):
|
|
log_level = 10
|
|
else:
|
|
log_level = 20
|
|
vsetup_logging(LOG, log_level)
|
|
try:
|
|
l = iMain(sys.argv[1:])
|
|
if l: print(l)
|
|
i = 0
|
|
except KeyboardInterrupt as e:
|
|
i = 0
|
|
except Exception as e:
|
|
LOG.exception(f"Exception {e}")
|
|
i = 1
|
|
finally:
|
|
unset_socks_proxy()
|
|
sys.exit(i)
|