ljw 1 год назад
Родитель
Сommit
c8b3d41d9d
2 измененных файлов с 216 добавлено и 0 удалено
  1. 1 0
      README.md
  2. 215 0
      README_EN.md

+ 1 - 0
README.md

@@ -1,4 +1,5 @@
1 1
 # RustDesk API
2
+[English Doc](README_EN.md)
2 3
 
3 4
 本项目使用 Go 实现了 RustDesk 的 API,并包含了 Web UI 和 Web 客户端。RustDesk 是一个远程桌面软件,提供了自托管的解决方案。
4 5
 

+ 215 - 0
README_EN.md

@@ -0,0 +1,215 @@
1
+# RustDesk API
2
+
3
+This project implements RustDesk's API using Go and includes a Web UI and Web client. RustDesk is a remote desktop software that provides a self-hosting solution.
4
+
5
+<div align=center>
6
+<img src="https://img.shields.io/badge/golang-1.22-blue"/>
7
+<img src="https://img.shields.io/badge/gin-v1.9.0-lightBlue"/>
8
+<img src="https://img.shields.io/badge/gorm-v1.25.7-green"/>
9
+<img src="https://img.shields.io/badge/swag-v1.16.3-yellow"/>
10
+</div>
11
+
12
+## Preparation
13
+
14
+### [Rustdesk](https://github.com/rustdesk/rustdesk)
15
+
16
+1. The PC client version used is ***1.3.0***, and versions ***1.2.6+*** have been tested to work.
17
+2. The server must specify a key and not use the built-in generated key; otherwise, connection issues or timeouts may occur.
18
+
19
+```bash
20
+hbbs -r <relay-server-ip[:port]> -k 123456789
21
+hbbr -k 123456789
22
+```
23
+
24
+## Features
25
+
26
+### **API Service**: Implements the basic interfaces for the PC client.
27
+
28
+![pc_ab](docs/pc_ab.png)
29
+![pc_gr](docs/pc_gr.png)
30
+
31
+### **Web UI**: Uses a front-end and back-end separation, providing a user-friendly management interface primarily for administration and display.
32
+
33
+***The front-end code is available at [rustdesk-api-web](https://github.com/lejianwen/rustdesk-api-web).***
34
+
35
+***The admin panel can be accessed at `http://<your server>:21114/_admin/` with default credentials of `admin admin`. Please change the password promptly.***
36
+
37
+1. Admin interface  
38
+   ![web_admin](docs/web_admin.png)
39
+2. Regular user interface  
40
+   ![web_user](docs/web_user.png)
41
+3. Password can be changed from the top-right corner  
42
+   ![web_resetpwd](docs/web_resetpwd.png)
43
+4. Groups can be customized for easier management. Two types of groups are currently supported: `Shared Group` and `Regular Group`.  
44
+   ![web_admin_gr](docs/web_admin_gr.png)
45
+
46
+### **Web Client**:
47
+
48
+1. If you are already logged in to the admin panel, the web client will automatically log in.
49
+2. If not logged in, click the login button in the top-right corner; the API server will be auto-configured.
50
+3. Once logged into the admin panel, the address book will be saved automatically in the web client for convenience.  
51
+   ![webclient_conf](docs/webclient_conf.png)
52
+
53
+### **Automated Documentation**: API documentation is generated using Swag, making it easier for developers to understand and use the API.
54
+
55
+1. Admin documentation: `<your server>/admin/swagger/index.html`
56
+2. PC client documentation: `<your server>/swagger/index.html`  
57
+   ![api_swag](docs/api_swag.png)
58
+
59
+## Installation and Running
60
+
61
+### Configuration
62
+
63
+* Refer to the `conf/config.yaml` file to modify relevant configurations. If `gorm.type` is `sqlite`, MySQL configurations are not required.
64
+
65
+```yaml
66
+gin:
67
+  api-addr: "0.0.0.0:21114"
68
+  mode: "release"
69
+  resources-path: 'resources'
70
+gorm:
71
+  type: "sqlite"
72
+  max-idle-conns: 10
73
+  max-open-conns: 100
74
+mysql:
75
+  username: "root"
76
+  password: "111111"
77
+  addr: "192.168.1.66:3308"
78
+  dbname: "rustdesk"
79
+rustdesk:
80
+  id-server: "192.168.1.66:21116"
81
+  relay-server: "192.168.1.66:21117"
82
+  api-server: "http://192.168.1.66:21114"
83
+  key: "123456789"
84
+```
85
+
86
+### Installation Steps
87
+
88
+#### Running with Docker
89
+
90
+1. Run directly using Docker:
91
+
92
+```bash
93
+docker run -d --name rustdesk-api -p 21114:21114 -v /data/rustdesk/api:/app/data lejianwen/rustdesk-api
94
+```
95
+
96
+- Environment variables with the prefix `RUSTDESK_API` can be set.
97
+
98
+| Variable Name                         | Description                                      | Example                      |
99
+|----------------------------------------|--------------------------------------------------|------------------------------|
100
+| -----------GORM Configuration----------| -------------------------------------------------| -----------------------------|
101
+| RUSTDESK_API_GORM_TYPE                | Database type, either `sqlite` or `mysql`. Default is `sqlite` | sqlite                       |
102
+| RUSTDESK_API_GORM_MAX_IDLE_CONNS      | Maximum number of idle connections                | 10                           |
103
+| RUSTDESK_API_GORM_MAX_OPEN_CONNS      | Maximum number of open connections                | 100                          |
104
+| -----------MySQL Configuration---------| ---Not required if using `sqlite`---              |                              |
105
+| RUSTDESK_API_MYSQL_USERNAME           | MySQL username                                   | root                         |
106
+| RUSTDESK_API_MYSQL_PASSWORD           | MySQL password                                   | 111111                       |
107
+| RUSTDESK_API_MYSQL_ADDR               | MySQL address                                    | 192.168.1.66:3306            |
108
+| RUSTDESK_API_MYSQL_DBNAME             | MySQL database name                              | rustdesk                     |
109
+| -----------Rustdesk Configuration------| -------------------------------------------------| -----------------------------|
110
+| RUSTDESK_API_RUSTDESK_ID_SERVER       | Rustdesk ID server address                       | 192.168.1.66:21116           |
111
+| RUSTDESK_API_RUSTDESK_RELAY_SERVER    | Rustdesk relay server address                    | 192.168.1.66:21117           |
112
+| RUSTDESK_API_RUSTDESK_API_SERVER      | Rustdesk API server address                      | http://192.168.1.66:21114    |
113
+| RUSTDESK_API_RUSTDESK_KEY             | Rustdesk key                                     | 123456789                    |
114
+
115
+2. Use `docker-compose`, adding your RustDesk API configuration to the provided RustDesk example:
116
+
117
+```docker-compose
118
+networks:
119
+  rustdesk-net:
120
+    external: false
121
+services:
122
+  hbbs:
123
+    container_name: hbbs
124
+    ports:
125
+      - 21115:21115
126
+      - 21116:21116 # Custom hbbs port mapping
127
+      - 21116:21116/udp # Custom hbbs port mapping
128
+      - 21118:21118 # Required for web client
129
+    image: rustdesk/rustdesk-server
130
+    command: hbbs -r <relay-server-ip[:port]> -k 123456789 # Use your domain or IP + hbbr exposed port
131
+    volumes:
132
+      - /data/rustdesk/hbbs:/root # Custom mount directory
133
+    networks:
134
+      - rustdesk-net
135
+    depends_on:
136
+      - hbbr
137
+    restart: unless-stopped
138
+    deploy:
139
+      resources:
140
+        limits:
141
+          memory: 64M
142
+  hbbr:
143
+    container_name: hbbr
144
+    ports:
145
+      - 21117:21117 # Custom hbbr port mapping
146
+    image: rustdesk/rustdesk-server
147
+    command: hbbr -k 123456789
148
+    volumes:
149
+      - /data/rustdesk/hbbr:/root # Custom mount directory
150
+    networks:
151
+      - rustdesk-net
152
+    restart: unless-stopped
153
+    deploy:
154
+      resources:
155
+        limits:
156
+          memory: 64M
157
+  rustdesk-api:
158
+    container_name: rustdesk-api
159
+    ports:
160
+      - 21114:21114
161
+    image: lejianwen/rustdesk-api
162
+    volumes:
163
+      - /data/rustdesk/api:/app/data # Mount database for easy backups
164
+    networks:
165
+      - rustdesk-net
166
+    restart: unless-stopped
167
+```
168
+
169
+#### Running from Release
170
+
171
+Download the release from [release](https://github.com/lejianwen/rustdesk-api/releases).
172
+
173
+#### Source Installation
174
+
175
+1. Clone the repository:
176
+   ```bash
177
+   git clone https://github.com/lejianwen/rustdesk-api.git
178
+   cd rustdesk-api
179
+   ```
180
+
181
+2. Install dependencies:
182
+
183
+    ```bash
184
+    go mod tidy
185
+    # Install Swag if you need to generate documentation; otherwise, you can skip this step
186
+    go install github.com/swaggo/swag/cmd/swag@latest
187
+    ```
188
+
189
+3. Build the admin front-end (the front-end code is in [rustdesk-api-web](https://github.com/lejianwen/rustdesk-api-web)):
190
+   ```bash
191
+   cd resources
192
+   mkdir -p admin
193
+   git clone https://github.com/lejianwen/rustdesk-api-web
194
+   cd rustdesk-api-web
195
+   npm install
196
+   npm run build
197
+   cp -ar dist/* ../admin/
198
+   ```
199
+
200
+4. Run:
201
+    ```bash
202
+    # Run directly
203
+    go run cmd/apimain.go
204
+    # Or generate and run the API using generate_api.go
205
+    go generate generate_api.go
206
+    ```
207
+
208
+5. To compile, change to the project root directory. For Windows, run `build.bat`, and for Linux, run `build.sh`. After compiling, the corresponding executables will be generated in the `release` directory. Run the compiled executables directly.
209
+
210
+6. Open your browser and visit `http://<your server>:21114/_admin/`, with default credentials `admin admin`. Please change the password promptly.
211
+
212
+## Miscellaneous
213
+
214
+- [Change client ID](https://github.com/abdullah-erturk/RustDesk-ID-Changer)
215
+- [webclient](https://hub.docker.com/r/keyurbhole/flutter_web_desk)