diff options
author | Magnus Ahltorp <map@kth.se> | 2015-03-27 17:33:35 +0100 |
---|---|---|
committer | Magnus Ahltorp <map@kth.se> | 2015-03-27 17:33:35 +0100 |
commit | 6c07054bbb2b04a686e48fb2ca46807d82d03699 (patch) | |
tree | b13113b172bca8c148a11141384d3274de16edf9 /tools/compileconfig.py | |
parent | 6cd3c80c61711cabf9e308da1963b56f6dd49cfd (diff) |
Allow local administrator to override IP address and port for web serverbindaddress
Closes CATLFISH-30
Diffstat (limited to 'tools/compileconfig.py')
-rwxr-xr-x | tools/compileconfig.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/tools/compileconfig.py b/tools/compileconfig.py index 52f10e8..88d6b51 100755 --- a/tools/compileconfig.py +++ b/tools/compileconfig.py @@ -77,17 +77,24 @@ def get_node_config(nodename, config): sys.exit(1) return (nodetype, nodeconfig) -def gen_https_servers(nodetype, nodeconfig): +def gen_https_servers(nodetype, nodeconfig, bind_address, bind_publicaddress): + if bind_address: + (host, port) = parse_address(bind_address) + else: + (_, port) = parse_address(nodeconfig["address"]) + host = "0.0.0.0" if nodetype == "frontendnodes": - (publichost, publicport) = parse_address(nodeconfig["publicaddress"]) - (host, port) = parse_address(nodeconfig["address"]) + if bind_publicaddress: + (publichost, publicport) = parse_address(bind_publicaddress) + else: + (_, publicport) = parse_address(nodeconfig["publicaddress"]) + publichost = "0.0.0.0" + return [(Symbol("external_https_api"), publichost, publicport, Symbol("v1")), (Symbol("frontend_https_api"), host, port, Symbol("frontend"))] elif nodetype == "storagenodes": - (host, port) = parse_address(nodeconfig["address"]) return [(Symbol("storage_https_api"), host, port, Symbol("storage"))] elif nodetype == "signingnodes": - (host, port) = parse_address(nodeconfig["address"]) return [(Symbol("signing_https_api"), host, port, Symbol("signing"))] def allowed_clients_frontend(mergenodenames): @@ -136,13 +143,15 @@ def allowed_servers_frontend(signingnodenames, storagenodenames): def gen_config(nodename, config, localconfig): print "generating config for", nodename paths = localconfig["paths"] + bind_address = localconfig.get("addresses", {}).get(nodename) + bind_publicaddress = localconfig.get("publicaddresses", {}).get(nodename) options = localconfig.get("options", []) configfile = open(paths["configdir"] + nodename + ".config", "w") print >>configfile, "%% catlfish configuration file (-*- erlang -*-)" (nodetype, nodeconfig) = get_node_config(nodename, config) - https_servers = gen_https_servers(nodetype, nodeconfig) + https_servers = gen_https_servers(nodetype, nodeconfig, bind_address, bind_publicaddress) catlfishconfig = [] plopconfig = [] |