change protoc-erl to gpb plugin
This commit is contained in:
parent
2132f45dae
commit
e01916fabf
@ -1,221 +0,0 @@
|
|||||||
%% -*- coding: utf-8 -*-
|
|
||||||
%% Automatically generated, do not edit
|
|
||||||
%% Generated by gpb_compile version 4.21.1
|
|
||||||
|
|
||||||
-ifndef(sdlan_pb).
|
|
||||||
-define(sdlan_pb, true).
|
|
||||||
|
|
||||||
-define(sdlan_pb_gpb_version, "4.21.1").
|
|
||||||
|
|
||||||
|
|
||||||
-ifndef('SDLV_4_INFO_PB_H').
|
|
||||||
-define('SDLV_4_INFO_PB_H', true).
|
|
||||||
-record(sdl_v4_info,
|
|
||||||
{port = 0 :: non_neg_integer() | undefined, % = 1, optional, 32 bits
|
|
||||||
v4 = <<>> :: iodata() | undefined, % = 2, optional
|
|
||||||
nat_type = 0 :: non_neg_integer() | undefined % = 3, optional, 32 bits
|
|
||||||
}).
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
-ifndef('SDLV_6_INFO_PB_H').
|
|
||||||
-define('SDLV_6_INFO_PB_H', true).
|
|
||||||
-record(sdl_v6_info,
|
|
||||||
{port = 0 :: non_neg_integer() | undefined, % = 1, optional, 32 bits
|
|
||||||
v6 = <<>> :: iodata() | undefined % = 2, optional
|
|
||||||
}).
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
-ifndef('SDL_WELCOME_PB_H').
|
|
||||||
-define('SDL_WELCOME_PB_H', true).
|
|
||||||
-record(sdl_welcome,
|
|
||||||
{version = 0 :: non_neg_integer() | undefined, % = 1, optional, 32 bits
|
|
||||||
max_bidi_streams = 0 :: non_neg_integer() | undefined, % = 2, optional, 32 bits
|
|
||||||
max_packet_size = 0 :: non_neg_integer() | undefined, % = 3, optional, 32 bits
|
|
||||||
heartbeat_sec = 0 :: non_neg_integer() | undefined % = 4, optional, 32 bits
|
|
||||||
}).
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
-ifndef('SDL_REGISTER_SUPER_PB_H').
|
|
||||||
-define('SDL_REGISTER_SUPER_PB_H', true).
|
|
||||||
-record(sdl_register_super,
|
|
||||||
{client_id = <<>> :: unicode:chardata() | undefined, % = 1, optional
|
|
||||||
network_id = 0 :: non_neg_integer() | undefined, % = 2, optional, 32 bits
|
|
||||||
mac = <<>> :: iodata() | undefined, % = 3, optional
|
|
||||||
ip = 0 :: non_neg_integer() | undefined, % = 4, optional, 32 bits
|
|
||||||
mask_len = 0 :: non_neg_integer() | undefined, % = 5, optional, 32 bits
|
|
||||||
hostname = <<>> :: unicode:chardata() | undefined, % = 6, optional
|
|
||||||
pub_key = <<>> :: unicode:chardata() | undefined, % = 7, optional
|
|
||||||
access_token = <<>> :: unicode:chardata() | undefined % = 8, optional
|
|
||||||
}).
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
-ifndef('SDL_REGISTER_SUPER_ACK_PB_H').
|
|
||||||
-define('SDL_REGISTER_SUPER_ACK_PB_H', true).
|
|
||||||
-record(sdl_register_super_ack,
|
|
||||||
{algorithm = <<>> :: unicode:chardata() | undefined, % = 1, optional
|
|
||||||
key = <<>> :: iodata() | undefined, % = 2, optional
|
|
||||||
region_id = 0 :: non_neg_integer() | undefined, % = 3, optional, 32 bits
|
|
||||||
session_token = <<>> :: iodata() | undefined % = 4, optional
|
|
||||||
}).
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
-ifndef('SDL_REGISTER_SUPER_NAK_PB_H').
|
|
||||||
-define('SDL_REGISTER_SUPER_NAK_PB_H', true).
|
|
||||||
-record(sdl_register_super_nak,
|
|
||||||
{error_code = 0 :: non_neg_integer() | undefined, % = 1, optional, 32 bits
|
|
||||||
error_message = <<>> :: unicode:chardata() | undefined % = 2, optional
|
|
||||||
}).
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
-ifndef('SDL_QUERY_INFO_PB_H').
|
|
||||||
-define('SDL_QUERY_INFO_PB_H', true).
|
|
||||||
-record(sdl_query_info,
|
|
||||||
{dst_mac = <<>> :: iodata() | undefined % = 1, optional
|
|
||||||
}).
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
-ifndef('SDL_PEER_INFO_PB_H').
|
|
||||||
-define('SDL_PEER_INFO_PB_H', true).
|
|
||||||
-record(sdl_peer_info,
|
|
||||||
{dst_mac = <<>> :: iodata() | undefined, % = 1, optional
|
|
||||||
v4_info :: sdlan_pb:sdl_v4_info() | undefined, % = 2, optional
|
|
||||||
v6_info :: sdlan_pb:sdl_v6_info() | undefined % = 3, optional
|
|
||||||
}).
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
-ifndef('SDL_ARP_REQUEST_PB_H').
|
|
||||||
-define('SDL_ARP_REQUEST_PB_H', true).
|
|
||||||
-record(sdl_arp_request,
|
|
||||||
{target_ip = 0 :: non_neg_integer() | undefined, % = 1, optional, 32 bits
|
|
||||||
origin_ip = 0 :: non_neg_integer() | undefined, % = 2, optional, 32 bits
|
|
||||||
context = <<>> :: iodata() | undefined % = 3, optional
|
|
||||||
}).
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
-ifndef('SDL_ARP_RESPONSE_PB_H').
|
|
||||||
-define('SDL_ARP_RESPONSE_PB_H', true).
|
|
||||||
-record(sdl_arp_response,
|
|
||||||
{target_ip = 0 :: non_neg_integer() | undefined, % = 1, optional, 32 bits
|
|
||||||
target_mac = <<>> :: iodata() | undefined, % = 2, optional
|
|
||||||
origin_ip = 0 :: non_neg_integer() | undefined, % = 3, optional, 32 bits
|
|
||||||
context = <<>> :: iodata() | undefined % = 4, optional
|
|
||||||
}).
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
-ifndef('SDL_POLICY_REQUEST_PB_H').
|
|
||||||
-define('SDL_POLICY_REQUEST_PB_H', true).
|
|
||||||
-record(sdl_policy_request,
|
|
||||||
{src_identity_id = 0 :: non_neg_integer() | undefined, % = 1, optional, 32 bits
|
|
||||||
dst_identity_id = 0 :: non_neg_integer() | undefined, % = 2, optional, 32 bits
|
|
||||||
version = 0 :: non_neg_integer() | undefined % = 3, optional, 32 bits
|
|
||||||
}).
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
-ifndef('SDL_POLICY_RESPONSE_PB_H').
|
|
||||||
-define('SDL_POLICY_RESPONSE_PB_H', true).
|
|
||||||
-record(sdl_policy_response,
|
|
||||||
{src_identity_id = 0 :: non_neg_integer() | undefined, % = 1, optional, 32 bits
|
|
||||||
dst_identity_id = 0 :: non_neg_integer() | undefined, % = 2, optional, 32 bits
|
|
||||||
version = 0 :: non_neg_integer() | undefined, % = 3, optional, 32 bits
|
|
||||||
rules = <<>> :: iodata() | undefined % = 4, optional
|
|
||||||
}).
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
-ifndef('SDL_NAT_CHANGED_EVENT_PB_H').
|
|
||||||
-define('SDL_NAT_CHANGED_EVENT_PB_H', true).
|
|
||||||
-record(sdl_nat_changed_event,
|
|
||||||
{mac = <<>> :: iodata() | undefined, % = 1, optional
|
|
||||||
ip = 0 :: non_neg_integer() | undefined % = 2, optional, 32 bits
|
|
||||||
}).
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
-ifndef('SDL_SEND_REGISTER_EVENT_PB_H').
|
|
||||||
-define('SDL_SEND_REGISTER_EVENT_PB_H', true).
|
|
||||||
-record(sdl_send_register_event,
|
|
||||||
{dst_mac = <<>> :: iodata() | undefined, % = 1, optional
|
|
||||||
nat_ip = 0 :: non_neg_integer() | undefined, % = 2, optional, 32 bits
|
|
||||||
nat_port = 0 :: non_neg_integer() | undefined, % = 3, optional, 32 bits
|
|
||||||
nat_type = 0 :: non_neg_integer() | undefined, % = 4, optional, 32 bits
|
|
||||||
v6_info :: sdlan_pb:sdl_v6_info() | undefined % = 5, optional
|
|
||||||
}).
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
-ifndef('SDL_NETWORK_SHUTDOWN_EVENT_PB_H').
|
|
||||||
-define('SDL_NETWORK_SHUTDOWN_EVENT_PB_H', true).
|
|
||||||
-record(sdl_network_shutdown_event,
|
|
||||||
{message = <<>> :: unicode:chardata() | undefined % = 1, optional
|
|
||||||
}).
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
-ifndef('SDL_STUN_REQUEST_PB_H').
|
|
||||||
-define('SDL_STUN_REQUEST_PB_H', true).
|
|
||||||
-record(sdl_stun_request,
|
|
||||||
{client_id = <<>> :: unicode:chardata() | undefined, % = 1, optional
|
|
||||||
network_id = 0 :: non_neg_integer() | undefined, % = 2, optional, 32 bits
|
|
||||||
mac = <<>> :: iodata() | undefined, % = 3, optional
|
|
||||||
ip = 0 :: non_neg_integer() | undefined, % = 4, optional, 32 bits
|
|
||||||
nat_type = 0 :: non_neg_integer() | undefined, % = 5, optional, 32 bits
|
|
||||||
v6_info :: sdlan_pb:sdl_v6_info() | undefined, % = 6, optional
|
|
||||||
session_token = <<>> :: iodata() | undefined % = 7, optional
|
|
||||||
}).
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
-ifndef('SDL_STUN_REPLY_PB_H').
|
|
||||||
-define('SDL_STUN_REPLY_PB_H', true).
|
|
||||||
-record(sdl_stun_reply,
|
|
||||||
{
|
|
||||||
}).
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
-ifndef('SDL_DATA_PB_H').
|
|
||||||
-define('SDL_DATA_PB_H', true).
|
|
||||||
-record(sdl_data,
|
|
||||||
{network_id = 0 :: non_neg_integer() | undefined, % = 1, optional, 32 bits
|
|
||||||
src_mac = <<>> :: iodata() | undefined, % = 2, optional
|
|
||||||
dst_mac = <<>> :: iodata() | undefined, % = 3, optional
|
|
||||||
is_p2p = false :: boolean() | 0 | 1 | undefined, % = 4, optional
|
|
||||||
ttl = 0 :: non_neg_integer() | undefined, % = 5, optional, 32 bits
|
|
||||||
data = <<>> :: iodata() | undefined, % = 6, optional
|
|
||||||
session_token = <<>> :: iodata() | undefined, % = 7, optional
|
|
||||||
identity_id = 0 :: non_neg_integer() | undefined % = 8, optional, 32 bits
|
|
||||||
}).
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
-ifndef('SDL_STUN_PROBE_PB_H').
|
|
||||||
-define('SDL_STUN_PROBE_PB_H', true).
|
|
||||||
-record(sdl_stun_probe,
|
|
||||||
{cookie = 0 :: non_neg_integer() | undefined, % = 1, optional, 32 bits
|
|
||||||
attr = 0 :: non_neg_integer() | undefined, % = 2, optional, 32 bits
|
|
||||||
step = 0 :: non_neg_integer() | undefined % = 3, optional, 32 bits
|
|
||||||
}).
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
-ifndef('SDL_STUN_PROBE_REPLY_PB_H').
|
|
||||||
-define('SDL_STUN_PROBE_REPLY_PB_H', true).
|
|
||||||
-record(sdl_stun_probe_reply,
|
|
||||||
{cookie = 0 :: non_neg_integer() | undefined, % = 1, optional, 32 bits
|
|
||||||
step = 0 :: non_neg_integer() | undefined, % = 2, optional, 32 bits
|
|
||||||
port = 0 :: non_neg_integer() | undefined, % = 3, optional, 32 bits
|
|
||||||
ip = 0 :: non_neg_integer() | undefined % = 4, optional, 32 bits
|
|
||||||
}).
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
-ifndef('SDL_REGISTER_PB_H').
|
|
||||||
-define('SDL_REGISTER_PB_H', true).
|
|
||||||
-record(sdl_register,
|
|
||||||
{network_id = 0 :: non_neg_integer() | undefined, % = 1, optional, 32 bits
|
|
||||||
src_mac = <<>> :: iodata() | undefined, % = 2, optional
|
|
||||||
dst_mac = <<>> :: iodata() | undefined % = 3, optional
|
|
||||||
}).
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
-ifndef('SDL_REGISTER_ACK_PB_H').
|
|
||||||
-define('SDL_REGISTER_ACK_PB_H', true).
|
|
||||||
-record(sdl_register_ack,
|
|
||||||
{network_id = 0 :: non_neg_integer() | undefined, % = 1, optional, 32 bits
|
|
||||||
src_mac = <<>> :: iodata() | undefined, % = 2, optional
|
|
||||||
dst_mac = <<>> :: iodata() | undefined % = 3, optional
|
|
||||||
}).
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
-endif.
|
|
||||||
@ -206,10 +206,21 @@ handle_call({attach, ChannelPid, ClientId, Mac, Ip, Hostname}, _From,
|
|||||||
maybe
|
maybe
|
||||||
{ok, #endpoint{ip = OldIp, channel_pid = OldChannelPid, channel_ref = OldChannelRef}} ?= maps:find(Mac, Endpoints),
|
{ok, #endpoint{ip = OldIp, channel_pid = OldChannelPid, channel_ref = OldChannelRef}} ?= maps:find(Mac, Endpoints),
|
||||||
true ?= OldIp =/= Ip,
|
true ?= OldIp =/= Ip,
|
||||||
NatChangedEvent = sdlan_pb:encode_msg(#sdl_nat_changed_event{
|
|
||||||
mac = Mac,
|
#sdl_event {
|
||||||
ip = Ip
|
event = {nat_changed, #'sdl_event.nat_changed' {
|
||||||
|
mac = Mac,
|
||||||
|
ip = Ip
|
||||||
|
}}
|
||||||
|
},
|
||||||
|
|
||||||
|
Event = sdlan_pb:encode_msg(#sdl_event {
|
||||||
|
event = {nat_changed, #'sdl_event.nat_changed' {
|
||||||
|
mac = Mac,
|
||||||
|
ip = Ip
|
||||||
|
}}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
broadcast(fun(#endpoint{channel_pid = ChannelPid0}) ->
|
broadcast(fun(#endpoint{channel_pid = ChannelPid0}) ->
|
||||||
sdlan_quic_channel:send_event(ChannelPid0, ?EVENT_NAT_CHANGED, NatChangedEvent)
|
sdlan_quic_channel:send_event(ChannelPid0, ?EVENT_NAT_CHANGED, NatChangedEvent)
|
||||||
end, [Mac], Endpoints),
|
end, [Mac], Endpoints),
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
21
rebar.config
21
rebar.config
@ -1,6 +1,20 @@
|
|||||||
{erl_opts, [
|
{erl_opts, [
|
||||||
debug_info
|
debug_info
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
{plugins, [
|
||||||
|
{rebar3_gpb_plugin, ".*", {git, "https://github.com/lrascao/rebar3_gpb_plugin.git", {tag, "2.23.8"}}}
|
||||||
|
]}.
|
||||||
|
|
||||||
|
{gpb_opts, [
|
||||||
|
{i, "proto"}, % proto 文件目录
|
||||||
|
{module_name_suffix, "_pb"}, % 生成 xxx_pb.erl
|
||||||
|
{o_erl, "apps/sdlan/src"}, % .erl 输出到 src
|
||||||
|
{o_hrl, "apps/sdlan/include"}, % .hrl 输出到 include
|
||||||
|
{strings_as_binaries, true},
|
||||||
|
type_specs
|
||||||
|
]}.
|
||||||
|
|
||||||
{deps, [
|
{deps, [
|
||||||
{poolboy, ".*", {git, "https://github.com/devinus/poolboy.git", {tag, "1.5.1"}}},
|
{poolboy, ".*", {git, "https://github.com/devinus/poolboy.git", {tag, "1.5.1"}}},
|
||||||
{hackney, ".*", {git, "https://github.com/benoitc/hackney.git", {tag, "1.16.0"}}},
|
{hackney, ".*", {git, "https://github.com/benoitc/hackney.git", {tag, "1.16.0"}}},
|
||||||
@ -15,6 +29,13 @@
|
|||||||
{sync, ".*", {git, "https://github.com/rustyio/sync.git", {branch, "master"}}}
|
{sync, ".*", {git, "https://github.com/rustyio/sync.git", {branch, "master"}}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
{provider_hooks, [
|
||||||
|
{pre, [
|
||||||
|
{compile, {protobuf, compile}},
|
||||||
|
{clean, {protobuf, clean}}
|
||||||
|
]}
|
||||||
|
]}.
|
||||||
|
|
||||||
{relx, [{release, {sdlan, "0.1.0"},
|
{relx, [{release, {sdlan, "0.1.0"},
|
||||||
[sdlan,
|
[sdlan,
|
||||||
sasl]},
|
sasl]},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user