sdlan/API.md
2026-04-02 17:09:31 +08:00

150 lines
2.5 KiB
Markdown
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.

# SDLAN 交互文档
## SDL主动请求的接口
### 1. 获取全部的可用网络信息
```text
url: get_all_networks
method: get
return:
{"result": [8, 9, 10]}
{"error": {"code": 1, "message": "错误描述"}}
```
### 2. 获取单个网络信息
```text
url: get_network?id=:id
method: get
return:
{"result":
{
"id": 1,
"name": "网络1",
"ipaddr": "192.168.0.1/24",
"domain": "punchnet.cn",
"owner_id": 1234,
"algorithm": "aes|chacha20",
"disabled_clients": ["client_id_xyz", "client_id_xyz1"]
}
}
{"error": {"code": 1, "message": "错误描述"}}
```
### 3. access_token校验
```text
url: auth/access_token
method: post
params:
network_id: int,
client_id: string
mac: string,
ip: string,
mask_len: int,
hostname: string,
access_token: string,
return:
{"result": "ok"}
{"error": {"code": 1, "message": "错误描述"}}
code = 1, Token does not exists
code = 2, Client Connection Disable
```
### 4.设置节点的状态
```text
url: set_node_status
method: post
params:
client_id: string
network_id: int,
ip_addr: string,
status: 0 | 1, // 0: 离线1 在线
return:
{"result": "success"}
```
## 管理平台请求SDLAN
### 网络管理接口
#### 1. 创建新网络
```text
url: /network/create
method: post
params:
id: int
return:
{"result": "success"}
{"error": {"code": 1, "message": "错误描述"}}
```
#### 2. 更新网络信息
```text
url: /network/reload
method: post
params:
id: int
return:
{"result": "success"}
{"error": {"code": 1, "message": "错误描述"}}
```
#### 3. 删除网络
```text
url: /network/delete
method: post
params:
id: int
return:
{"result": "success"}
{"error": {"code": 1, "message": "错误描述"}}
```
#### 3. 设置网络出口
```text
url: /network/exit_node_control
method: post
params:
id: int, //网络id
action: int // 0: 关闭1: 开启
client_id: string // 目标节点的mac地址
remark: string // 下发的标签,用于跟踪测试问题,可为空
timeout: int // 超时设置,单位为秒
return:
{"result": "success"}
{"error": {"code": 1, "message": "错误描述"}}
```
### 客户端节点管理
#### 1. 禁用节点
```text
url: /node/disable
method: post
params:
network_id: int
client_id: int
return:
{"result": "success"}
{"error": {"code": 1, "message": "错误描述"}}
```