Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Reverier-Xu committed Oct 22, 2024
2 parents a18c112 + 0e10469 commit 10bb92e
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

env:
APP_NAME: "WebSocketReflectorX"
APP_VERSION: "0.2.28"
APP_VERSION: "0.2.29"

#-------------------------------------------------------------------------------
# Workflow jobs
Expand Down Expand Up @@ -51,11 +51,11 @@ jobs:

# Deploy Glibc application
- name: Compress Glibc Binaries
run: tar --transform='s!.*/!!' -cvf wsrx-cli-${{env.APP_VERSION}}-linux64-gnu.tar.gz target/release/wsrx
run: tar --transform='s!.*/!!' -czvf wsrx-cli-${{env.APP_VERSION}}-linux64-gnu.tar.gz target/release/wsrx

# Deploy musl application
- name: Compress musl Binaries
run: tar --transform='s!.*/!!' -cvf wsrx-cli-${{env.APP_VERSION}}-linux64-musl.tar.gz target/x86_64-unknown-linux-musl/release/wsrx
run: tar --transform='s!.*/!!' -czvf wsrx-cli-${{env.APP_VERSION}}-linux64-musl.tar.gz target/x86_64-unknown-linux-musl/release/wsrx

# Upload application ZIP
- name: Upload application ZIP
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:

env:
APP_NAME: "WebSocketReflectorX"
APP_VERSION: "0.2.28"
APP_VERSION: "0.2.29"
QT_VERSION: "6.7.1"

#-------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

env:
APP_NAME: "WebSocketReflectorX"
APP_VERSION: "0.2.28"
APP_VERSION: "0.2.29"
QT_VERSION: "6.7.1"

#-------------------------------------------------------------------------------
Expand Down
58 changes: 58 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Local Daemon API

WebSocket Reflector X provides a local API server to control it from remote.

## Start the daemon API server

WebSocket Reflector X Desktop App will automatically start the daemon server at `127.0.0.1:3307`, if `3307` is not available, it will fallback to random available port, you can get it from the Logs panel in Desktop App.

If you want to integrate the daemon server from `popen` without desktop app, you can run the daemon server with the options below:

```shell
$ wsrx daemon
```

Available options could be shown by `--help`:

```
$ wsrx daemon --help
Launch wsrx daemon
Usage: wsrx daemon [OPTIONS]
Options:
--host <HOST> The admin and ws http address to listen on
-p, --port <PORT> The admin and ws http port to listen on
-s, --secret <SECRET>
-l, --log-json <LOG_JSON> Log in json format [possible values: true, false]
--heartbeat <HEARTBEAT> The heartbeat interval in seconds. If not set, the daemon will not automatically exit when heartbeat timeout
-h, --help Print help
```

## Admin API

### Auth

WebSocket Reflector X's API daemon server has two methods to protect the admin API.

#### HTTP-Header `Authorization`

If you launch the daemon server with option `-s xxx` or `--secret xxx`, the API server will protect admin route with authorization header validation. You should insert `Authorization: xxx` in every request headers.

#### CORS protection

By default, the daemon server will reject any request from a different host. If you want to access daemon server from the browser (eg. WebApp integration), you could send connect request to:

```
$ curl -v -i -X POST http://127.0.0.1:3307/connect --data '"https://your.website"' --header 'Content-Type: application/json'
```

this will add your website origin to the pending list. You can check your website status through this endpoint:

```
$ curl -v -i http://127.0.0.1:3307/connect
```

## WIP

refer to [daemon.rs](https://github.com/XDSEC/WebSocketReflectorX/blob/master/wsrx/src/cli/daemon.rs#L100) and [daemon.h](https://github.com/XDSEC/WebSocketReflectorX/blob/master/desktop/daemon.h)

0 comments on commit 10bb92e

Please sign in to comment.