Add port and protocol validation

This commit is contained in:
Mark Veidemanis 2017-11-23 19:19:48 +00:00
parent 4f70cf69b3
commit c3aa3715c6
2 changed files with 16 additions and 1 deletions

View File

@ -1 +0,0 @@
{}

View File

@ -187,6 +187,12 @@ class Helper(object):
incUsage("connect")
return
try:
int(spl[3])
except:
failure("Port must be an integer, not %s" % spl[3])
return
pool[spl[1]] = { "address": spl[2],
"port": spl[3],
"protocol": protocol,
@ -252,6 +258,16 @@ class Helper(object):
if not spl[2] in pool[spl[1]].keys():
failure("No such key: %s" % spl[2])
return
if spl[2] == "port":
try:
int(spl[3])
except:
failure("Port must be an integer, not %s" % spl[3])
return
if spl[2] == "protocol":
if not spl[3] in ["ssl", "plain"]:
failure("Protocol must be ssl or plain, not %s" % spl[3])
return
if spl[3] == pool[spl[1]][spl[2]]:
failure("Value already exists: %s" % spl[3])
return