api set user's id from u64 to u32

This commit is contained in:
asxalex 2024-04-06 11:23:40 +08:00
parent 1467b8ba68
commit 107a7f8161
2 changed files with 223 additions and 1 deletions

222
docs/http_api.md Normal file
View File

@ -0,0 +1,222 @@
# sdlan中心节点提供的api
sdlan中心节点需要被告知的内容主要有
* `register_token`——节点上线需要填写的token是一个`big int`64位的unsigned int
* 与`register_token`关联的信息,包括(但不一定需要)
* 过期时间
* 默认加入的网络
* 与`register_token`关联的用户信息,主要包括
* 用户的uuid为一个`big int`(64位的unsigned int)
* 用户是否启用
* 与用户uuid相互关联的信息比如该用户限制的连接的终端的个数等如果有的化
## 1.0. token创建通知
```
POST /token/created
{
"value": $unsigned_int,
// 过期时候的unix timestamp
"expire": $unsigned_int,
// 默认加入的网络的uuid
"defalut_network_id": "",
"user_info": {
// 关联的用户的id的数字
"user_id": $unsigned_int,
// 限制的节点的个数
"limit": $int,
// 表明用户是否启用
"enabled": $bool,
}
}
```
返回值:
```
{
// 0表示成功其他数字代表失败
"code": $int,
// 如果成功message返回信息这里只返回一个ok
"message": "ok",
// 如果code不为0则error表示出错信息
"error": $string,
}
```
## 1.1. token删除
通过调用该接口告知supernode删除一个token。
```
POST /token/delete
{
"value": $unsigned_int,
}
```
返回值:
```
{
// 0表示成功其他数字代表失败
"code": $int,
// 如果成功message返回信息这里只返回一个ok
"message": "ok",
// 如果code不为0则error表示出错信息
"error": $string,
}
```
## 1.2. 用户信息修改
用户信息修改,主要涉及到用户可以创建节点的个数,接口如下:
```
POST /user/update
{
"user_id": $unsigned_int,
"limit": $int,
"enabled": $bool
}
```
返回值:
```
{
// 0表示成功其他数字代表失败
"code": $int,
// 如果成功message返回信息这里只返回一个ok
"message": "ok",
// 如果code不为0则error表示出错信息
"error": $string,
}
```
## 1.3. 创建网络
创建网络是supernode端进行主要因为需要分配ip地址supernode端提供创建网络的api。
```
POST /network/create
{
// 网络的名称
"name": $string,
// 用户选择的ip地址段cidr格式的ip地址如10.20.1.0/24
// 如果不指定,则该字段不传递
"ip": $string,
// 创建的用户的id最后会用于表明该网络属于哪个用户
"user_id": $unsigned_int,
}
```
返回值:
```
{
// 0表示成功其他数字代表失败
"code": $int,
// 如果成功message返回信息这里只返回一个ok
"message": {
// 该网络的唯一标识
"uuid": $string
// 最后分配的cidr格式的ip地址如10.20.1.0/24
"ip": $string
},
// 如果code不为0则error表示出错信息
"error": $string,
}
```
## 1.4. 移动节点
移动节点用于将某个处于网络A中的节点移动到同一个用户的另一个网络B中
```
POST /peer/move
{
// 需要移动的节点的uuid
"peer_id": $string,
// 节点所处的以前的网络
"from_id": $string,
// 节点移动到的新网络的uuid
"to_id": $string,
// 属于哪个用户
"user_id": $unsigned_int,
}
```
返回值:
```json
{
// 0表示成功其他数字代表失败
"code": $int,
// 如果成功message返回信息这里只返回一个ok
"message": "ok",
// 如果code不为0则error表示出错信息
"error": $string
}
```
## 1.5. 授权节点
移动节点用于将某个处于未授权的节点,移动到同一个用户的某个网络中:
```
POST /peer/authorize
{
// 需要移动的节点的uuid
"peer_id": $string,
// 节点移动到的新网络的uuid
"to_id": $string,
// 属于哪个用户
"user_id": $unsigned_int,
}
```
返回值:
```json
{
// 0表示成功其他数字代表失败
"code": $int,
// 如果成功message返回信息这里只返回一个ok
"message": "ok",
// 如果code不为0则error表示出错信息
"error": $string
}
```
## 1.6. 取消节点授权
移动节点用于将某个处于某个网络的节点,取消授权,返回到为授权状态:
```
POST /peer/unauthorize
{
// 需要移动的节点的uuid
"peer_id": $string,
// 节点所处的以前的网络
"from_id": $string,
// 属于哪个用户
"user_id": $unsigned_int,
}
```
返回值:
```json
{
// 0表示成功其他数字代表失败
"code": $int,
// 如果成功message返回信息这里只返回一个ok
"message": "ok",
// 如果code不为0则error表示出错信息
"error": $string
}
```

View File

@ -21,7 +21,7 @@ pub struct MovePeerCommandReq {
pub peer_id: String,
pub new_ip: u32,
pub net_bit_len: u8,
pub user_id: u64,
pub user_id: u32,
}
#[derive(Serialize, Deserialize)]