Merge 0777151cd2 into 4e534a804e
This commit is contained in:
commit
28a0e11a43
|
|
@ -88,12 +88,9 @@ Traffic Legend:
|
||||||
# in the form of token: host:port
|
# in the form of token: host:port
|
||||||
|
|
||||||
# Extract the token parameter from url
|
# Extract the token parameter from url
|
||||||
args = parse_qs(urlparse(path)[4]) # 4 is the query from url
|
token = urlparse(path)[4] # 4 is the query from url
|
||||||
|
if not token:
|
||||||
if not args.has_key('token') or not len(args['token']):
|
raise self.EClose("Token not present")
|
||||||
raise self.EClose("Token not present")
|
|
||||||
|
|
||||||
token = args['token'][0].rstrip('\n')
|
|
||||||
|
|
||||||
# target_cfg can be a single config file or directory of
|
# target_cfg can be a single config file or directory of
|
||||||
# config files
|
# config files
|
||||||
|
|
@ -103,19 +100,13 @@ Traffic Legend:
|
||||||
else:
|
else:
|
||||||
cfg_files = [target_cfg]
|
cfg_files = [target_cfg]
|
||||||
|
|
||||||
targets = {}
|
|
||||||
for f in cfg_files:
|
for f in cfg_files:
|
||||||
for line in [l.strip() for l in file(f).readlines()]:
|
for line in [l.strip() for l in open(f)]:
|
||||||
if line and not line.startswith('#'):
|
if line and not line.startswith('#'):
|
||||||
ttoken, target = line.split(': ')
|
ftoken, target = line.split(': ')
|
||||||
targets[ttoken] = target.strip()
|
if ftoken == token:
|
||||||
|
return target.split(':')
|
||||||
self.vmsg("Target config: %s" % repr(targets))
|
raise self.EClose("Token '%s' not found" % token)
|
||||||
|
|
||||||
if targets.has_key(token):
|
|
||||||
return targets[token].split(':')
|
|
||||||
else:
|
|
||||||
raise self.EClose("Token '%s' not found" % token)
|
|
||||||
|
|
||||||
def do_proxy(self, target):
|
def do_proxy(self, target):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue