stem
This commit is contained in:
parent
d24657a1b8
commit
79d3270a8d
@ -54,6 +54,7 @@ commands, or the filename of the nodes file for the nodes command.
|
|||||||
--onions experimental
|
--onions experimental
|
||||||
config - check your /etc/tor/torrc configuration
|
config - check your /etc/tor/torrc configuration
|
||||||
test - test your /etc/tor/torrc configuration
|
test - test your /etc/tor/torrc configuration
|
||||||
|
exits - cleans exists with no Contact Info listed
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -74,6 +75,8 @@ import json
|
|||||||
import warnings
|
import warnings
|
||||||
warnings.filterwarnings('ignore')
|
warnings.filterwarnings('ignore')
|
||||||
|
|
||||||
|
from wrapper_tests import support_testing as ts
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# https://pypi.org/project/msgpack/
|
# https://pypi.org/project/msgpack/
|
||||||
import msgpack
|
import msgpack
|
||||||
@ -83,6 +86,10 @@ try:
|
|||||||
import yaml
|
import yaml
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
yaml = None
|
yaml = None
|
||||||
|
try:
|
||||||
|
import stem
|
||||||
|
except ImportError as e:
|
||||||
|
stem = None
|
||||||
try:
|
try:
|
||||||
# https://pypi.org/project/coloredlogs/
|
# https://pypi.org/project/coloredlogs/
|
||||||
import coloredlogs
|
import coloredlogs
|
||||||
@ -90,6 +97,7 @@ try:
|
|||||||
os.environ['COLOREDLOGS_LEVEL_STYLES'] = 'spam=22;debug=28;verbose=34;notice=220;warning=202;success=118,bold;error=124;critical=background=red'
|
os.environ['COLOREDLOGS_LEVEL_STYLES'] = 'spam=22;debug=28;verbose=34;notice=220;warning=202;success=118,bold;error=124;critical=background=red'
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
coloredlogs = False
|
coloredlogs = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# https://git.plastiras.org/emdee/toxygen_wrapper
|
# https://git.plastiras.org/emdee/toxygen_wrapper
|
||||||
from wrapper.toxencryptsave import ToxEncryptSave
|
from wrapper.toxencryptsave import ToxEncryptSave
|
||||||
@ -112,6 +120,18 @@ except ImportError as e:
|
|||||||
|
|
||||||
LOG = logging.getLogger('TSF')
|
LOG = logging.getLogger('TSF')
|
||||||
|
|
||||||
|
def LOG_error(a): print('EROR> '+a)
|
||||||
|
def LOG_warn(a): print('WARN> '+a)
|
||||||
|
def LOG_info(a):
|
||||||
|
bVERBOSE = hasattr(__builtins__, 'oArgs') and oArgs.log_level <= 20
|
||||||
|
if bVERBOSE: print('INFO> '+a)
|
||||||
|
def LOG_debug(a):
|
||||||
|
bVERBOSE = hasattr(__builtins__, 'oArgs') and oArgs.log_level <= 10-1
|
||||||
|
if bVERBOSE: print('DBUG> '+a)
|
||||||
|
def LOG_trace(a):
|
||||||
|
bVERBOSE = hasattr(__builtins__, 'oArgs') and oArgs.log_level < 10
|
||||||
|
if bVERBOSE: print('TRAC> '+a)
|
||||||
|
|
||||||
# Fix for Windows
|
# Fix for Windows
|
||||||
sDIR = os.environ.get('TMPDIR', '/tmp')
|
sDIR = os.environ.get('TMPDIR', '/tmp')
|
||||||
sTOX_VERSION = "1000002018"
|
sTOX_VERSION = "1000002018"
|
||||||
@ -708,11 +728,11 @@ ip=""
|
|||||||
declare -a ports
|
declare -a ports
|
||||||
jq '.|with_entries(select(.key|match("nodes"))).nodes[]|select(.status_tcp)|select(.ipv4|match("."))|.ipv4,.tcp_ports' | while read line ; do
|
jq '.|with_entries(select(.key|match("nodes"))).nodes[]|select(.status_tcp)|select(.ipv4|match("."))|.ipv4,.tcp_ports' | while read line ; do
|
||||||
if [ -z "$ip" ] ; then
|
if [ -z "$ip" ] ; then
|
||||||
ip=`echo $line|sed -e 's/"//g'`
|
ip=`echo $line|sed -e 's/"//g'`
|
||||||
ports=()
|
ports=()
|
||||||
continue
|
continue
|
||||||
elif [ "$line" = '[' ] ; then
|
elif [ "$line" = '[' ] ; then
|
||||||
continue
|
continue
|
||||||
elif [ "$line" = ']' ] ; then
|
elif [ "$line" = ']' ] ; then
|
||||||
if ! route | grep -q ^def ; then
|
if ! route | grep -q ^def ; then
|
||||||
echo ERROR no route
|
echo ERROR no route
|
||||||
@ -1017,15 +1037,15 @@ def iOsSystemNmapTcp(l, oArgs):
|
|||||||
iErrs += iErr
|
iErrs += iErr
|
||||||
return iErrs
|
return iErrs
|
||||||
|
|
||||||
def vSetupLogging(loglevel=logging.DEBUG):
|
def vSetupLogging(log_level=logging.DEBUG):
|
||||||
global LOG
|
global LOG
|
||||||
if coloredlogs:
|
if coloredlogs:
|
||||||
aKw = dict(level=loglevel,
|
aKw = dict(level=log_level,
|
||||||
logger=LOG,
|
logger=LOG,
|
||||||
fmt='%(name)s %(levelname)s %(message)s')
|
fmt='%(name)s %(levelname)s %(message)s')
|
||||||
coloredlogs.install(**aKw)
|
coloredlogs.install(**aKw)
|
||||||
else:
|
else:
|
||||||
aKw = dict(level=loglevel,
|
aKw = dict(level=log_level,
|
||||||
format='%(name)s %(levelname)-4s %(message)s')
|
format='%(name)s %(levelname)-4s %(message)s')
|
||||||
logging.basicConfig(**aKw)
|
logging.basicConfig(**aKw)
|
||||||
|
|
||||||
@ -1057,6 +1077,23 @@ def iTestTorConfig(sProOrNodes, oArgs, bClean=False):
|
|||||||
# add_bootstrap
|
# add_bootstrap
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
def iTestTorExits(sProOrNodes, oArgs, bClean=False):
|
||||||
|
LOG.info(f"iTestTorExits")
|
||||||
|
# import pdb; pdb.set_trace()
|
||||||
|
# sProOrNodes
|
||||||
|
try:
|
||||||
|
if hasattr(ts, 'oSTEM_CONTROLER') and ts.oSTEM_CONTROLER \
|
||||||
|
and controller.is_set('ExcludeExitNodes'):
|
||||||
|
LOG_info(f"ExcludeExitNodes is set so we cant continue")
|
||||||
|
return 0
|
||||||
|
LOG_info(f"ExcludeExitNodes is not set so we can continue")
|
||||||
|
l = ts.lExitExcluder(iPort=9051)
|
||||||
|
except Exception as e:
|
||||||
|
LOG.error(f"ExcludeExitNodes errored {e}")
|
||||||
|
return 1
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
def iTestTorTest(sProOrNodes, oArgs, bClean=False):
|
def iTestTorTest(sProOrNodes, oArgs, bClean=False):
|
||||||
# test_onion
|
# test_onion
|
||||||
# check_mapaddress
|
# check_mapaddress
|
||||||
@ -1215,7 +1252,13 @@ def iMain(sProOrNodes, oArgs):
|
|||||||
elif oArgs.onions == 'test':
|
elif oArgs.onions == 'test':
|
||||||
i = iTestTorTest(sProOrNodes, oArgs)
|
i = iTestTorTest(sProOrNodes, oArgs)
|
||||||
iRet = i
|
iRet = i
|
||||||
|
|
||||||
|
elif oArgs.onions == 'exits':
|
||||||
|
i = iTestTorExits(sProOrNodes, oArgs)
|
||||||
|
iRet = i
|
||||||
|
else:
|
||||||
|
RuntimeError( oArgs.onions)
|
||||||
|
|
||||||
elif oArgs.command in ['info', 'edit']:
|
elif oArgs.command in ['info', 'edit']:
|
||||||
|
|
||||||
if oArgs.command in ['edit']:
|
if oArgs.command in ['edit']:
|
||||||
@ -1370,7 +1413,7 @@ def oMainArgparser(_=None):
|
|||||||
parser.add_argument('--download_nodes_url', type=str,
|
parser.add_argument('--download_nodes_url', type=str,
|
||||||
default='https://nodes.tox.chat/json')
|
default='https://nodes.tox.chat/json')
|
||||||
parser.add_argument('--onions', type=str, default='',
|
parser.add_argument('--onions', type=str, default='',
|
||||||
choices=['config', 'test'] if bHAVE_TOR else [],
|
choices=['config', 'test', 'exits'] if bHAVE_TOR else [],
|
||||||
help='Action for onion command (requires tor)')
|
help='Action for onion command (requires tor)')
|
||||||
|
|
||||||
parser.add_argument('--encoding', type=str, default=sENC)
|
parser.add_argument('--encoding', type=str, default=sENC)
|
||||||
@ -1400,6 +1443,7 @@ if __name__ == '__main__':
|
|||||||
print('Supported Quads: section,num,key,type ' +sEDIT_HELP)
|
print('Supported Quads: section,num,key,type ' +sEDIT_HELP)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
__builtins__.oArgs = oArgs
|
||||||
vSetupLogging(oArgs.log_level)
|
vSetupLogging(oArgs.log_level)
|
||||||
i = 0
|
i = 0
|
||||||
for sProOrNodes in oArgs.lprofile:
|
for sProOrNodes in oArgs.lprofile:
|
||||||
|
Loading…
Reference in New Issue
Block a user