added encode error

This commit is contained in:
asxalex 2024-06-20 23:02:44 +08:00
parent f9a5cc3986
commit f320526f2d
4 changed files with 14 additions and 2 deletions

View File

@ -13,6 +13,7 @@ dashmap = "5.5.3"
futures = "0.3.30"
# lazy_static = "1.4.0"
once_cell = "1.19.0"
prost = "0.12.6"
rand = "0.8.5"
rolling-file = { git = "https://git.asxalex.pw/rust/rolling-file" }
rsa = "0.9.6"

View File

@ -219,4 +219,7 @@ POST /peer/unauthorize
// 如果code不为0则error表示出错信息
"error": $string
}
```
```
# 2.0 sdlan中心节点使用的数据库结构
在中心节点收到客户端上线请求之后,如果这个节点是第一次上线,则会将相关信息插入到

View File

@ -26,7 +26,7 @@ sdlan协议的总体格式如下
其中version占用一个字节用于标识协议版本。id用于唯一标识某个客户端为长度为32字节的uuidtoken是用户生成的邀请码占用8个字节(64比特的大端序整型数字)。之后的ttl占用一个字节当ttl为0则直接丢弃该数据包。后面的flag占用2字节用于标识数据包属性目前拥有的标识如下
* `federation`: `0x0010`,表示这个数据包是从其他的supernode主动发送过来的比如其他supernode主动发送过来的RegisterSuper其他supernode
* `federation`: `0x0010`,表示这个数据包是从其他的supernode主动发送过来的比如其他supernode主动发送过来的RegisterSuper其他supernode收到情短请求之后主动将请求以Command的形式广播给其他supernode等。
* `from_sn`: `0x0020`,表示这个数据包是从服务端发送过来的。
* `socket`: `0x0040`表示这个数据包里面包含了有用的socket信息通常在服务端转发的时候有用
* `v6_info`: `0x0080`,表示这个数据包里面包含了ipv6信息专门用在packet数据包里面目前只有这个数据包使用了该标识

View File

@ -10,6 +10,7 @@ pub enum SDLanError {
SerializeError(String),
EncryptError(String),
DBError(String),
PBError(String),
}
impl SDLanError {
@ -21,6 +22,7 @@ impl SDLanError {
Self::SerializeError(ref e) => e,
Self::EncryptError(ref e) => e,
Self::DBError(ref e) => e,
Self::PBError(ref e) => e,
}
}
}
@ -31,6 +33,12 @@ impl From<std::io::Error> for SDLanError {
}
}
impl From<prost::EncodeError> for SDLanError {
fn from(value: prost::EncodeError) -> Self {
Self::PBError(value.to_string())
}
}
impl From<&'static str> for SDLanError {
fn from(value: &'static str) -> Self {
Self::NormalError(value)