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
PROXY = {
"gw": 5000,
"h3": 5000,
"gw": "gw.some.network:5000",
"h3": "h3.some.network:5000",
}
# Used for bgpmap

6
lg.py
View File

@ -138,14 +138,14 @@ def bird_proxy(host, proto, service, query):
elif proto == "ipv4":
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
elif not path:
return False, 'Proto "%s" invalid' % proto
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:
f = urlopen(url)
resultat = f.read()