get subscription by service name

This commit is contained in:
rootzoll 2020-05-26 15:22:46 +02:00
parent 368d8d95e1
commit 45d5f5e4b3

View file

@ -27,6 +27,7 @@ if len(sys.argv) <= 1 or sys.argv[1] == "-h" or sys.argv[1] == "help":
print("# blitz.ip2tor.py subscriptions-list") print("# blitz.ip2tor.py subscriptions-list")
print("# blitz.ip2tor.py subscriptions-renew [secondsBeforeSuspend]") print("# blitz.ip2tor.py subscriptions-renew [secondsBeforeSuspend]")
print("# blitz.ip2tor.py subscription-cancel [id]") print("# blitz.ip2tor.py subscription-cancel [id]")
print("# blitz.ip2tor.py subscription-by-service [servicename]")
sys.exit(1) sys.exit(1)
####### BASIC SETTINGS ######### ####### BASIC SETTINGS #########
@ -868,7 +869,6 @@ if sys.argv[1] == "subscriptions-renew":
# SUBSCRIPTION CANCEL # SUBSCRIPTION CANCEL
# call in intervalls from background process # call in intervalls from background process
####################### #######################
if sys.argv[1] == "subscription-cancel": if sys.argv[1] == "subscription-cancel":
# check parameters # check parameters
@ -898,5 +898,38 @@ if sys.argv[1] == "subscription-cancel":
sys.exit(0) sys.exit(0)
#######################
# GET ADDRESS BY SERVICENAME
# gets called by other scripts to check if service has a ip2tor bridge address
# output is bash key/value style so that it can be imported with source
#######################
if sys.argv[1] == "subscription-by-service":
# check parameters
try:
servicenname = sys.argv[2]
except Exception as e:
handleException(e)
try:
subs = toml.load(SUBSCRIPTIONS_FILE)
newList = []
for idx, sub in enumerate(subs['subscriptions_ip2tor']):
if sub['active'] and sub['blitz_service'] == servicenname:
print("type='{0}'".format(sub['type']))
print("ip='{0}'".format(sub['ip']))
print("port='{0}'".format(sub['port']))
print("tor='{0}'".format(sub['tor']))
sys.exit(0)
print("error='not found'")
sys.exit(0)
except Exception as e:
handleException(e)
sys.exit(1)
# unkown command # unkown command
print("# unkown command") print("# unkown command")