aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_ssl_transport.erl
diff options
context:
space:
mode:
authorHunter Morris <[email protected]>2011-06-21 13:39:06 +0100
committerHunter Morris <[email protected]>2011-06-21 16:02:33 +0100
commit5f438561e9cb3656f289c6c438b3f8a8dfaf5c66 (patch)
tree37cc94a08a57224c120f4b60abe9fb42dd5f8688 /src/cowboy_ssl_transport.erl
parenta93eb026465261cb7f0f7bc80e3bfadca69e7709 (diff)
downloadcowboy-5f438561e9cb3656f289c6c438b3f8a8dfaf5c66.tar.gz
cowboy-5f438561e9cb3656f289c6c438b3f8a8dfaf5c66.tar.bz2
cowboy-5f438561e9cb3656f289c6c438b3f8a8dfaf5c66.zip
Pass {ip, Ip} configuration through for TCP and SSL transports
Diffstat (limited to 'src/cowboy_ssl_transport.erl')
-rw-r--r--src/cowboy_ssl_transport.erl13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/cowboy_ssl_transport.erl b/src/cowboy_ssl_transport.erl
index ea3f482..8e569ec 100644
--- a/src/cowboy_ssl_transport.erl
+++ b/src/cowboy_ssl_transport.erl
@@ -25,7 +25,8 @@ name() -> ssl.
messages() -> {ssl, ssl_closed, ssl_error}.
-spec listen([{port, inet:ip_port()} | {certfile, string()}
- | {keyfile, string()} | {password, string()}])
+ | {keyfile, string()} | {password, string()}
+ | {ip, inet:ip_address()}])
-> {ok, ssl:sslsocket()} | {error, atom()}.
listen(Opts) ->
require([crypto, public_key, ssl]),
@@ -34,9 +35,15 @@ listen(Opts) ->
{certfile, CertFile} = lists:keyfind(certfile, 1, Opts),
{keyfile, KeyFile} = lists:keyfind(keyfile, 1, Opts),
{password, Password} = lists:keyfind(password, 1, Opts),
- ssl:listen(Port, [binary, {active, false},
+ ListenOpts0 = [binary, {active, false},
{backlog, Backlog}, {packet, raw}, {reuseaddr, true},
- {certfile, CertFile}, {keyfile, KeyFile}, {password, Password}]).
+ {certfile, CertFile}, {keyfile, KeyFile}, {password, Password}],
+ ListenOpts =
+ case lists:keyfind(ip, 1, Opts) of
+ false -> ListenOpts0;
+ Ip -> [Ip|ListenOpts0]
+ end,
+ ssl:listen(Port, ListenOpts).
-spec accept(ssl:sslsocket(), timeout())
-> {ok, ssl:sslsocket()} | {error, closed | timeout | atom()}.