web api

需要开启请先去掉nps.confauth_key的注释并配置一个合适的密钥

webAPI验证说明

  • 采用auth_key的验证方式
  • 在提交的每个请求后面附带两个参数,auth_keytimestamp

    auth_key的生成方式为:md5(配置文件中的auth_key+当前时间戳)

    timestamp为当前时间戳

    curl —request POST \
    —url http://127.0.0.1:8080/client/list \
    —data ‘auth_key=2a0000d9229e7dbcf79dd0f5e04bb084×tamp=1553045344&start=0&limit=10’

注意: 为保证安全,时间戳的有效范围为20秒内,所以每次提交请求必须重新生成。

获取服务端时间

由于服务端与api请求的客户端时间差异不能太大,所以提供了一个可以获取服务端时间的接口

  1. POST /auth/gettime

获取服务端authKey

如果想获取authKey,服务端提供获取authKey的接口

  1. POST /auth/getauthkey

将返回加密后的authKey,采用aes cbc加密,请使用与服务端配置文件中cryptKey相同的密钥进行解密

注意: nps配置文件中auth_crypt_key需为16位

  • 解密密钥长度128
  • 偏移量与密钥相同
  • 补码方式pkcs5padding
  • 解密串编码方式 十六进制

详细文档

获取客户端列表

  1. POST /client/list/
参数 含义
search 搜索
order 排序asc 正序 desc倒序
offset 分页(第几页)
limit 条数(分页显示的条数)

获取单个客户端

  1. POST /client/getclient/
参数 含义
id 客户端id

添加客户端

  1. POST /client/add/
参数 含义
remark 备注
u basic权限认证用户名
p basic权限认证密码
limit 条数(分页显示的条数)
vkey 客户端验证密钥
config_conn_allow 是否允许客户端以配置文件模式连接 1允许 0不允许
compress 压缩1允许 0不允许
crypt 是否加密(1或者0)1允许 0不允许
rate_limit 带宽限制 单位KB/S 空则为不限制
flow_limit 流量限制 单位M 空则为不限制
max_conn 客户端最大连接数量 空则为不限制
max_tunnel 客户端最大隧道数量 空则为不限制

修改客户端

  1. POST /client/edit/
参数 含义
remark 备注
u basic权限认证用户名
p basic权限认证密码
limit 条数(分页显示的条数)
vkey 客户端验证密钥
config_conn_allow 是否允许客户端以配置文件模式连接 1允许 0不允许
compress 压缩1允许 0不允许
crypt 是否加密(1或者0)1允许 0不允许
rate_limit 带宽限制 单位KB/S 空则为不限制
flow_limit 流量限制 单位M 空则为不限制
max_conn 客户端最大连接数量 空则为不限制
max_tunnel 客户端最大隧道数量 空则为不限制
id 要修改的客户端id

删除客户端

  1. POST /client/del/
参数 含义
id 要删除的客户端id

获取域名解析列表

  1. POST /index/hostlist/
参数 含义
search 搜索(可以搜域名/备注什么的)
offset 分页(第几页)
limit 条数(分页显示的条数)

添加域名解析

  1. POST /index/addhost/
参数 含义
remark 备注
host 域名
scheme 协议类型(三种 all http https)
location url路由 空则为不限制
client_id 客户端id
target 内网目标(ip:端口)
header request header 请求头
hostchange request host 请求主机

修改域名解析

  1. POST /index/edithost/
参数 含义
remark 备注
host 域名
scheme 协议类型(三种 all http https)
location url路由 空则为不限制
client_id 客户端id
target 内网目标(ip:端口)
header request header 请求头
hostchange request host 请求主机
id 需要修改的域名解析id

删除域名解析

  1. POST /index/delhost/
参数 含义
id 需要删除的域名解析id

获取单条隧道信息

  1. POST /index/getonetunnel/
参数 含义
id 隧道的id

获取隧道列表

  1. POST /index/gettunnel/
参数 含义
client_id 穿透隧道的客户端id
type 类型tcp udp httpProx socks5 secret p2p
search 搜索
offset 分页(第几页)
limit 条数(分页显示的条数)

添加隧道

  1. POST /index/add/
参数 含义
type 类型tcp udp httpProx socks5 secret p2p
remark 备注
port 服务端端口
target 目标(ip:端口)
client_id 客户端id

修改隧道

  1. POST /index/edit/
参数 含义
type 类型tcp udp httpProx socks5 secret p2p
remark 备注
port 服务端端口
target 目标(ip:端口)
client_id 客户端id
id 隧道id

删除隧道

  1. POST /index/del/
参数 含义
id 隧道id

隧道停止工作

  1. POST /index/stop/
参数 含义
id 隧道id

隧道开始工作

  1. POST /index/start/
参数 含义
id 隧道id