This is an automated email from the ASF dual-hosted git repository. jan pushed a commit to branch feat/ssl-server-options in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 6d550148f5944f2dc3adc1bb73ad639d08905c0f Author: Jan Lehnardt <[email protected]> AuthorDate: Fri Jun 29 19:31:44 2018 +0200 allow socket server configuration for TLS httpd --- src/chttpd/src/chttpd.erl | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/chttpd/src/chttpd.erl b/src/chttpd/src/chttpd.erl index ae94ae6..c0179ba 100644 --- a/src/chttpd/src/chttpd.erl +++ b/src/chttpd/src/chttpd.erl @@ -104,10 +104,12 @@ start_link(https) -> end, SslOpts = ServerOpts ++ ClientOpts, - Options = + Options0 = [{port, Port}, {ssl, true}, {ssl_opts, SslOpts}], + CustomServerOpts = get_server_options("httpsd"), + Options = merge_server_options(Options0, CustomServerOpts), start_link(https, Options). start_link(Name, Options) -> @@ -124,9 +126,8 @@ start_link(Name, Options) -> {name, Name}, {ip, IP} ], - ServerOptsCfg = config:get("chttpd", "server_options", "[]"), - {ok, ServerOpts} = couch_util:parse_term(ServerOptsCfg), - Options2 = lists:keymerge(1, lists:sort(Options1), lists:sort(ServerOpts)), + ServerOpts = get_server_options("chttpd"), + Options2 = merge_server_options(Options1, ServerOpts), case mochiweb_http:start(Options2) of {ok, Pid} -> {ok, Pid}; @@ -135,6 +136,14 @@ start_link(Name, Options) -> {error, Reason} end. +get_server_options(Module) -> + ServerOptsCfg = config:get(Module, "server_options", "[]"), + {ok, ServerOpts} = couch_util:parse_term(ServerOptsCfg), + ServerOpts. + +merge_server_options(A, B) -> + lists:keymerge(1, lists:sort(A), lists:sort(B)). + stop() -> catch mochiweb_http:stop(https), mochiweb_http:stop(?MODULE).
