sdlan/message.proto
2026-02-13 14:11:44 +08:00

174 lines
4.2 KiB
Protocol Buffer
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

syntax = "proto3";
// 基础公共类型定义
message SDLV4Info {
uint32 port = 1;
bytes v4 = 2;
uint32 nat_type = 3;
}
message SDLV6Info {
uint32 port = 1;
bytes v6 = 2;
}
// 和super之间采用了quic协议通讯
// 传输层采用: <<Len:16, Data/binary>>
// 数据层采用: <<PacketId:32, PacketType:8, Payload/binary>>
// quic 通讯消息
message SDLEmpty {
}
// 这里修改成了扁平的结构, 否则有些字段不好找放的位置
message SDLRegisterSuper {
uint32 version = 1;
string client_id = 2;
// 网络地址信息已经有https请求分配了
// 注册的时候需要带上(network_id, mac, ip, mask_len, hostname)
uint32 network_id = 3;
bytes mac = 4;
uint32 ip = 5;
uint32 mask_len = 6;
string hostname = 7;
string pub_key = 8;
// 客户端使用http协议请求后端通过token或者账号密码登录时, 统一返回一个access_token;
// RegisterSuper的时候验证凭证是否合法 (access_token)
string access_token = 9;
}
// 客户端的升级逻辑在https的接口里面去完成
// 部分逻辑会脱离quic去通讯增加session_token校验
message SDLRegisterSuperAck {
bytes aes_key = 1;
bytes session_token = 2;
}
message SDLRegisterSuperNak {
uint32 error_code = 1;
string error_message = 2;
}
// 网络地址查询
message SDLQueryInfo {
bytes dst_mac = 1;
}
message SDLPeerInfo {
bytes dst_mac = 1;
SDLV4Info v4_info = 2;
optional SDLV6Info v6_info = 3;
}
// ARP查询相关
// 真实的arp请求是通过广播的形式获取到的但是针对于macos这种tun的实现是能够分析出arp请求包的
// 对于当前网络来说服务端是知道mac对应的ip地址的因此没有必要广播直接通过服务器端返回
message SDLArpRequest {
uint32 target_ip = 1;
}
message SDLArpResponse {
uint32 target_ip = 1;
bytes target_mac = 2;
}
// 权限请求查询相关
message SDLPolicyRequest {
uint32 src_identity_id = 1;
uint32 dst_identity_id = 2;
uint32 version = 3;
}
// 基于quic通讯rules部分已经没有了长度限制
message SDLPolicyResponse {
uint32 src_identity_id = 1;
uint32 dst_identity_id = 2;
// 版本号,客户端需要比较版本号确定是否覆盖; 请求端自己去管理版本号,服务端只是原样回写
uint32 version = 3;
// 4+1+2 的稀疏序列化规则
bytes rules = 4;
}
// 事件定义
message SDLNatChangedEvent {
bytes mac = 1;
uint32 ip = 2;
}
message SDLSendRegisterEvent {
bytes dst_mac = 1;
uint32 nat_ip = 2;
uint32 nat_port = 3;
uint32 nat_type = 4;
optional SDLV6Info v6_info = 5;
}
message SDLNetworkShutdownEvent {
string message = 1;
}
// UDP通讯消息
// client和stun之间的心跳包客户端需要和super的udp之间的存活逻辑
message SDLStunRequest {
uint32 cookie = 1;
string client_id = 2;
uint32 network_id = 3;
bytes mac = 4;
uint32 ip = 5;
uint32 nat_type = 6;
optional SDLV6Info v6_info = 7;
}
message SDLStunReply {
uint32 cookie = 1;
}
message SDLData {
uint32 network_id = 1;
bytes src_mac = 2;
bytes dst_mac = 3;
bool is_p2p = 4;
uint32 ttl = 5;
bytes data = 6;
bytes session_token = 7;
// 端通过https登录的时候服务端会分配该端对应的权限标识
// 后续的请求过程中需要带上这个值,对端通过这个值要判断对数据包是否放行
uint32 identity_id = 8;
}
// 网络类型探测
message SDLStunProbe {
uint32 cookie = 1;
uint32 attr = 2;
// 增加step是为了方便端上判断收到的请求和响应之间的映射关系服务器端原样返回
uint32 step = 3;
}
message SDLStunProbeReply {
uint32 cookie = 1;
// 增加step是为了方便端上判断收到的请求和响应之间的映射关系服务器端原样返回
uint32 step = 2;
uint32 port = 3;
uint32 ip = 4;
}
// Node-Node之间的握手逻辑, 是基于udp传输的
message SDLRegister {
uint32 network_id = 1;
bytes src_mac = 2;
bytes dst_mac = 3;
}
message SDLRegisterAck {
uint32 network_id = 1;
bytes src_mac = 2;
bytes dst_mac = 3;
}