check for empty proxy

This commit is contained in:
Roy Olav Purser 2021-05-12 12:22:01 +02:00
parent 3ccbef047e
commit 462a3dbbc5
Signed by: roypur
GPG Key ID: E14D26A036F21656

View File

@ -200,6 +200,7 @@ class MainHandler(tornado.web.RequestHandler):
streams = proxy.stream.streams(src)
for key in reversed(streams):
stream = streams.get(key)
print(stream)
if hasattr(stream, "url"):
upstream = stream.url
break
@ -220,11 +221,14 @@ class MainHandler(tornado.web.RequestHandler):
ldata["proxy"] = proxy.proxy
ldata["proxied"] = isinstance(proxy.proxy, str)
links = [ldata]
resp = requests.post(proxy_server, json=links)
if isinstance(resp.text, str):
new_links = json.loads(resp.text)
if isinstance(new_links, list) and len(new_links) == 1:
upstream = new_links.pop()
try:
resp = requests.post(proxy_server, json=links)
if isinstance(resp.text, str):
new_links = json.loads(resp.text)
if isinstance(new_links, list) and len(new_links) == 1:
upstream = new_links.pop()
except Exception as e:
print(e)
if data is None:
self.redirect(upstream, status=303)
else: