Edited it so multitarges works

This commit is contained in:
Joe 2013-08-07 16:35:08 -04:00
parent 292f6a5da7
commit 1c548208c1
1 changed files with 11 additions and 16 deletions

View File

@ -206,12 +206,12 @@ 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
print(token)
#if not 'token' in args or not len(args['token']):
# raise self.EClose("Token not present")
if not args.has_key('token') or not len(args['token']): #token = args['token'][0].rstrip('\n')
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
@ -221,19 +221,14 @@ 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:
print(target)
self.vmsg("Target config: %s" % repr(targets)) return target.split(':')
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):
""" """