update
This commit is contained in:
parent
9c97bb9acb
commit
17f6264c18
7 changed files with 102 additions and 48 deletions
|
@ -9,16 +9,10 @@ import socket
|
|||
import sys
|
||||
import time
|
||||
|
||||
if False:
|
||||
import cepa as stem
|
||||
from cepa.connection import MissingPassword
|
||||
from cepa.control import Controller
|
||||
from cepa.util.tor_tools import is_valid_fingerprint
|
||||
else:
|
||||
import stem
|
||||
from stem.connection import MissingPassword
|
||||
from stem.control import Controller
|
||||
from stem.util.tor_tools import is_valid_fingerprint
|
||||
import stem
|
||||
from stem.connection import MissingPassword
|
||||
from stem.control import Controller
|
||||
from stem.util.tor_tools import is_valid_fingerprint
|
||||
|
||||
global LOG
|
||||
import logging
|
||||
|
|
|
@ -24,20 +24,20 @@ import logging
|
|||
import warnings
|
||||
import requests
|
||||
import textwrap
|
||||
try:
|
||||
from rich import print as rprint
|
||||
HAS_RICH = True
|
||||
except ImportError:
|
||||
|
||||
# from rich import print as rprintxxx
|
||||
# HAS_RICH = True
|
||||
if True:
|
||||
def rprint(value='', *args, **kwargs):
|
||||
if value not in [None, False, True] and isinstance(value, (dict, list, set, tuple)):
|
||||
if value not in [None, False, True] and
|
||||
isinstance(value, (dict, list, set, tuple)):
|
||||
value = json.dumps(value, indent=4)
|
||||
return print(value, *args, **kwargs)
|
||||
return LOG.debug(value, *args, **kwargs)
|
||||
# rprint = print
|
||||
HAS_RICH = False
|
||||
# HAS_RICH = False
|
||||
|
||||
warnings.filterwarnings('ignore')
|
||||
|
||||
from exclude_badExits.exclude_utils import vsetup_logging
|
||||
LOG = logging.getLogger()
|
||||
|
||||
class TorContactInfoParser(object):
|
||||
email_regex = "^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$"
|
||||
|
@ -448,7 +448,7 @@ def cmd_scan(opts: argparse.Namespace, adata=None) -> int:
|
|||
if opts.pretty:
|
||||
rprint(result)
|
||||
else:
|
||||
print(result)
|
||||
LOG.debug(result)
|
||||
return 0
|
||||
|
||||
ETC_DIR = '/etc/tor/yaml'
|
||||
|
@ -544,7 +544,7 @@ def oparser():
|
|||
|
||||
return cparser
|
||||
|
||||
def iMain(lArgs=None)
|
||||
def iMain(lArgs=None):
|
||||
cparser = oparser()
|
||||
opts = cparser.parse_args(lArgs)
|
||||
data = None
|
||||
|
@ -554,11 +554,11 @@ def iMain(lArgs=None)
|
|||
return i
|
||||
|
||||
if __name__ == "__main__":
|
||||
from exclude_utils import vsetup_logging
|
||||
if os.environ.get('DEBUG', ''):
|
||||
log_level = 10
|
||||
log_level = 10 # logging.DEBUG
|
||||
else:
|
||||
log_level = 20
|
||||
LOG = logging.getLogger()
|
||||
log_level = 20 # logging.INFO
|
||||
vsetup_logging(LOG, log_level)
|
||||
try:
|
||||
i = iMain(sys.argv[1:])
|
||||
|
|
|
@ -218,7 +218,7 @@ def find_validation_candidates(controller,
|
|||
result[domain] = {prooftype: [fingerprint]}
|
||||
return result
|
||||
|
||||
def oDownloadUrlRequests(uri, sCAfile, timeout=30, host='127.0.0.1', port=9050, content_type='text/plain', session=None):
|
||||
def oDownloadUrlRequests(uri, sCAfile: str, timeout: int = 30, host: str = '127.0.0.1', port:int = 9050, content_type: str = 'text/plain', session=None):
|
||||
import requests
|
||||
# socks proxy used for outbound web requests (for validation of proofs)
|
||||
proxy = {'https': "socks5h://{host}:{port}"}
|
||||
|
@ -266,7 +266,7 @@ def oDownloadUrlRequests(uri, sCAfile, timeout=30, host='127.0.0.1', port=9050,
|
|||
return oReqResp
|
||||
|
||||
# There's no point in using asyncio because of duplicate urls in the tasks
|
||||
async def oDownloadUrlHttpx(uri, sCAfile, timeout=30, host='127.0.0.1', port=9050, content_type='text/plain'):
|
||||
async def oDownloadUrlHttpx(uri:str, sCAfile:str, timeout;int = 30, host:str = '127.0.0.1', port:int = 9050, content_type:str = 'text/plain'):
|
||||
import httpcore
|
||||
import asyncio
|
||||
import httpx
|
||||
|
@ -502,7 +502,8 @@ def lDownloadUrlFps(domain, sCAfile, timeout=30, host='127.0.0.1', port=9050):
|
|||
well_known_content = [i for i in well_known_content if i and len(i) == 40]
|
||||
return well_known_content
|
||||
|
||||
def validate_proofs(candidates, validation_cache_file, timeout=20, host='127.0.0.1', port=9050):
|
||||
def validate_proofs(candidates, validation_cache_file, timeout=20, host='127.0.0.1', port=9050, CAfile:str = '/etc/ssl/certs/ca-certificates.crt'):
|
||||
|
||||
'''
|
||||
This function takes the return value of find_validation_candidates()
|
||||
and validated them according to their proof type (uri-rsa, dns-rsa)
|
||||
|
@ -619,7 +620,8 @@ if __name__ == '__main__':
|
|||
validate_proofs(r, validation_cache_file,
|
||||
timeout=timeout,
|
||||
host=controller_address,
|
||||
port=port)
|
||||
port=port,
|
||||
CAfile=CAfile)
|
||||
|
||||
# refresh list with newly validated fingerprints
|
||||
trusted_fingerprints = read_local_validation_cache(validation_cache_file,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue