fix
This commit is contained in:
parent
be855d6985
commit
8d94244689
@ -117,7 +117,7 @@ handle_cast(_Msg, State) ->
|
||||
|
||||
%% 带上token或者网络id来注册
|
||||
handle_info({tcp, Sock, <<PacketId:32, ?PACKET_REGISTER_SUPER, Body/binary>>}, State=#state{transport = Transport, socket = Sock}) ->
|
||||
#sdl_register_super{version = Version, client_id = ClientId, hostname = HostName, dev_addr = #sdl_dev_addr{net_addr = NetAddr0, mac = Mac}, network_code = NetworkCode, token = Token, pub_key = PubKey} = sdlan_pb:decode_msg(Body, sdl_register_super),
|
||||
#sdl_register_super{version = Version, client_id = ClientId, dev_addr = #sdl_dev_addr{mac = Mac}, network_code = NetworkCode, token = Token, pub_key = PubKey} = sdlan_pb:decode_msg(Body, sdl_register_super),
|
||||
|
||||
%% 参数检查
|
||||
lager:debug("[sdlan_channel] client_id: ~p, public_key: ~p, token: ~p, network_code: ~p", [ClientId, PubKey, Token, NetworkCode]),
|
||||
@ -140,7 +140,7 @@ handle_info({tcp, Sock, <<PacketId:32, ?PACKET_REGISTER_SUPER, Body/binary>>}, S
|
||||
%% 建立到network的对应关系
|
||||
case sdlan_network:get_pid(NetworkId) of
|
||||
NetworkPid when is_pid(NetworkPid) ->
|
||||
try sdlan_network:assign_ip_addr(NetworkPid, self(), ClientId, Mac, NetAddr0, HostName) of
|
||||
try sdlan_network:assign_ip_addr(NetworkPid, self(), ClientId, Mac) of
|
||||
{ok, Domain, NetAddr, NetBitLen, AesKey} ->
|
||||
RsaPubKey = sdlan_cipher:rsa_pem_decode(PubKey),
|
||||
EncodedAesKey = rsa_encode(AesKey, RsaPubKey),
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
|
||||
%% API
|
||||
-export([start_link/2]).
|
||||
-export([get_name/1, get_pid/1, assign_ip_addr/6, peer_info/3, unregister/3, debug_info/1, get_network_id/1, get_used_map/1]).
|
||||
-export([get_name/1, get_pid/1, assign_ip_addr/4, peer_info/3, unregister/3, debug_info/1, get_network_id/1, get_used_map/1]).
|
||||
-export([forward/5, update_hole/6, disable_client/2, get_channel/2, dropout_client/2]).
|
||||
-export([test_event/1]).
|
||||
|
||||
@ -81,10 +81,10 @@ get_pid(Id) when is_integer(Id) ->
|
||||
get_name(Id) when is_integer(Id) ->
|
||||
list_to_atom("sdlan_network:" ++ integer_to_list(Id)).
|
||||
|
||||
-spec assign_ip_addr(Pid :: pid(), ChannelPid :: pid(), ClientId :: binary(), Mac :: binary(), NetAddr :: integer(), HostName :: binary()) ->
|
||||
-spec assign_ip_addr(Pid :: pid(), ChannelPid :: pid(), ClientId :: binary(), Mac :: binary()) ->
|
||||
{ok, Domain :: binary(), NetAddr :: integer(), MaskLen :: integer(), AesKey :: binary()} | {error, Reason :: any()}.
|
||||
assign_ip_addr(Pid, ChannelPid, ClientId, Mac, NetAddr, HostName) when is_pid(Pid), is_pid(ChannelPid), is_binary(ClientId), is_binary(Mac), is_integer(NetAddr) ->
|
||||
gen_server:call(Pid, {assign_ip_addr, ChannelPid, ClientId, Mac, NetAddr, HostName}).
|
||||
assign_ip_addr(Pid, ChannelPid, ClientId, Mac) when is_pid(Pid), is_pid(ChannelPid), is_binary(ClientId), is_binary(Mac) ->
|
||||
gen_server:call(Pid, {assign_ip_addr, ChannelPid, ClientId, Mac}).
|
||||
|
||||
-spec get_network_id(Pid :: pid()) -> {ok, NetworkId :: integer()}.
|
||||
get_network_id(Pid) when is_pid(Pid) ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user