feat(proxy): add modify proxy API endpoint and functionality

Implement proxy modification feature including:
- New modifyFrpcProxy function in config.go
- New ModifyProxyHandler in frpcProxyAct.go
- New API endpoint in router.go
- Updated API documentation in docs/api.md
This commit is contained in:
2026-03-31 23:03:51 +08:00
parent f4d742de04
commit 1aaec45151
5 changed files with 215 additions and 0 deletions
+85
View File
@@ -1042,6 +1042,91 @@ remote_port = 6000
---
## Modify Proxy
**Endpoint:** `/frpcAct/proxyMgr/modify`
**Method:** POST
**Content-Type:** application/json
**Auth Required:** Yes (token)
**Permission Level:** Admin
Modify an existing proxy configuration for an frpc instance. The proxy configuration will be updated in the instance's config file.
**Request Headers:**
```
X-Token: your_token
X-Timestamp: 1704067200000
```
**Request Body:**
```json
{
"instanceID": "1",
"proxyInfo": {
"name": "ssh_proxy",
"type": "tcp",
"localIP": "127.0.0.1",
"localPort": "22",
"remotePort": "6001"
}
}
```
| Header | Type | Required | Description |
|--------|------|----------|-------------|
| X-Token | string | Yes | Authentication token |
| X-Timestamp | int64 | Yes | Client timestamp in milliseconds |
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| instanceID | string | Yes | Instance ID (the ID of the frpc instance) |
| proxyInfo.name | string | Yes | Proxy name (used to identify which proxy to modify) |
| proxyInfo.type | string | Yes | Proxy type (e.g., tcp, udp, http, https) |
| proxyInfo.localIP | string | Yes | Local IP address to forward to |
| proxyInfo.localPort | string | Yes | Local port to forward from |
| proxyInfo.remotePort | string | Yes | Remote port on frps to expose |
**Response:**
```json
{
"success": true,
"message": "Proxy modified successfully",
"data": {
"instanceID": 1,
"configPath": "./configs/superfrpc_user_my_frpc.toml",
"proxyName": "ssh_proxy"
}
}
```
| Field | Type | Description |
|-------|------|-------------|
| instanceID | int | Instance ID |
| configPath | string | Path to the configuration file |
| proxyName | string | Name of the modified proxy |
**Config File Format:**
The proxy configuration in the config file will be updated to the following format:
```toml
[[proxies]]
name = ssh_proxy
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6001
```
> **Note:**
> - The proxy configuration is updated in the existing config file
> - The instance must already exist before modifying a proxy
> - This endpoint does not modify the database, only the config file
> - The frpc service needs to be restarted for changes to take effect
> - The proxy name is used to identify which proxy to modify; if the proxy is not found, an error will be returned
---
## Delete Proxy
**Endpoint:** `/frpcAct/proxyMgr/delete`