added encode error
This commit is contained in:
parent
f9a5cc3986
commit
f320526f2d
@ -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"
|
||||
|
||||
@ -219,4 +219,7 @@ POST /peer/unauthorize
|
||||
// 如果code不为0,则error表示出错信息
|
||||
"error": $string
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
# 2.0 sdlan中心节点使用的数据库结构
|
||||
在中心节点收到客户端上线请求之后,如果这个节点是第一次上线,则会将相关信息插入到
|
||||
@ -26,7 +26,7 @@ sdlan协议的总体格式如下:
|
||||
|
||||
其中,version占用一个字节,用于标识协议版本。id用于唯一标识某个客户端,为长度为32字节的uuid,token是用户生成的邀请码,占用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数据包里面,目前只有这个数据包使用了该标识)。
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user