-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
149 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
# QNAP Build | ||
|
||
To build Teliod package for QNAP devices there are two alternatives: | ||
|
||
- Run cargo build directly: | ||
```cargo build --verbose --target x86_64-unknown-linux-musl --package teliod --features qnap``` | ||
|
||
- Run build script [Recommended]: | ||
```../../ci/build_libtelio.py build qnap x86_64 [--debug]``` | ||
|
||
The build script has an additional stage at the end of the build where it creates the QNAP package. | ||
|
||
## REST API | ||
|
||
This REST API allows interaction with the Teliod daemon. It provides endpoints for managing the daemon, updating its configuration, and retrieving logs and status information. | ||
|
||
--- | ||
|
||
### Endpoints | ||
|
||
#### 1. **Start the Daemon** | ||
|
||
- **Endpoint**: `/` | ||
- **Method**: `POST` | ||
- **Description**: Starts the Teliod Daemon in the background. | ||
- **Request Body**: None | ||
- **Responses**: | ||
- **200 OK**: Daemon started successfully. | ||
- **400 Bad Request**: Daemon is already running. | ||
- **500 Internal Server Error**: Failed to start the daemon. | ||
|
||
--- | ||
|
||
#### 2. **Stop the Daemon** | ||
|
||
- **Endpoint**: `/` | ||
- **Method**: `DELETE` | ||
- **Description**: Stops the running Teliod Daemon. | ||
- **Request Body**: None | ||
- **Responses**: | ||
- **200 OK**: Daemon stopped successfully. | ||
- **400 Bad Request**: Daemon is not running. | ||
- **500 Internal Server Error**: Failed to stop the daemon. | ||
|
||
--- | ||
|
||
#### 3. **Update Configuration** | ||
|
||
- **Endpoint**: `/` | ||
- **Method**: `PATCH` | ||
- **Description**: Updates the daemon configuration with provided settings. | ||
- **Request Body**: JSON object containing the configuration updates. Only specified fields will be updated; others remain unchanged. | ||
- **Example Request Body**: | ||
```json | ||
{ | ||
"log_level": "info", | ||
"log_file_path": "/new/path/to/log.log" | ||
} | ||
``` | ||
- **Responses**: | ||
- **200 OK**: Configuration updated successfully | ||
- **400 Bad Request**: Invalid JSON payload or configuration fields. | ||
- **500 Internal Server Error**: Failed to update configuration. | ||
|
||
--- | ||
|
||
### 4. **Get Meshnet Status** | ||
|
||
- **Endpoint**: `/?info=get-status` | ||
- **Method**: `GET` | ||
- **Description**: Retrieves the current status of the Meshnet from Teliod daemon. | ||
- **Request Body**: None | ||
- **Responses**: | ||
- **200 OK**: Status information in JSON format. | ||
```json | ||
{ | ||
"telio_is_running": true, | ||
"meshnet_ip": null, | ||
"external_nodes": [] | ||
... | ||
} | ||
``` | ||
- **500 Internal Server Error**: Failed to retrieve status. | ||
|
||
--- | ||
|
||
### 5. **Get Meshnet Logs** | ||
|
||
- **Endpoint**: `/?info=get-meshnet-logs` | ||
- **Method**: `GET` | ||
- **Description**: Retrieves the latest logs of the Meshnet. | ||
- **Request Body**: None | ||
- **Responses**: | ||
- **200 OK**: Log content in JSON format. | ||
```json | ||
{ | ||
"Log line 1\nLog line 2\nLog line 3\n..." | ||
} | ||
``` | ||
- **404 Not Found**: Log file not found. | ||
|
||
--- | ||
|
||
### 6. **Get Teliod Logs** | ||
|
||
- **Endpoint**: `/?info=get-teliod-logs` | ||
- **Method**: `GET` | ||
- **Description**: Retrieves the latest logs of the Teliod Daemon. | ||
- **Request Body**: None | ||
- **Responses**: | ||
- **200 OK**: Log content in JSON format. | ||
```json | ||
{ | ||
"Log line 1\nLog line 2\nLog line 3\n..." | ||
} | ||
``` | ||
- **404 Not Found**: Log file not found. | ||
|
||
--- | ||
|
||
## Error Handling | ||
|
||
For all endpoints, the following error codes may be returned: | ||
- **400 Bad Request**: The request was malformed or invalid. | ||
- **500 Internal Server Error**: An unexpected error occurred while processing the request. | ||
|
||
--- | ||
|
||
## Example Usage with curl | ||
|
||
### Start Teliod daemon | ||
```bash | ||
curl -X POST http://<NAS-IP>:8080/ | ||
``` | ||
|
||
### Stop Teliod daemon | ||
```bash | ||
curl -X POST http://<NAS-IP>:8080/ | ||
``` | ||
|
||
### Get Meshnet logs | ||
```bash | ||
curl -X GET "http://<NAS-IP>:8080/?info=get-meshnet-logs" | ||
``` | ||
|
||
### Update Config | ||
```bash | ||
curl -X PATCH -H "Content-Type: application/json" -d '{"log_level":"info", authentication_token": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"}' http://<NAS-IP>:8080/cgi-bin/qpkg/teliod.cgi | ||
``` |