# 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, // 限制的节点的个数 "peer_limit": $int, // 表明用户是否启用 "enabled": $bool, } } ``` 返回值: ``` { // 0表示成功,其他数字代表失败 "code": $int, // 如果成功,message返回信息,这里只返回一个ok "message": "ok", // 如果code不为0,则error表示出错信息 "error": $string, } ``` ## 1.1. token删除 通过调用该接口,告知supernode删除一个token。 ``` POST /token/deleted { "value": $unsigned_int, } ``` 返回值: ``` { // 0表示成功,其他数字代表失败 "code": $int, // 如果成功,message返回信息,这里只返回一个ok "message": "ok", // 如果code不为0,则error表示出错信息 "error": $string, } ``` ## 1.2. 用户信息修改 用户信息修改,主要涉及到用户可以创建节点的个数,接口如下: ``` POST /user/updated { "user_id": $unsigned_int, "peer_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 } ```