summaryrefslogtreecommitdiff
path: root/tools/compileconfig.py
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2015-06-11 16:38:30 +0200
committerLinus Nordberg <linus@nordu.net>2015-06-12 15:45:18 +0200
commit4e26b3679e9743690a85c9f72f7f4fc8ea8fd3f0 (patch)
tree6c445bb8644a7f2ece4084b731faedb726aea3f0 /tools/compileconfig.py
parent3de0e0af3521f826e60468b2d6d19717fa0a53d7 (diff)
Implement rate limiting of add_chain
Diffstat (limited to 'tools/compileconfig.py')
-rwxr-xr-xtools/compileconfig.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/compileconfig.py b/tools/compileconfig.py
index d90d96d..c48ba66 100755
--- a/tools/compileconfig.py
+++ b/tools/compileconfig.py
@@ -150,6 +150,21 @@ def allowed_servers_frontend(signingnodenames, storagenodenames):
("/ct/signing/sct", signingnodenames),
]
+def parse_ratelimit_expression(expression):
+ if expression == "none":
+ return Symbol("none")
+ parts = expression.split(" ")
+ if not (len(parts) == 3 and parts[1] == 'per' and parts[2] in ["second", "minute", "hour"]):
+ print >>sys.stderr, "Ratelimit expressions must have the format \"<frequency> per second|minute|hour\" or \"none\""
+ sys.exit(1)
+ return (int(parts[0]), Symbol(parts[2]))
+
+def parse_ratelimit((type, description)):
+ descriptions = [parse_ratelimit_expression(s.strip()) for s in description.split(",")]
+ if len(descriptions) != 1:
+ print >>sys.stderr, "%s: Only one ratelimit expression supported right now" % (type,)
+ return (Symbol(type), descriptions)
+
def gen_config(nodename, config, localconfig):
print "generating config for", nodename
paths = localconfig["paths"]
@@ -171,6 +186,9 @@ def gen_config(nodename, config, localconfig):
catlfishconfig.append((Symbol("known_roots_path"), localconfig["paths"]["knownroots"]))
if "sctcaching" in options:
catlfishconfig.append((Symbol("sctcache_root_path"), paths["db"] + "sctcache/"))
+ if localconfig["ratelimits"]:
+ ratelimits = map(parse_ratelimit, localconfig["ratelimits"].items())
+ catlfishconfig.append((Symbol("ratelimits"), ratelimits))
catlfishconfig += [
(Symbol("https_servers"), https_servers),