Simplify proxy host configuration
This commit is contained in:
parent
e60cb8027c
commit
0350ff6922
4
lg.cfg
4
lg.cfg
@ -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
6
lg.py
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user