update
This commit is contained in:
parent
9c97bb9acb
commit
17f6264c18
16
Makefile
16
Makefile
@ -1,5 +1,6 @@
|
|||||||
PREFIX=/usr/local
|
PREFIX=/usr/local
|
||||||
PYTHON_EXE_MSYS=${PREFIX}/bin/python3.bash
|
PYTHON_EXE_MSYS=${PREFIX}/bin/python3.sh
|
||||||
|
PIP_EXE_MSYS=${PREFIX}/bin/pip3.sh
|
||||||
LOCAL_DOCTEST=${PREFIX}/bin/toxcore_run_doctest3.bash
|
LOCAL_DOCTEST=${PREFIX}/bin/toxcore_run_doctest3.bash
|
||||||
DOCTEST=${LOCAL_DOCTEST}
|
DOCTEST=${LOCAL_DOCTEST}
|
||||||
MOD=exclude_badExits
|
MOD=exclude_badExits
|
||||||
@ -11,21 +12,20 @@ lint::
|
|||||||
sh .pylint.sh
|
sh .pylint.sh
|
||||||
|
|
||||||
install::
|
install::
|
||||||
pip3.sh install --target ${PREFIX}/lib/python3.11/site-packages/ --upgrade .
|
${PIP_EXE_MSYS} install --target ${PREFIX}/lib/python3.11/site-packages/ --upgrade .
|
||||||
|
|
||||||
rsync::
|
rsync::
|
||||||
bash .rsync.sh
|
bash .rsync.sh
|
||||||
|
|
||||||
test::
|
test::
|
||||||
${PYTHON_EXE_MSYS} exclude_badExits.py --help
|
env PYTHONPATH=${PWD}/src ${PYTHON_EXE_MSYS} ${PWD}/src/${MOD}/exclude_badExits.py --help
|
||||||
TOR_CONTROLLER_PASSWORD=${PASS} ${PYTHON_EXE_MSYS} src/${MOD}/torcontactinfo.py
|
env PYTHONPATH=${PWD}/src TOR_CONTROLLER_PASSWORD=${PASS} ${PYTHON_EXE_MSYS} src/${MOD}/torcontactinfo.py
|
||||||
|
|
||||||
doctest::
|
doctest::
|
||||||
export PYTHONPATH=${PWD}/src/${MOD}
|
env PYTHONPATH=${PWD}/src ${DOCTEST} ${MOD}.txt
|
||||||
${DOCTEST} ${MOD}.txt
|
|
||||||
|
|
||||||
veryclean:: clean
|
veryclean:: clean
|
||||||
rm -rf build dist
|
rm -rf build dist src/exclude_badExits.egg-info/
|
||||||
|
|
||||||
clean::
|
clean::
|
||||||
find * -name \*~ -delete
|
find * -name \*~ -delete
|
||||||
|
@ -140,4 +140,4 @@ For usage, do ```python3 exclude_badExits.py --help```
|
|||||||
See [exclude_badExits.hlp](./exclude_badExits.hlp)
|
See [exclude_badExits.hlp](./exclude_badExits.hlp)
|
||||||
or there's a doctest file in [exclude_badExits.txt](./exclude_badExits.txt)
|
or there's a doctest file in [exclude_badExits.txt](./exclude_badExits.txt)
|
||||||
|
|
||||||
|
Up-to-date code is on https://git.plastiras.org/emdee/exclude_badExits
|
||||||
|
@ -17,19 +17,15 @@ classifiers = [
|
|||||||
"Programming Language :: Python :: 3.11",
|
"Programming Language :: Python :: 3.11",
|
||||||
"Programming Language :: Python :: Implementation :: CPython",
|
"Programming Language :: Python :: Implementation :: CPython",
|
||||||
]
|
]
|
||||||
dynamic = ["version", "readme", ] # cannot be dynamic ['license']
|
dynamic = ["version", "readme", "dependencies"] # cannot be dynamic ['license']
|
||||||
dependencies = [
|
|
||||||
# 'qasync >= 0.27.1',
|
|
||||||
'cryptography >= 41.0.7',
|
|
||||||
'rsa >= 4.9',
|
|
||||||
'stem >= 1.8.2']
|
|
||||||
|
|
||||||
[project.scripts
|
[project.scripts]
|
||||||
exclude_badExits = "exclude_badExits.exclude_badExits:iMain"
|
exclude_badExits = "exclude_badExits.exclude_badExits:iMain"
|
||||||
|
|
||||||
[tool.setuptools.dynamic]
|
[tool.setuptools.dynamic]
|
||||||
version = {attr = "exclude_badExits.__version__"}
|
version = {attr = "exclude_badExits.__version__"}
|
||||||
readme = {file = ["README.md"]}
|
readme = {file = ["README.md"]}
|
||||||
|
dependencies = {file = ["requirements.txt"]}
|
||||||
|
|
||||||
[project.license]
|
[project.license]
|
||||||
file = "LICENSE.md"
|
file = "LICENSE.md"
|
||||||
@ -42,8 +38,6 @@ requires = ["setuptools >= 61.0"]
|
|||||||
build-backend = "setuptools.build_meta"
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
# Either or both of these don't work
|
# Either or both of these don't work
|
||||||
#[tool.setuptools]
|
[tool.setuptools]
|
||||||
#packages = ["exclude_badExits"]
|
packages = ["exclude_badExits"]
|
||||||
|
|
||||||
#[tool.setuptools.packages.find]
|
|
||||||
#include = ["src"]
|
|
||||||
|
64
setup.cfg
Normal file
64
setup.cfg
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
[metadata]
|
||||||
|
classifiers =
|
||||||
|
License :: OSI Approved
|
||||||
|
Intended Audience :: Web Developers
|
||||||
|
Operating System :: POSIX :: BSD :: FreeBSD
|
||||||
|
Operating System :: POSIX :: Linux
|
||||||
|
Programming Language :: Python :: 3 :: Only
|
||||||
|
Programming Language :: Python :: 3.6
|
||||||
|
Programming Language :: Python :: 3.7
|
||||||
|
Programming Language :: Python :: 3.8
|
||||||
|
Programming Language :: Python :: 3.9
|
||||||
|
Programming Language :: Python :: 3.10
|
||||||
|
Programming Language :: Python :: 3.11
|
||||||
|
Programming Language :: Python :: Implementation :: CPython
|
||||||
|
Framework :: AsyncIO
|
||||||
|
description='Tox ctypes wrapping into Python'
|
||||||
|
long_description='A program to exclude bad exits on the Tor network'
|
||||||
|
url='https://git.plastiras.org/emdee/exclude_badExits/'
|
||||||
|
keywords='rotten-onions tor'
|
||||||
|
|
||||||
|
[options]
|
||||||
|
zip_safe = false
|
||||||
|
#python_requires = >=3.6
|
||||||
|
include_package_data =
|
||||||
|
"*" = ["*.txt"]
|
||||||
|
package_dir=
|
||||||
|
=src
|
||||||
|
packages = ["exclude_badExits"]
|
||||||
|
|
||||||
|
|
||||||
|
[options.packages.find]
|
||||||
|
where=src
|
||||||
|
|
||||||
|
[options.entry_points]
|
||||||
|
console_scripts =
|
||||||
|
exclude_badExits = exclude_badExits.exclude_badExits:iMain
|
||||||
|
|
||||||
|
[easy_install]
|
||||||
|
zip_ok = false
|
||||||
|
|
||||||
|
[flake8]
|
||||||
|
jobs = 1
|
||||||
|
max-line-length = 88
|
||||||
|
ignore =
|
||||||
|
E111
|
||||||
|
E114
|
||||||
|
E128
|
||||||
|
E225
|
||||||
|
E261
|
||||||
|
E302
|
||||||
|
E305
|
||||||
|
E402
|
||||||
|
E501
|
||||||
|
E502
|
||||||
|
E541
|
||||||
|
E701
|
||||||
|
E702
|
||||||
|
E704
|
||||||
|
E722
|
||||||
|
E741
|
||||||
|
F508
|
||||||
|
F541
|
||||||
|
W503
|
||||||
|
W601
|
@ -9,16 +9,10 @@ import socket
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
if False:
|
import stem
|
||||||
import cepa as stem
|
from stem.connection import MissingPassword
|
||||||
from cepa.connection import MissingPassword
|
from stem.control import Controller
|
||||||
from cepa.control import Controller
|
from stem.util.tor_tools import is_valid_fingerprint
|
||||||
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
|
|
||||||
|
|
||||||
global LOG
|
global LOG
|
||||||
import logging
|
import logging
|
||||||
|
@ -24,20 +24,20 @@ import logging
|
|||||||
import warnings
|
import warnings
|
||||||
import requests
|
import requests
|
||||||
import textwrap
|
import textwrap
|
||||||
try:
|
|
||||||
from rich import print as rprint
|
# from rich import print as rprintxxx
|
||||||
HAS_RICH = True
|
# HAS_RICH = True
|
||||||
except ImportError:
|
if True:
|
||||||
def rprint(value='', *args, **kwargs):
|
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)
|
value = json.dumps(value, indent=4)
|
||||||
return print(value, *args, **kwargs)
|
return LOG.debug(value, *args, **kwargs)
|
||||||
# rprint = print
|
# rprint = print
|
||||||
HAS_RICH = False
|
# HAS_RICH = False
|
||||||
|
|
||||||
warnings.filterwarnings('ignore')
|
warnings.filterwarnings('ignore')
|
||||||
|
LOG = logging.getLogger()
|
||||||
from exclude_badExits.exclude_utils import vsetup_logging
|
|
||||||
|
|
||||||
class TorContactInfoParser(object):
|
class TorContactInfoParser(object):
|
||||||
email_regex = "^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$"
|
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:
|
if opts.pretty:
|
||||||
rprint(result)
|
rprint(result)
|
||||||
else:
|
else:
|
||||||
print(result)
|
LOG.debug(result)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
ETC_DIR = '/etc/tor/yaml'
|
ETC_DIR = '/etc/tor/yaml'
|
||||||
@ -544,7 +544,7 @@ def oparser():
|
|||||||
|
|
||||||
return cparser
|
return cparser
|
||||||
|
|
||||||
def iMain(lArgs=None)
|
def iMain(lArgs=None):
|
||||||
cparser = oparser()
|
cparser = oparser()
|
||||||
opts = cparser.parse_args(lArgs)
|
opts = cparser.parse_args(lArgs)
|
||||||
data = None
|
data = None
|
||||||
@ -554,11 +554,11 @@ def iMain(lArgs=None)
|
|||||||
return i
|
return i
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
from exclude_utils import vsetup_logging
|
||||||
if os.environ.get('DEBUG', ''):
|
if os.environ.get('DEBUG', ''):
|
||||||
log_level = 10
|
log_level = 10 # logging.DEBUG
|
||||||
else:
|
else:
|
||||||
log_level = 20
|
log_level = 20 # logging.INFO
|
||||||
LOG = logging.getLogger()
|
|
||||||
vsetup_logging(LOG, log_level)
|
vsetup_logging(LOG, log_level)
|
||||||
try:
|
try:
|
||||||
i = iMain(sys.argv[1:])
|
i = iMain(sys.argv[1:])
|
||||||
|
@ -218,7 +218,7 @@ def find_validation_candidates(controller,
|
|||||||
result[domain] = {prooftype: [fingerprint]}
|
result[domain] = {prooftype: [fingerprint]}
|
||||||
return result
|
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
|
import requests
|
||||||
# socks proxy used for outbound web requests (for validation of proofs)
|
# socks proxy used for outbound web requests (for validation of proofs)
|
||||||
proxy = {'https': "socks5h://{host}:{port}"}
|
proxy = {'https': "socks5h://{host}:{port}"}
|
||||||
@ -266,7 +266,7 @@ def oDownloadUrlRequests(uri, sCAfile, timeout=30, host='127.0.0.1', port=9050,
|
|||||||
return oReqResp
|
return oReqResp
|
||||||
|
|
||||||
# There's no point in using asyncio because of duplicate urls in the tasks
|
# 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 httpcore
|
||||||
import asyncio
|
import asyncio
|
||||||
import httpx
|
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]
|
well_known_content = [i for i in well_known_content if i and len(i) == 40]
|
||||||
return well_known_content
|
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()
|
This function takes the return value of find_validation_candidates()
|
||||||
and validated them according to their proof type (uri-rsa, dns-rsa)
|
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,
|
validate_proofs(r, validation_cache_file,
|
||||||
timeout=timeout,
|
timeout=timeout,
|
||||||
host=controller_address,
|
host=controller_address,
|
||||||
port=port)
|
port=port,
|
||||||
|
CAfile=CAfile)
|
||||||
|
|
||||||
# refresh list with newly validated fingerprints
|
# refresh list with newly validated fingerprints
|
||||||
trusted_fingerprints = read_local_validation_cache(validation_cache_file,
|
trusted_fingerprints = read_local_validation_cache(validation_cache_file,
|
||||||
|
Loading…
Reference in New Issue
Block a user