Skip to content

Commit

Permalink
Fix dtls listen on ipv6 with default ip
Browse files Browse the repository at this point in the history
IP adress always defaulted to {0,0,0,0} even for ipv6 connections,
which caused a single entry if you where listening on both stacks.

Fixes erlang#7955
  • Loading branch information
dgud committed Mar 20, 2024
1 parent 777936c commit 2c70066
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/ssl/src/dtls_socket.erl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ listen(Port, #config{inet_ssl = SockOpts,
ssl = SslOpts,
emulated = EmOpts,
inet_user = Options} = Config) ->
IP = proplists:get_value(ip, SockOpts, {0,0,0,0}),
DefIP = case proplists:get_value(inet6, SockOpts, false) of
false -> {0,0,0,0};
true -> {0,0,0,0, 0,0,0,0}
end,
IP = proplists:get_value(ip, SockOpts, DefIP),
case dtls_listener_sup:lookup_listener(IP, Port) of
undefined ->
start_new_listener(IP, Port, Config);
Expand Down Expand Up @@ -96,10 +100,14 @@ connect(Address, Port, #config{transport_info = {Transport, _, _, _, _} = CbInfo

close(#sslsocket{pid = {dtls, #config{dtls_handler = {Pid, Port0},
inet_ssl = SockOpts}}}) ->
IP = proplists:get_value(ip, SockOpts, {0,0,0,0}),
DefIP = case proplists:get_value(inet6, SockOpts, false) of
false -> {0,0,0,0};
true -> {0,0,0,0, 0,0,0,0}
end,
IP = proplists:get_value(ip, SockOpts, DefIP),
Port = get_real_port(Pid, Port0),
dtls_listener_sup:register_listener({undefined, Pid}, IP, Port),
dtls_packet_demux:close(Pid).
dtls_packet_demux:close(Pid).

close(_, dtls) ->
ok;
Expand Down

0 comments on commit 2c70066

Please sign in to comment.