Simplify proxy host configuration

This commit is contained in:
Zhaofeng Li 2018-11-27 17:21:52 -08:00 committed by Simon Marsh
parent e60cb8027c
commit 0350ff6922
2 changed files with 5 additions and 5 deletions

4
lg.cfg
View File

@ -9,8 +9,8 @@ BIND_IP = "0.0.0.0"
BIND_PORT = 5000 BIND_PORT = 5000
PROXY = { PROXY = {
"gw": 5000, "gw": "gw.some.network:5000",
"h3": 5000, "h3": "h3.some.network:5000",
} }
# Used for bgpmap # Used for bgpmap

6
lg.py
View File

@ -138,14 +138,14 @@ def bird_proxy(host, proto, service, query):
elif proto == "ipv4": elif proto == "ipv4":
path = service path = service
port = app.config["PROXY"].get(host, "") proxyHost = app.config["PROXY"].get(host, "")
if not port: if not proxyHost:
return False, 'Host "%s" invalid' % host return False, 'Host "%s" invalid' % host
elif not path: elif not path:
return False, 'Proto "%s" invalid' % proto return False, 'Proto "%s" invalid' % proto
else: else:
url = "http://%s.%s:%d/%s?q=%s" % (host, app.config["DOMAIN"], port, path, quote(query)) url = "http://%s/%s?q=%s" % (proxyHost, path, quote(query))
try: try:
f = urlopen(url) f = urlopen(url)
resultat = f.read() resultat = f.read()