This commit is contained in:
anlicheng 2026-02-21 22:44:48 +08:00
parent 2cc9bdadc1
commit 159586da72

View File

@ -95,7 +95,6 @@ handle_cast(_Request, State) ->
{noreply, NewState :: #state{}} |
{noreply, NewState :: #state{}, timeout() | hibernate} |
{stop, Reason :: term(), NewState :: #state{}}).
handle_info({udp, Sock, Ip, Port, <<?PACKET_STUN_REQUEST:8, Body/binary>>}, State = #state{socket = Sock}) ->
StunRequest = catch sdlan_pb:decode_msg(Body, sdl_stun_request),
%% ip对应的nat的映射关系
@ -106,7 +105,11 @@ handle_info({udp, Sock, Ip, Port, <<?PACKET_STUN_REQUEST:8, Body/binary>>}, Stat
StunReply = sdlan_pb:encode_msg(#sdl_stun_reply{
cookie = Cookie
}),
ok = gen_udp:send(Sock, Ip, Port, <<?PACKET_STUN_REPLY, StunReply/binary>>),
logger:debug("[sdlan_stun] xyz, reply size: ~p", [byte_size(StunReply)]),
ok = gen_udp:send(Sock, Ip, Port, <<?PACKET_STUN_REPLY:8, StunReply/binary>>),
logger:debug("[sdlan_stun] stun_request network_id: ~p, client_id: ~p, hole: ~p, bytes: ~p", [NetworkId, ClientId, {Ip, Port}, byte_size(<<?PACKET_STUN_REPLY, StunReply/binary>>)])
end,
{noreply, State};