This project implements the RustDesk API using Go, and includes both a web UI and web client. RustDesk is a remote desktop software that provides self-hosted solutions.
- PC API
- Personal API
- Login
- Address Book
- Groups
- Authorized login, supports
GitHub
,Google
andOIDC
login, supportsweb admin
authorized login - i18n
- Web Admin
- User Management
- Device Management
- Address Book Management
- Tag Management
- Group Management
- OAuth Management
- Login Logs
- Connection Logs
- File Transfer Logs
- Quick access to web client
- i18n
- Share to guest by web client
- Server control (some simple official commands WIKI)
- Web Client
- Automatically obtain API server
- Automatically obtain ID server and KEY
- Automatically obtain address book
- Visitors are remotely to the device via a temporary sharing link
- CLI
- Reset admin password
Basic implementation of the PC client's primary interfaces.Supports the Personal version api, which can be enabled by configuring the rustdesk.personal
file or the RUSTDESK_API_RUSTDESK_PERSONAL
environment variable.
Login | |
Address Book | Groups |
-
The frontend and backend are separated to provide a user-friendly management interface, primarily for managing and displaying data.Frontend code is available at rustdesk-api-web
-
Admin panel URL:
http://<your server[:port]>/_admin/
. The default username and password for the initial installation areadmin
admin
, please change the password immediately.
-
Regular user interface: In the top right corner, you can change the password, switch languages, and toggle between
day/night
mode. -
Each user can have multiple address books, which can also be shared with other users.
-
Groups can be customized for easy management. Currently, two types are supported:
shared group
andregular group
. -
You can directly launch the client or open the web client for convenience; you can also share it with guests, who can remotely access the device via the web client.
-
OAuth support: Currently,
GitHub
,Google
andOIDC
are supported. You need to create anOAuth App
and configure it in the admin panel.- For
Google
andGithub
, you don't need to fill theIssuer
andScpoes
- For
OIDC
, you must set theIssuer
. AndScopes
is optional which default isopenid,email,profile
, please make sure thisOauth App
can accesssub
,email
andpreferred_username
- Create a
GitHub OAuth App
atSettings
->Developer settings
->OAuth Apps
->New OAuth App
here. - Set the
Authorization callback URL
tohttp://<your server[:port]>/api/oauth/callback
, e.g.,http://127.0.0.1:21114/api/oauth/callback
.
- For
-
Login logs
-
Connection logs
-
File transfer logs
-
Server control
-
Simple mode
, some simple commands have been GUI-ized and can be executed directly in the backend -
Advanced mode
, commands can be executed directly in the backend- Official commands can be used
- Custom commands can be added
- Custom commands can be executed
- If you're already logged into the admin panel, the web client will log in automatically.
- If you're not logged in, simply click the login button in the top right corner, and the API server will be pre-configured.
- After logging in, the ID server and key will be automatically synced.
- The address book will also be automatically saved to the web client for convenient use.
- Now supports
v2 Preview
, accessible at/webclient2
v2 preview
deployment, WIKI
Automated Documentation : API documentation is generated using Swag, making it easier for developers to understand and use the API.
- Admin panel docs:
<your server[:port]>/admin/swagger/index.html
- PC client docs:
<your server[:port]>/swagger/index.html
# help
./apimain -h
./apimain reset-admin-pwd <pwd>
- Modify the configuration in
conf/config.yaml
. - If
gorm.type
is set tosqlite
, MySQL-related configurations are not required. - Language support:
en
andzh-CN
are supported. The default iszh-CN
.
lang: "en"
app:
web-client: 1 # web client route 1:open 0:close
register: false #register enable
show-swagger: 0 #show swagger 1:open 0:close
gin:
api-addr: "0.0.0.0:21114"
mode: "release"
resources-path: 'resources'
trust-proxy: ""
gorm:
type: "sqlite"
max-idle-conns: 10
max-open-conns: 100
mysql:
username: "root"
password: "111111"
addr: "192.168.1.66:3308"
dbname: "rustdesk"
rustdesk:
id-server: "192.168.1.66:21116"
relay-server: "192.168.1.66:21117"
api-server: "http://192.168.1.66:21114"
key: "123456789"
personal: 1
logger:
path: "./runtime/log.txt"
level: "warn" #trace,debug,info,warn,error,fatal
report-caller: true
proxy:
enable: false
host: ""
jwt:
key: ""
expire-duration: 360000
The prefix for variable names is RUSTDESK_API
. If environment variables exist, they will override the configurations in the configuration file.
Variable Name | Description | Example |
---|---|---|
TZ | timezone | Asia/Shanghai |
RUSTDESK_API_LANG | Language | en ,zh-CN |
RUSTDESK_API_APP_WEB_CLIENT | web client on/off; 1: on, 0 off, default: 1 | 1 |
RUSTDESK_API_APP_REGISTER | register enable; true , false ; default:false |
false |
RUSTDESK_API_APP_SHOW_SWAGGER | swagger visible; 1: yes, 0: no; default: 0 | 0 |
RUSTDESK_API_APP_TOKEN_EXPIRE | token expire duration(second) | 3600 |
----- ADMIN Configuration----- | ---------- | ---------- |
RUSTDESK_API_ADMIN_TITLE | Admin Title | RustDesk Api Admin |
RUSTDESK_API_ADMIN_HELLO | Admin welcome message, you can use html |
|
RUSTDESK_API_ADMIN_HELLO_FILE | Admin welcome message file, will override RUSTDESK_API_ADMIN_HELLO |
./conf/admin/hello.html |
----- GIN Configuration ----- | --------------------------------------- | ----------------------------- |
RUSTDESK_API_GIN_TRUST_PROXY | Trusted proxy IPs, separated by commas. | 192.168.1.2,192.168.1.3 |
----- GORM Configuration ----- | --------------------------------------- | ----------------------------- |
RUSTDESK_API_GORM_TYPE | Database type (sqlite or mysql ). Default is sqlite . |
sqlite |
RUSTDESK_API_GORM_MAX_IDLE_CONNS | Maximum idle connections | 10 |
RUSTDESK_API_GORM_MAX_OPEN_CONNS | Maximum open connections | 100 |
RUSTDESK_API_RUSTDESK_PERSONAL | Open Personal Api 1:Enable,0:Disable | 1 |
----- MYSQL Configuration ----- | --------------------------------------- | ----------------------------- |
RUSTDESK_API_MYSQL_USERNAME | MySQL username | root |
RUSTDESK_API_MYSQL_PASSWORD | MySQL password | 111111 |
RUSTDESK_API_MYSQL_ADDR | MySQL address | 192.168.1.66:3306 |
RUSTDESK_API_MYSQL_DBNAME | MySQL database name | rustdesk |
----- RUSTDESK Configuration ----- | --------------------------------------- | ----------------------------- |
RUSTDESK_API_RUSTDESK_ID_SERVER | Rustdesk ID server address | 192.168.1.66:21116 |
RUSTDESK_API_RUSTDESK_RELAY_SERVER | Rustdesk relay server address | 192.168.1.66:21117 |
RUSTDESK_API_RUSTDESK_API_SERVER | Rustdesk API server address | http://192.168.1.66:21114 |
RUSTDESK_API_RUSTDESK_KEY | Rustdesk key | 123456789 |
RUSTDESK_API_RUSTDESK_KEY_FILE | Rustdesk key file | ./conf/data/id_ed25519.pub |
RUSTDESK_API_RUSTDESK_WEBCLIENT_MAGIC_QUERYONLINE | New online query method is enabled in the web client v2; '1': Enabled, '0': Disabled, not enabled by default | 0 |
---- PROXY ----- | --------------- | ---------- |
RUSTDESK_API_PROXY_ENABLE | proxy_enable :false , true |
false |
RUSTDESK_API_PROXY_HOST | proxy_host | http://127.0.0.1:1080 |
----JWT---- | -------- | -------- |
RUSTDESK_API_JWT_KEY | JWT KEY. Set empty to disable jwt | |
RUSTDESK_API_JWT_EXPIRE_DURATION | JWT expire duration | 360000 |
-
Run directly with Docker. Configuration can be modified by mounting the config file
/app/conf/config.yaml
, or by using environment variables to override settings.docker run -d --name rustdesk-api -p 21114:21114 \ -v /data/rustdesk/api:/app/data \ -e RUSTDESK_API_LANG=en \ -e RUSTDESK_API_RUSTDESK_ID_SERVER=192.168.1.66:21116 \ -e RUSTDESK_API_RUSTDESK_RELAY_SERVER=192.168.1.66:21117 \ -e RUSTDESK_API_RUSTDESK_API_SERVER=http://192.168.1.66:21114 \ -e RUSTDESK_API_RUSTDESK_KEY=abc123456 \ lejianwen/rustdesk-api
-
Using
docker-compose
,look WIKI
Download the release from release.
-
Clone the repository:
git clone https://github.com/lejianwen/rustdesk-api.git cd rustdesk-api
-
Install dependencies:
go mod tidy # Install Swag if you need to generate documentation; otherwise, you can skip this step go install github.com/swaggo/swag/cmd/swag@latest
-
Build the admin front-end (the front-end code is in rustdesk-api-web):
cd resources mkdir -p admin git clone https://github.com/lejianwen/rustdesk-api-web cd rustdesk-api-web npm install npm run build cp -ar dist/* ../admin/
-
Run:
# Run directly go run cmd/apimain.go # Or generate and run the API using generate_api.go go generate generate_api.go
-
To compile, change to the project root directory. For Windows, run
build.bat
, and for Linux, runbuild.sh
. After compiling, the corresponding executables will be generated in therelease
directory. Run the compiled executables directly. -
Open your browser and visit
http://<your server[:port]>/_admin/
, with default credentialsadmin admin
. Please change the password promptly.
- github https://github.com/lejianwen/rustdesk-server
- docker hub https://hub.docker.com/r/lejianwen/rustdesk-server-s6
networks:
rustdesk-net:
external: false
services:
rustdesk:
ports:
- 21114:21114
- 21115:21115
- 21116:21116
- 21116:21116/udp
- 21117:21117
- 21118:21118
- 21119:21119
image: lejianwen/rustdesk-server-s6:latest
environment:
- RELAY=<relay_server[:port]>
- ENCRYPTED_ONLY=1
- MUST_LOGIN=N
- TZ=Asia/Shanghai
- RUSTDESK_API_RUSTDESK_ID_SERVER=<id_server[:21116]>
- RUSTDESK_API_RUSTDESK_RELAY_SERVER=<relay_server[:21117]>
- RUSTDESK_API_RUSTDESK_API_SERVER=http://<api_server[:21114]>
- RUSTDESK_API_KEY_FILE=/data/id_ed25519.pub
- RUSTDESK_API_JWT_KEY=xxxxxx # jwt key
volumes:
- /data/rustdesk/server:/data
- /data/rustdesk/api:/app/data #将数据库挂载
networks:
- rustdesk-net
restart: unless-stopped
Thanks to everyone who contributed!