feat(proxy): add proxy management endpoint and proxy creation API
- Implement new endpoint for creating frpc proxy configurations - Add DBQueryFrpcInstanceByID function to fetch instances by ID - Move proxy generation logic to separate function in frpcProxyAct.go - Update API documentation with new proxy creation endpoint
This commit is contained in:
+86
@@ -635,6 +635,92 @@ Modify system-level settings such as instance name, boot-at-start configuration,
|
||||
|
||||
---
|
||||
|
||||
## Create Proxy
|
||||
|
||||
**Endpoint:** `/frpcAct/proxyMgr/create`
|
||||
**Method:** POST
|
||||
**Content-Type:** application/json
|
||||
**Auth Required:** Yes (token)
|
||||
**Permission Level:** Admin
|
||||
|
||||
Create a new proxy configuration for an existing frpc instance. The proxy configuration will be appended to 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": "6000"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
| 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 |
|
||||
| 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 created successfully",
|
||||
"data": {
|
||||
"instanceName": "my_frpc",
|
||||
"instanceID": 1,
|
||||
"configPath": "./configs/superfrpc_user_my_frpc.toml",
|
||||
"proxyName": "ssh_proxy"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| instanceName | string | Name of the frpc instance |
|
||||
| instanceID | int | Instance ID |
|
||||
| configPath | string | Path to the configuration file |
|
||||
| proxyName | string | Name of the created proxy |
|
||||
|
||||
**Config File Format:**
|
||||
|
||||
The proxy configuration will be appended to the instance's config file in the following format:
|
||||
|
||||
```toml
|
||||
[[proxies]]
|
||||
name = ssh_proxy
|
||||
type = tcp
|
||||
local_ip = 127.0.0.1
|
||||
local_port = 22
|
||||
remote_port = 6000
|
||||
```
|
||||
|
||||
> **Note:**
|
||||
> - The proxy configuration is appended to the existing config file
|
||||
> - The instance must already exist before creating 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
|
||||
|
||||
---
|
||||
|
||||
## List frpc Instances
|
||||
|
||||
**Endpoint:** `/frpcAct/instanceMgr/list`
|
||||
|
||||
Reference in New Issue
Block a user