feat(frpAct): add Windows/Systemd/Init.d service boot control. BUT WINDOWS STILL HAS BUGS AND LINUX HAS NOT BEEN TESTED.

This commit is contained in:
2026-03-24 23:23:34 +08:00
parent e335ce4da6
commit 802a726464
6 changed files with 994 additions and 92 deletions
+267 -15
View File
@@ -492,21 +492,36 @@ X-Timestamp: 1704067200000
**Request Body:**
```json
{
"instanceName": "my_frpc"
"instanceID": "1"
}
```
| 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) |
**Response:**
```json
{
"success": true,
"message": "instance deleted successfully",
"data": {
"instanceID": 1,
"name": "my_frpc"
}
}
```
| Field | Type | Description |
|-------|------|-------------|
| instanceID | int | Instance ID |
| name | string | Name of the deleted frpc instance |
---
## Modify frpc Instance
@@ -532,7 +547,6 @@ Modify fields in the `[common]` section of the frpc configuration file. Only `[c
**Request Body:**
```json
{
"instanceName": "my_frpc",
"instanceID": "1",
"type": "configFile",
"modifiedData": {
@@ -546,8 +560,7 @@ Modify fields in the `[common]` section of the frpc configuration file. Only `[c
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| instanceName | string | Yes | Current instance name |
| instanceID | string | Yes | Instance ID |
| instanceID | string | Yes | Instance ID (the ID of the frpc instance) |
| type | string | Yes | Modification type: `configFile` or `systemConfig` |
| modifiedData | object | Yes | Key-value pairs of fields to modify in `[common]` section |
@@ -557,7 +570,6 @@ Modify fields in the `[common]` section of the frpc configuration file. Only `[c
"success": true,
"message": "Config file modified successfully",
"data": {
"instanceName": "my_frpc",
"instanceID": 1,
"configPath": "./configs/superfrpc_user_my_frpc.toml"
}
@@ -571,7 +583,6 @@ Modify system-level settings such as instance name, boot-at-start configuration,
**Request Body:**
```json
{
"instanceName": "my_frpc",
"instanceID": "1",
"type": "systemConfig",
"modifiedData": {
@@ -584,8 +595,7 @@ Modify system-level settings such as instance name, boot-at-start configuration,
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| instanceName | string | Yes | Current instance name |
| instanceID | string | Yes | Instance ID |
| instanceID | string | Yes | Instance ID (the ID of the frpc instance) |
| type | string | Yes | Modification type: `configFile` or `systemConfig` |
| modifiedData.name | string | No | New instance name (renames config file if changed) |
| modifiedData.bootAtStart | bool | No | Auto-start on system boot |
@@ -597,7 +607,6 @@ Modify system-level settings such as instance name, boot-at-start configuration,
"success": true,
"message": "System config modified successfully",
"data": {
"instanceName": "new_frpc_name",
"instanceID": 1,
"configPath": "./configs/superfrpc_user_new_frpc_name.toml",
"bootAtStart": true,
@@ -635,6 +644,255 @@ Modify system-level settings such as instance name, boot-at-start configuration,
---
## Start frpc Instance
**Endpoint:** `/frpcAct/instanceMgr/start`
**Method:** POST
**Content-Type:** application/json
**Auth Required:** Yes (token)
**Permission Level:** Admin
Start a frpc instance. The instance can be started as a background process on Windows (hidden window) or as a systemd/init.d service on Linux.
**Request Headers:**
```
X-Token: your_token
X-Timestamp: 1704067200000
```
**Request Body:**
```json
{
"instanceID": "1"
}
```
| 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 | ID of the instance to start |
**Response (Windows):**
```json
{
"success": true,
"message": "Instance started successfully",
"data": {}
}
```
**Response (Linux systemd):**
```json
{
"success": true,
"message": "Instance started successfully",
"data": {}
}
```
**Response (Linux init.d):**
```json
{
"success": true,
"message": "Instance started successfully",
"data": {}
}
```
---
## Stop frpc Instance
**Endpoint:** `/frpcAct/instanceMgr/stop`
**Method:** POST
**Content-Type:** application/json
**Auth Required:** Yes (token)
**Permission Level:** Admin
Stop a running frpc instance. On Windows, this stops the frpc process. On Linux, this stops the systemd/init.d service.
**Request Headers:**
```
X-Token: your_token
X-Timestamp: 1704067200000
```
**Request Body:**
```json
{
"instanceID": "1"
}
```
| 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 | ID of the instance to stop |
**Response (Windows):**
```json
{
"success": true,
"message": "Instance stopped successfully",
"data": {}
}
```
**Response (Linux systemd):**
```json
{
"success": true,
"message": "Instance stopped successfully",
"data": {}
}
```
**Response (Linux init.d):**
```json
{
"success": true,
"message": "Instance stopped successfully",
"data": {}
}
```
---
## Restart frpc Instance
**Endpoint:** `/frpcAct/instanceMgr/restart`
**Method:** POST
**Content-Type:** application/json
**Auth Required:** Yes (token)
**Permission Level:** Admin
Restart a frpc instance. This stops and then starts the instance again.
**Request Headers:**
```
X-Token: your_token
X-Timestamp: 1704067200000
```
**Request Body:**
```json
{
"instanceID": "1"
}
```
| 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 | ID of the instance to restart |
**Response (Windows):**
```json
{
"success": true,
"message": "Instance restarted successfully",
"data": {}
}
```
**Response (Linux systemd):**
```json
{
"success": true,
"message": "Instance restarted successfully",
"data": {}
}
```
**Response (Linux init.d):**
```json
{
"success": true,
"message": "Instance restarted successfully",
"data": {}
}
```
---
## Get frpc Instance Status
**Endpoint:** `/frpcAct/instanceMgr/status`
**Method:** GET
**Auth Required:** Yes (token)
**Permission Level:** Visitor
Check the running status of a frpc instance.
**Request Headers:**
```
X-Token: your_token
X-Timestamp: 1704067200000
```
**Query Parameters:**
```
instanceID=1
```
| Header | Type | Required | Description |
|--------|------|----------|-------------|
| X-Token | string | Yes | Authentication token |
| X-Timestamp | int64 | Yes | Client timestamp in milliseconds |
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| instanceID | string | Yes | ID of the instance to check |
**Response (running):**
```json
{
"success": true,
"message": "Instance status retrieved successfully",
"data": {
"name": "my_frpc",
"initSystem": "systemd",
"serviceName": "superfrpc_admin_my_frpc",
"isRunning": true
}
}
```
**Response (stopped):**
```json
{
"success": true,
"message": "Instance status retrieved successfully",
"data": {
"name": "my_frpc",
"initSystem": "systemd",
"serviceName": "superfrpc_admin_my_frpc",
"isRunning": false
}
}
```
| Field | Type | Description |
|-------|------|-------------|
| name | string | Name of the frpc instance |
| initSystem | string | Operating system init system: "windows", "systemd", or "init.d" |
| serviceName | string | Service name (Linux only) |
| isRunning | boolean | Instance running status: true (running) or false (stopped) |
---
## Create Proxy
**Endpoint:** `/frpcAct/proxyMgr/create`
@@ -685,7 +943,6 @@ X-Timestamp: 1704067200000
"success": true,
"message": "Proxy created successfully",
"data": {
"instanceName": "my_frpc",
"instanceID": 1,
"configPath": "./configs/superfrpc_user_my_frpc.toml",
"proxyName": "ssh_proxy"
@@ -695,7 +952,6 @@ X-Timestamp: 1704067200000
| 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 |
@@ -761,7 +1017,6 @@ X-Timestamp: 1704067200000
"success": true,
"message": "Proxy deleted successfully",
"data": {
"instanceName": "my_frpc",
"instanceID": 1,
"configPath": "./configs/superfrpc_user_my_frpc.toml",
"proxyName": "ssh_proxy"
@@ -771,7 +1026,6 @@ X-Timestamp: 1704067200000
| 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 deleted proxy |
@@ -820,7 +1074,6 @@ X-Timestamp: 1704067200000
"message": "Proxies listed successfully",
"data": {
"instanceID": 1,
"instanceName": "my_frpc",
"proxyCount": 2,
"proxies": [
{
@@ -845,7 +1098,6 @@ X-Timestamp: 1704067200000
| Field | Type | Description |
|-------|------|-------------|
| instanceID | int | Instance ID |
| instanceName | string | Name of the frpc instance |
| proxyCount | int | Number of proxies |
| proxies | array | List of proxy configurations |