服务商 API
接口前缀:
/dashboard/*请求方式:
POST(部分为GET) 认证方式: 服务商 Token(非 CSRF)页面入口:
/sp(ServiceProvider.vue)
认证说明
服务商 Token 取自用户信息中的 token 字段(/user type=info),通过 /dashboard/login 验证:
typescript
const spToken = computed(() => userStore.userInfo?.token || '')
const res = await api.spLogin(spToken.value)
if (res.code === 200) {
// 登录成功,用户组见 res.group
}Token 与 CSRF 不同
- 控制台接口用 CSRF(登录返回的
token) - 服务商接口用用户信息里的
token(FRP 连接 Token)
两者语义不同,不要混用。
API 列表
| 序号 | 接口 | 路径 / 说明 |
|---|---|---|
| 1 | 服务商登录 | POST /dashboard/login |
| 2 | 服务器列表 | POST /dashboard/server?type=list |
| 3 | 服务器配置 | POST /dashboard/server?type=config&id= |
| 4 | 编辑页面数据 | POST /dashboard/server?type=editpage&id= |
| 5 | 编辑服务器 | POST /dashboard/server?type=edit&id=... |
| 6 | 删除服务器 | POST /dashboard/server?type=remove&id= |
| 7 | 添加服务器 | POST /dashboard/server?type=add&... |
| 8 | 检测状态 | POST /dashboard/server?type=status&id= |
| 9 | 批量检测 | POST /dashboard/server?type=statusall |
| 10 | 获取公告 | POST /dashboard/spnotice?type=get |
| 11 | 发布公告 | POST /dashboard/spnotice?type=push |
| 12 | 申请列表 | GET /dashboard/besp?type=list&token= |
| 13 | 批准申请 | GET /dashboard/besp?type=canbesp&user=&token= |
| 14 | 忽略申请 | GET /dashboard/besp?type=remove&user=&token= |
| 15 | 删除全部申请 | GET /dashboard/besp?type=removeall&token= |
| 16 | 申请成为服务商 | GET /dashboard/besp?user=&msg=&type=besp |
1. 服务商登录
bash
curl -X POST https://api.hayfrp.1zyq1.com/dashboard/login \
-H "waf: off" \
-d "token=服务商Token"返回 code: 200 表示成功,group 为当前用户组;非服务商返回权限不足提示。
2. 服务器列表
bash
curl -X POST "https://api.hayfrp.1zyq1.com/dashboard/server?type=list" \
-H "waf: off" -d "token=服务商Token"前端兼容三种数据字段:res.data / res.servers / res.list。
服务器对象关键字段:
| 字段 | 说明 |
|---|---|
id | 服务器 ID |
cname / nname | 服务器名称(中文 / 显示名) |
country / ecountry | 国家(中文 / 英文) |
area / earea | 地区 |
description | 描述 |
group | 节点权限组:0 全部 / 1 已实名 / 2 特殊组 / 3 管理组 |
port | frps 端口 |
aport / apass | 管理端口 / 管理密码 |
up / down | 上行 / 下行带宽 |
prange | 可用端口范围,如 10000-20000 |
banport | 禁用端口 |
web / tcp / udp / http / https / xtcp / stcp / sudp | 支持的隧道类型(字符串 "true" / "false") |
online / 在线时长 | 节点在线状态与在线秒数(前端格式化为「x天 x小时」) |
3. 服务器配置
bash
curl -X POST "https://api.hayfrp.1zyq1.com/dashboard/server?type=config&id=1" \
-H "waf: off" -d "token=服务商Token"返回该节点的 frps 配置文件内容(前端以代码块预览,并给出「在服务器上运行以下命令」的一键配置命令)。
4. 编辑页面数据
bash
curl -X POST "https://api.hayfrp.1zyq1.com/dashboard/server?type=editpage&id=1" \
-H "waf: off" -d "token=服务商Token"该接口返回的是一段 HTML 表单,前端用 DOMParser 解析出各 input 的当前值后回填到编辑弹窗。
5. 编辑服务器
bash
curl -X POST "https://api.hayfrp.1zyq1.com/dashboard/server?type=edit&id=1&cname=新名称&port=7000" \
-H "waf: off" -d "token=服务商Token"参数通过 query 传递,常用字段:
| 参数 | 说明 |
|---|---|
country / ecountry | 国家(中文 / 英文) |
area / earea | 地区(中文 / 英文) |
nname / enname | 服务器名称(中文 / 英文) |
cname | 服务器简称 / 展示名 |
description | 描述 |
group | 权限组 0–3 |
port / aport / apass | frps 端口 / 管理端口 / 管理密码 |
up / down | 上行 / 下行带宽 |
prange | 端口范围(前端拼成 起始-结束) |
banport | 禁用端口 |
web / tcp / udp / http / https / xtcp / stcp / sudp | 支持类型("true" / "false") |
编辑弹窗中勾选「同时更新域名」时,前端改调
spEditServerWithDomain()(额外提交域名字段)。
6. 删除服务器
bash
curl -X POST "https://api.hayfrp.1zyq1.com/dashboard/server?type=remove&id=1" \
-H "waf: off" -d "token=服务商Token"7. 添加服务器
bash
curl -X POST "https://api.hayfrp.1zyq1.com/dashboard/server?type=add&country=中国&cname=新服务器&port=7000" \
-H "waf: off" -d "token=服务商Token"参数同「编辑服务器」,前端默认端口范围 1-65500、禁用端口 0、权限组 0。
8. 检测服务器状态
bash
curl -X POST "https://api.hayfrp.1zyq1.com/dashboard/server?type=status&id=1" \
-H "waf: off" -d "token=服务商Token"9. 批量检测状态
bash
curl -X POST "https://api.hayfrp.1zyq1.com/dashboard/server?type=statusall" \
-H "waf: off" -d "token=服务商Token"10. 获取服务商公告
json
{ "type": "get", "token": "服务商Token" }返回 { code: 200, spnotice: "公告内容", time: "1700000000" }。
11. 发布服务商公告
json
{ "type": "push", "token": "服务商Token", "spnotice": "公告内容" }富文本与 XSS
公告支持 HTML 标签,前端渲染前统一经 DOMPurify.sanitize() 清洗。
12–15. 申请管理
bash
# 申请列表
curl "https://api.hayfrp.1zyq1.com/dashboard/besp?type=list&token=服务商Token"
# 批准
curl "https://api.hayfrp.1zyq1.com/dashboard/besp?type=canbesp&user=username&token=服务商Token"
# 忽略
curl "https://api.hayfrp.1zyq1.com/dashboard/besp?type=remove&user=username&token=服务商Token"
# 删除全部申请
curl "https://api.hayfrp.1zyq1.com/dashboard/besp?type=removeall&token=服务商Token"16. 申请成为服务商
bash
curl "https://api.hayfrp.1zyq1.com/dashboard/besp?user=username&msg=我想成为服务商&type=besp"普通用户入口位于
/settings(用户设置)与/sp(未通过审核时的申请卡片)。
前端封装
typescript
const spLogin = await api.spLogin(token)
const servers = await api.spGetServers(token)
const config = await api.spGetServerConfig(token, id)
const editHtml = await api.spGetEditPage(token, id)
await api.spEditServer(token, id, data)
await api.spEditServerWithDomain(token, id, data)
await api.spDeleteServer(token, id)
await api.spAddServer(token, data)
const status = await api.spCheckServerStatus(token, id)
const allStatus = await api.spBatchCheckServerStatus(token)
const notice = await api.spGetNotice(token)
await api.spPushNotice(token, content)
const applies = await api.spGetApplyList(token)
await api.spApproveApply(token, 'username')
await api.spRemoveApply(token, 'username')
await api.spRemoveAllApply(token)
await api.applyForProvider('username', '申请留言')节点权限组(group)
| 值 | 含义 |
|---|---|
0 | 全部用户可用 |
1 | 已实名用户可用 |
2 | 特殊组可用 |
3 | 管理组可用 |