aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2025-01-23 13:24:03 +0100
committerLoïc Hoguin <[email protected]>2025-01-23 13:24:03 +0100
commit536aa68ce51354de775f875dd49109ae6fa3a9cb (patch)
treee4a80f9dc7153d1b593fa16a951df35af12a8282 /src
parent7335184d0de59166b68e5b0bbb86ca40c3d4e5d0 (diff)
downloadranch-536aa68ce51354de775f875dd49109ae6fa3a9cb.tar.gz
ranch-536aa68ce51354de775f875dd49109ae6fa3a9cb.tar.bz2
ranch-536aa68ce51354de775f875dd49109ae6fa3a9cb.zip
Fix DTLS
Options invalid for DTLS were given to ssl. Now they are only given for TLS. The {packet,raw} option is no longer set because the default for TLS is the equivalent {packet,0} and DTLS doesn't accept it.
Diffstat (limited to 'src')
-rw-r--r--src/ranch_ssl.erl18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/ranch_ssl.erl b/src/ranch_ssl.erl
index c99335f..0ae8764 100644
--- a/src/ranch_ssl.erl
+++ b/src/ranch_ssl.erl
@@ -135,17 +135,25 @@ listen(TransOpts) ->
end.
do_listen(SocketOpts0, Logger) ->
- SocketOpts1 = ranch:set_option_default(SocketOpts0, backlog, 1024),
- SocketOpts2 = ranch:set_option_default(SocketOpts1, nodelay, true),
- SocketOpts3 = ranch:set_option_default(SocketOpts2, send_timeout, 30000),
- SocketOpts = ranch:set_option_default(SocketOpts3, send_timeout_close, true),
+ SocketOpts = set_default_options(SocketOpts0),
DisallowedOpts0 = disallowed_listen_options(),
DisallowedOpts = unsupported_tls_options(SocketOpts) ++ DisallowedOpts0,
%% We set the port to 0 because it is given in the Opts directly.
%% The port in the options takes precedence over the one in the
%% first argument.
ssl:listen(0, ranch:filter_options(SocketOpts, DisallowedOpts,
- [binary, {active, false}, {packet, raw}, {reuseaddr, true}], Logger)).
+ [binary, {active, false}, {reuseaddr, true}], Logger)).
+
+set_default_options(SocketOpts0) ->
+ case proplists:get_value(protocol, SocketOpts0, tls) of
+ tls ->
+ SocketOpts1 = ranch:set_option_default(SocketOpts0, backlog, 1024),
+ SocketOpts2 = ranch:set_option_default(SocketOpts1, nodelay, true),
+ SocketOpts3 = ranch:set_option_default(SocketOpts2, send_timeout, 30000),
+ ranch:set_option_default(SocketOpts3, send_timeout_close, true);
+ dtls ->
+ SocketOpts0
+ end.
%% 'binary' and 'list' are disallowed but they are handled
%% specifically as they do not have 2-tuple equivalents.