fix
This commit is contained in:
parent
f45b5e4ed4
commit
c820f62a53
@ -1,19 +0,0 @@
|
|||||||
%%%-------------------------------------------------------------------
|
|
||||||
%%% @author anlicheng
|
|
||||||
%%% @copyright (C) 2025, <COMPANY>
|
|
||||||
%%% @doc
|
|
||||||
%%%
|
|
||||||
%%% @end
|
|
||||||
%%% Created : 20. 1月 2025 21:35
|
|
||||||
%%%-------------------------------------------------------------------
|
|
||||||
-author("anlicheng").
|
|
||||||
|
|
||||||
%% ip的使用信息
|
|
||||||
-record(client, {
|
|
||||||
client_id :: binary(),
|
|
||||||
mac :: binary(),
|
|
||||||
ip :: integer(),
|
|
||||||
host_name :: binary(),
|
|
||||||
%% 当前状态
|
|
||||||
status = normal :: normal | disabled
|
|
||||||
}).
|
|
||||||
@ -22,6 +22,8 @@ init() ->
|
|||||||
|
|
||||||
Path = code:priv_dir(sdlan),
|
Path = code:priv_dir(sdlan),
|
||||||
LOptions = #{
|
LOptions = #{
|
||||||
|
addr_family => inet,
|
||||||
|
% 必选:QUIC/TLS证书配置
|
||||||
certfile => Path ++ "/cert.pem",
|
certfile => Path ++ "/cert.pem",
|
||||||
keyfile => Path ++ "/key.pem",
|
keyfile => Path ++ "/key.pem",
|
||||||
alpn => Alpn,
|
alpn => Alpn,
|
||||||
|
|||||||
@ -17,7 +17,6 @@
|
|||||||
dns_erlang,
|
dns_erlang,
|
||||||
pkt,
|
pkt,
|
||||||
quicer,
|
quicer,
|
||||||
mnesia,
|
|
||||||
erts,
|
erts,
|
||||||
public_key,
|
public_key,
|
||||||
ssl,
|
ssl,
|
||||||
|
|||||||
@ -11,8 +11,6 @@
|
|||||||
|
|
||||||
start(_StartType, _StartArgs) ->
|
start(_StartType, _StartArgs) ->
|
||||||
io:setopts([{encoding, unicode}]),
|
io:setopts([{encoding, unicode}]),
|
||||||
%% 启动mnesia数据库
|
|
||||||
mnesia:start(),
|
|
||||||
%% 加速内存的回收
|
%% 加速内存的回收
|
||||||
erlang:system_flag(fullsweep_after, 16),
|
erlang:system_flag(fullsweep_after, 16),
|
||||||
|
|
||||||
|
|||||||
@ -85,10 +85,8 @@ handle_call(_Request, _From, State = #state{}) ->
|
|||||||
{noreply, NewState :: #state{}} |
|
{noreply, NewState :: #state{}} |
|
||||||
{noreply, NewState :: #state{}, timeout() | hibernate} |
|
{noreply, NewState :: #state{}, timeout() | hibernate} |
|
||||||
{stop, Reason :: term(), NewState :: #state{}}).
|
{stop, Reason :: term(), NewState :: #state{}}).
|
||||||
|
|
||||||
%% 当前node下的转发,基于进程间的通讯
|
%% 当前node下的转发,基于进程间的通讯
|
||||||
handle_cast({stun_relay, Ip, Port, Reply}, State = #state{socket = Sock}) ->
|
handle_cast(_Request, State) ->
|
||||||
ok = gen_udp:send(Sock, Ip, Port, Reply),
|
|
||||||
{noreply, State}.
|
{noreply, State}.
|
||||||
|
|
||||||
%% @private
|
%% @private
|
||||||
@ -138,12 +136,6 @@ handle_info({udp, Sock, ClientIp, ClientPort, <<?PACKET_STUN_PROBE:8, Body/binar
|
|||||||
end,
|
end,
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
|
|
||||||
%% 转发消息, 跨服务器的stun_reply的转发通过socket来转发
|
|
||||||
handle_info({udp, Sock, _, _, <<?PACKET_STUN_PROBE_RELAY:8, Ip0, Ip1, Ip2, Ip3, Port:16, Reply/binary>>}, State = #state{socket = Sock}) ->
|
|
||||||
logger:debug("[sdlan_stun] get stun_probe_replay request, reply: ~p", [Reply]),
|
|
||||||
gen_udp:send(Sock, {Ip0, Ip1, Ip2, Ip3}, Port, Reply),
|
|
||||||
{noreply, State};
|
|
||||||
|
|
||||||
handle_info({udp, _, _Ip, _Port, <<?PACKET_STUN_DATA, Body/binary>>}, State = #state{socket = Sock}) ->
|
handle_info({udp, _, _Ip, _Port, <<?PACKET_STUN_DATA, Body/binary>>}, State = #state{socket = Sock}) ->
|
||||||
Data = catch sdlan_pb:decode_msg(Body, sdl_data),
|
Data = catch sdlan_pb:decode_msg(Body, sdl_data),
|
||||||
maybe
|
maybe
|
||||||
|
|||||||
@ -58,7 +58,6 @@ init([]) ->
|
|||||||
{ok, Socket} = gen_udp:open(0, Opts),
|
{ok, Socket} = gen_udp:open(0, Opts),
|
||||||
inet_udp:controlling_process(Socket, self()),
|
inet_udp:controlling_process(Socket, self()),
|
||||||
logger:debug("[sdlan_stun_peer_assist] started"),
|
logger:debug("[sdlan_stun_peer_assist] started"),
|
||||||
|
|
||||||
{ok, #state{socket = Socket, assist_ip = AssistIp, assist_port = AssistPort}}.
|
{ok, #state{socket = Socket, assist_ip = AssistIp, assist_port = AssistPort}}.
|
||||||
|
|
||||||
%% @private
|
%% @private
|
||||||
|
|||||||
@ -1,18 +0,0 @@
|
|||||||
%%%-------------------------------------------------------------------
|
|
||||||
%%% @author anlicheng
|
|
||||||
%%% @copyright (C) 2024, <COMPANY>
|
|
||||||
%%% @doc
|
|
||||||
%%%
|
|
||||||
%%% @end
|
|
||||||
%%% Created : 09. 3月 2024 15:25
|
|
||||||
%%%-------------------------------------------------------------------
|
|
||||||
-module(sdlan_test).
|
|
||||||
-author("anlicheng").
|
|
||||||
|
|
||||||
%% API
|
|
||||||
-export([test/1]).
|
|
||||||
|
|
||||||
test(X) when X band 1 == 0 ->
|
|
||||||
ok;
|
|
||||||
test(_) ->
|
|
||||||
error.
|
|
||||||
Loading…
x
Reference in New Issue
Block a user