summaryrefslogtreecommitdiff
path: root/src/catlfish_sup.erl
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2015-03-30 15:41:13 +0200
committerMagnus Ahltorp <map@kth.se>2015-03-31 00:40:58 +0200
commit22cefc84254cae1f57195da819eba69dbacb5a6e (patch)
tree63508f318361150ba35bbe17c18ab3e146dd20f1 /src/catlfish_sup.erl
parent2d8d55bb9b6672ebe829b185beb05d4a399167f5 (diff)
Allow non-TLS httpnopublicssl3
Closes CATLFISH-31
Diffstat (limited to 'src/catlfish_sup.erl')
-rw-r--r--src/catlfish_sup.erl34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/catlfish_sup.erl b/src/catlfish_sup.erl
index 6f918cd..882a017 100644
--- a/src/catlfish_sup.erl
+++ b/src/catlfish_sup.erl
@@ -9,6 +9,21 @@
start_link(_Args) ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
+gen_http_config(Config, SSLOptions, SSLFlag) ->
+ {ChildName, IpAddress, Port, Module} = Config,
+ {ok, IPv4Address} =
+ inet:parse_ipv4strict_address(IpAddress),
+ WebConfig = [{ip, IPv4Address},
+ {port, Port},
+ {ssl, SSLFlag},
+ {acceptor_pool_size, application:get_env(catlfish, http_server_pool_size, 16)},
+ {ssl_opts, SSLOptions}
+ ],
+ {ChildName,
+ {catlfish_web, start, [WebConfig, Module, ChildName]},
+ permanent, 5000,
+ worker, dynamic}.
+
init([]) ->
SSLOptions =
[{certfile, application:get_env(catlfish, https_certfile, none)},
@@ -16,20 +31,11 @@ init([]) ->
{cacertfile, application:get_env(catlfish, https_cacertfile, none)}],
Servers =
lists:map(fun (Config) ->
- {ChildName, IpAddress, Port, Module} = Config,
- {ok, IPv4Address} =
- inet:parse_ipv4strict_address(IpAddress),
- WebConfig = [{ip, IPv4Address},
- {port, Port},
- {ssl, true},
- {acceptor_pool_size, application:get_env(catlfish, http_server_pool_size, 16)},
- {ssl_opts, SSLOptions}
- ],
- {ChildName,
- {catlfish_web, start, [WebConfig, Module]},
- permanent, 5000,
- worker, dynamic}
- end, application:get_env(catlfish, https_servers, [])),
+ gen_http_config(Config, SSLOptions, true)
+ end, application:get_env(catlfish, https_servers, [])) ++
+ lists:map(fun (Config) ->
+ gen_http_config(Config, SSLOptions, false)
+ end, application:get_env(catlfish, http_servers, [])),
lager:debug("Starting servers ~p", [Servers]),
{ok,
{{one_for_one, 3, 10},