API请求与响应报文为HTTP协议 以POST JSON数据格式进行交互。

一、获取隧道列表

请求地址:
http://du.nsloop.com:8080/api/tunel/chn?token=xxxxxxxxxxxxxxxxxxxxxx

响应报文:

{
  "code": 0,   //0:成功  1:失败
  "msg": "ok", //描述信息
  "chns": [
    {
      "id": 3563,   //隧道ID
      "chn_name": "3",  //隧道名称
      "chn_type": 1,  //0:TCP  1:HTTP  2:HTTPS   3:UDP
      "remote_port": 20064, //远程端口
      "local_ip": "127.0.0.1",   //本地IP
      "local_port": 3000,          //本地端口    
      "userdomain": "",   //自定义域名
      "subdomain": "55555",
      "status": 0       //0:正常  1:停止
    },
    {
      "id": 3603,
      "chn_name": "隧道47a0",
      "chn_type": 1,
      "remote_port": 0,
      "local_ip": "127.0.0.1",
      "local_port": 80,
      "userdomain": "sss.nats0.vip",
      "subdomain": "",
      "status": 2      
    },

    {
      "id": 3606,
      "chn_name": "隧道ddeb",
      "chn_type": 1,
      "remote_port": 0,
      "local_ip": "127.0.0.1",
      "local_port": 80,
      "userdomain": "xxxx.com",
      "subdomain": "",
      "status": 0
    }
  ],
  "sn_host": "frp.x.com",   //线路域名
  "sn_sub_domain": "nat.x.com"
}

二、添加隧道

请求地址:
http://du.nsloop.com:8080/api/tunel/chn/add?token=xxxxxxxxxxxxxxxxxxxxxx
添加TCP隧道请求数据:

{
    "chn_name": "aaa", 
    "chn_type": 0, 
    "local_ip": "127.0.0.1", 
    "local_port": 8899
}

添加HTTP隧道请求数据

{
    "chn_name": "aaa", 
    "chn_type": 1, 
    "local_ip": "127.0.0.1", 
    "local_port": 8899,
    "userdomain": "www.test.com"
}

响应报文:

{
  "code": 0,
  "msg": "ok",
  "chn_id": 1111   //添加的隧道ID
}

三、修改隧道

请求地址:
http://du.nsloop.com:8080/api/tunel/chn/edit?token=xxxxxxxxxxxxxxxxxxxxxx
请求数据:

{
    "chn_id": 3605,
    "chn_name": "aaa", 
    "chn_type": 0,
    "auto_https": 0,
    "local_ip": "127.0.0.1", 
    "local_port": 8899,
    "remote_port": 9999
}

响应报文:

{
  "code": 0,
  "msg": "ok"
}

四、删除隧道

请求地址:
http://du.nsloop.com:8080/api/tunel/chn/del?token=xxxxxxxxxxxxxxxxxxxxxx
请求数据:

{
   "chn_id":1111  //隧道ID
}   

响应报文:

{
  "code": 0,
  "msg": "ok"
}

五、控制隧道启用,暂停

请求地址:
http://du.nsloop.com:8080/api/tunel/chn/set_state?token=xxxxxxxxxxxxxxxxxxxxxx
请求数据:

{
   "chn_id":1111,  //隧道ID
    “state”: 0      //0:启用   1:暂停
}   

响应报文:

{
  "code": 0,
  "msg": "ok"
}

六、获取当前网络信息

请求地址:
http://du.nsloop.com:8080/api/tunel/network/info?token=xxxxxxxxxxxxxxxxxxxxxx

响应报文:

{
"code": 0, 
"msg": "ok", 
"username": "bbbbbb",             //用户名
"product_name": "内网穿透VIP1",   //套餐名称
"expired_date": "2021-10-08",      //过期时间
"is_expired": true,                 //是否过期
"network_name": "测试网络",       //网络名称
"enabled": 1,                     //网络状态
"sn_host": "frp.x.com",
"sn_sub_domain": "nat.x.com"
}
文档更新时间: 2024-03-16 21:28   作者:admin