sdlan/API.md
2026-04-02 16:34:24 +08:00

2.5 KiB
Raw Blame History

SDLAN 交互文档

SDL主动请求的接口

1. 获取全部的可用网络信息

url: get_all_networks
method: get
return:

    {"result": [8, 9, 10]}

    {"error": {"code": 1, "message": "错误描述"}}

2. 获取单个网络信息

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校验

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.设置节点的状态

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. 创建新网络

url: /network/create
method: post
params:
    id: int
return:

    {"result": "success"}
    {"error": {"code": 1, "message": "错误描述"}}

2. 更新网络信息

url: /network/reload
method: post
params:
    id: int
return:

    {"result": "success"}
    {"error": {"code": 1, "message": "错误描述"}}

3. 删除网络

url: /network/delete
method: post
params:
    id: int
return:

    {"result": "success"}
    {"error": {"code": 1, "message": "错误描述"}}

3. 设置网络出口

url: /network/exit_node_control
method: post
params:
    id: int, //网络id
    action: int // 0: 关闭1: 开启 
    dst_mac: string // 目标节点的mac地址 
    remark: string // 下发的标签,用于跟踪测试问题,可为空 
    timeout: int // 超时设置,单位为秒 
return:

    {"result": "success"}
    {"error": {"code": 1, "message": "错误描述"}}

客户端节点管理

1. 禁用节点

url: /node/disable
method: post
params:
    network_id: int
    client_id: int
    
return:

    {"result": "success"}
    {"error": {"code": 1, "message": "错误描述"}}