Browse Source

up README_EN.md

ljw 1 year ago
parent
commit
03bd34cadd
1 changed files with 187 additions and 102 deletions
  1. 187 102
      README_EN.md

+ 187 - 102
README_EN.md

@@ -1,6 +1,7 @@
1 1
 # RustDesk API
2 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.
3
+This project implements the RustDesk API using Go, and includes both a web UI and web client. RustDesk is a remote
4
+desktop software that provides self-hosted solutions.
4 5
 
5 6
 <div align=center>
6 7
 <img src="https://img.shields.io/badge/golang-1.22-blue"/>
@@ -9,64 +10,104 @@ This project implements RustDesk's API using Go and includes a Web UI and Web cl
9 10
 <img src="https://img.shields.io/badge/swag-v1.16.3-yellow"/>
10 11
 </div>
11 12
 
12
-## Preparation
13
+## Prerequisites
13 14
 
14 15
 ### [Rustdesk](https://github.com/rustdesk/rustdesk)
15 16
 
16 17
 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
+2. The server must specify a key, and not use the auto-generated key, otherwise there may be connection failures or
19
+   timeouts.
18 20
 
19
-```bash
20
-hbbs -r <relay-server-ip[:port]> -k 123456789
21
-hbbr -k 123456789
22
-```
21
+   ```bash
22
+   hbbs -r <relay-server-ip[:port]> -k <key>
23
+   hbbr -k <key>
24
+   ```
25
+
26
+   Example:
27
+
28
+   ```bash
29
+   hbbs -r <relay-server-ip[:port]> -k abc1234567
30
+   hbbr -k abc1234567
31
+   ```
23 32
 
24 33
 ## Features
25 34
 
26
-### **API Service**: Implements the basic interfaces for the PC client.
35
+### API Service: Basic implementation of the PC client's primary interfaces.
36
+
37
+#### Login
38
+
39
+- Added `GitHub` login, which can be used after configuration in the admin panel. See the OAuth configuration section
40
+  for details.
41
+- Added authorization login for the web admin panel.
42
+
43
+![pc_login](docs/pc_login.png)
44
+
45
+#### Address Book
27 46
 
28 47
 ![pc_ab](docs/pc_ab.png)
48
+
49
+#### Groups: Groups are divided into `shared groups` and `regular groups`. In shared groups, everyone can see the addresses of all group members, while in regular groups, only administrators can see all members' addresses.
50
+
29 51
 ![pc_gr](docs/pc_gr.png)
30 52
 
31
-### **Web UI**: Uses a front-end and back-end separation, providing a user-friendly management interface primarily for administration and display.
53
+### **Web UI
32 54
 
33
-***The front-end code is available at [rustdesk-api-web](https://github.com/lejianwen/rustdesk-api-web).***
55
+**: The frontend and backend are separated to provide a user-friendly management interface, primarily for managing and
56
+displaying data.
34 57
 
35
-***The admin panel can be accessed at `http://<your server>:21114/_admin/` with default credentials of `admin admin`. Please change the password promptly.***
58
+***Frontend code is available at [rustdesk-api-web](https://github.com/lejianwen/rustdesk-api-web)***
36 59
 
37
-1. Admin interface  
60
+***Admin panel URL: `http://<your server>[:port]/_admin/`. The default username and password for the initial
61
+installation are `admin` `admin`, please change the password immediately.***
62
+
63
+1. Admin interface:
38 64
    ![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  
65
+2. Regular user interface:
66
+   ![web_user](docs/web_admin_user.png)
67
+3. You can change your password from the top right corner:
42 68
    ![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`.  
69
+4. Groups can be customized for easy management. Currently, two types are supported: `shared group` and `regular group`.
44 70
    ![web_admin_gr](docs/web_admin_gr.png)
71
+5. You can open the web client directly for convenience:
72
+   ![web_webclient](docs/admin_webclient.png)
73
+6. OAuth support: Currently, only `GitHub` is supported. You need to create an `OAuth App` and configure it in the admin
74
+   panel.
75
+   ![web_admin_oauth](docs/web_admin_oauth.png)
76
+    - Create a `GitHub OAuth App`
77
+      at `Settings` -> `Developer settings` -> `OAuth Apps` -> `New OAuth App` [here](https://github.com/settings/developers).
78
+    - Set the `Authorization callback URL` to `http://<your server[:port]>/api/oauth/callback`,
79
+      e.g., `http://127.0.0.1:21114/api/oauth/callback`.
45 80
 
46 81
 ### **Web Client**:
47 82
 
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.  
83
+1. If you're already logged into the admin panel, the web client will log in automatically.
84
+2. If you're not logged in, simply click the login button at the top right corner, and the API server will be
85
+   pre-configured.
51 86
    ![webclient_conf](docs/webclient_conf.png)
87
+3. After logging in, the ID server and key will be automatically synced.
88
+4. The address book will also be automatically saved to the web client for convenient use.
89
+
90
+### **Automated Documentation
52 91
 
53
-### **Automated Documentation**: API documentation is generated using Swag, making it easier for developers to understand and use the API.
92
+**: API documentation is generated using Swag, making it easier for developers to understand and use the API.
54 93
 
55
-1. Admin documentation: `<your server>/admin/swagger/index.html`
56
-2. PC client documentation: `<your server>/swagger/index.html`  
94
+1. Admin panel docs: `<your server>/admin/swagger/index.html`
95
+2. PC client docs: `<your server>/swagger/index.html`
57 96
    ![api_swag](docs/api_swag.png)
58 97
 
59
-## Installation and Running
98
+## Installation and Setup
60 99
 
61 100
 ### Configuration
62 101
 
63
-* Refer to the `conf/config.yaml` file to modify relevant configurations. If `gorm.type` is `sqlite`, MySQL configurations are not required.
102
+* Modify the configuration in `conf/config.yaml`. If `gorm.type` is set to `sqlite`, MySQL-related configurations are
103
+  not required.
64 104
 
65 105
 ```yaml
66 106
 gin:
67 107
   api-addr: "0.0.0.0:21114"
68 108
   mode: "release"
69 109
   resources-path: 'resources'
110
+  trust-proxy: ""
70 111
 gorm:
71 112
   type: "sqlite"
72 113
   max-idle-conns: 10
@@ -83,88 +124,128 @@ rustdesk:
83 124
   key: "123456789"
84 125
 ```
85 126
 
127
+* Environment variables, with the prefix `RUSTDESK_API`, will override the settings in the configuration file if
128
+  present.
129
+
130
+| Variable Name                      | Description                                               | Example                        |
131
+|------------------------------------|-----------------------------------------------------------|--------------------------------|
132
+| ----- GIN Configuration -----      | ---------------------------------------                   | ------------------------------ |
133
+| RUSTDESK_API_GIN_TRUST_PROXY       | Trusted proxy IPs, separated by commas.                   | 192.168.1.2,192.168.1.3        |
134
+| ----- GORM Configuration -----     | ---------------------------------------                   | ------------------------------ |
135
+| RUSTDESK_API_GORM_TYPE             | Database type (`sqlite` or `mysql`). Default is `sqlite`. | sqlite                         |
136
+| RUSTDESK_API_GORM_MAX_IDLE_CONNS   | Maximum idle connections                                  | 10                             |
137
+| RUSTDESK_API_GORM_MAX_OPEN_CONNS   | Maximum open connections                                  | 100                            |
138
+| ----- MYSQL Configuration -----    | ---------------------------------------                   | ------------------------------ |
139
+| RUSTDESK_API_MYSQL_USERNAME        | MySQL username                                            | root                           |
140
+| RUSTDESK_API_MYSQL_PASSWORD        | MySQL password                                            | 111111                         |
141
+| RUSTDESK_API_MYSQL_ADDR            | MySQL address                                             | 192.168.1.66:3306              |
142
+| RUSTDESK_API_MYSQL_DBNAME          | MySQL database name                                       | rustdesk                       |
143
+| ----- RUSTDESK Configuration ----- | ---------------------------------------                   | ------------------------------ |
144
+| RUSTDESK_API_RUSTDESK_ID_SERVER    | Rustdesk ID server address                                | 192.168.1.66:21116             |
145
+| RUSTDESK_API_RUSTDESK_RELAY_SERVER | Rustdesk relay server address                             | 192.168.1.66:21117             |
146
+| RUSTDESK_API_RUSTDESK_API_SERVER   | Rustdesk API server address                               | http://192.168.1.66:21114      |
147
+| RUSTDESK_API_RUSTDESK_KEY          | Rustdesk key                                              | 123456789                      |
148
+
86 149
 ### Installation Steps
87 150
 
88
-#### Running with Docker
151
+#### Running via Docker
89 152
 
90
-1. Run directly using Docker:
153
+1. Run directly with Docker. Configuration can be modified by mounting the config file `/app/conf/config.yaml`, or by
154
+   using environment variables to override settings.
91 155
 
92 156
 ```bash
93
-docker run -d --name rustdesk-api -p 21114:21114 -v /data/rustdesk/api:/app/data lejianwen/rustdesk-api
157
+docker run -d --name rustdesk-api -p 21114:21114 \
158
+-v /data/rustdesk/api:/app/data \
159
+-e RUSTDESK_API_RUSTDESK_ID_SERVER=192.168.1.66:21116 \
160
+-e RUSTDESK_API_RUSTDESK_RELAY_SERVER=192.168.1.66:21117 \
161
+-e RUSTDESK_API_RUSTDESK_API_SERVER=http://192.168.1.66:21114 \
162
+-e RUSTDESK_API_RUSTDESK_KEY=123456789 \
163
+lejianwen/rustdesk-api
94 164
 ```
95 165
 
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
-```
166
+2. Using `docker-compose`
167
+
168
+    - Simple example:
169
+
170
+   ```docker-compose
171
+   services:
172
+      rustdesk-api:
173
+       container_name: rustdesk-api
174
+       environment:
175
+         - RUSTDESK_API_RUSTDESK_ID_SERVER=192.168.1.66:21116
176
+         - RUSTDESK_API_RUSTDESK_RELAY_SERVER=192.168.1.66:21117
177
+         - RUSTDESK_API_RUSTDESK_API_SERVER=http://192.168.1.66:21114
178
+         - RUSTDESK_API_RUSTDESK_KEY=123456789
179
+       ports:
180
+         - 21114:21114
181
+       image: lejianwen/rustdesk-api
182
+       volumes:
183
+         - /data/rustdesk/api:/app/data # Mount the database for easy backup
184
+       networks:
185
+         - rustdesk-net
186
+       restart: unless-stopped
187
+   ```
188
+
189
+    - Example with RustDesk's official Docker Compose file, adding your `rustdesk-api` service:
190
+
191
+   ```docker-compose
192
+   networks:
193
+     rustdesk-net:
194
+       external: false
195
+   services:
196
+     hbbs:
197
+       container_name: hbbs
198
+       ports:
199
+         - 21115:21115
200
+         - 21116:21116 # 自定义 hbbs 映射端口
201
+         - 21116:21116/udp # 自定义 hbbs 映射端口
202
+         - 21118:21118 # web client 需要
203
+       image: rustdesk/rustdesk-server
204
+       command: hbbs -r <relay-server-ip[:port]> -k 123456789 # 填入个人域名或 IP + hbbr 暴露端口
205
+       volumes:
206
+         - /data/rustdesk/hbbs:/root # 自定义挂载目录
207
+       networks:
208
+         - rustdesk-net
209
+       depends_on:
210
+         - hbbr
211
+       restart: unless-stopped
212
+       deploy:
213
+         resources:
214
+           limits:
215
+             memory: 64M
216
+     hbbr:
217
+       container_name: hbbr
218
+       ports:
219
+         - 21117:21117 # 自定义 hbbr 映射端口
220
+       image: rustdesk/rustdesk-server
221
+       command: hbbr -k 123456789
222
+       #command: hbbr
223
+       volumes:
224
+         - /data/rustdesk/hbbr:/root # 自定义挂载目录
225
+       networks:
226
+         - rustdesk-net
227
+       restart: unless-stopped
228
+       deploy:
229
+         resources:
230
+           limits:
231
+             memory: 64M
232
+     rustdesk-api:
233
+       container_name: rustdesk-api
234
+       environment:
235
+         - RUSTDESK_API_RUSTDESK_ID_SERVER=192.168.1.66:21116
236
+         - RUSTDESK_API_RUSTDESK_RELAY_SERVER=192.168.1.66:21117
237
+         - RUSTDESK_API_RUSTDESK_API_SERVER=http://192.168.1.66:21114
238
+         - RUSTDESK_API_RUSTDESK_KEY=123456789
239
+       ports:
240
+         - 21114:21114
241
+       image: lejianwen/rustdesk-api
242
+       volumes:
243
+         - /data/rustdesk/api:/app/data #将数据库挂载出来方便备份
244
+       networks:
245
+         - rustdesk-net
246
+       restart: unless-stopped
247
+   
248
+   ```
168 249
 
169 250
 #### Running from Release
170 251
 
@@ -186,7 +267,8 @@ Download the release from [release](https://github.com/lejianwen/rustdesk-api/re
186 267
     go install github.com/swaggo/swag/cmd/swag@latest
187 268
     ```
188 269
 
189
-3. Build the admin front-end (the front-end code is in [rustdesk-api-web](https://github.com/lejianwen/rustdesk-api-web)):
270
+3. Build the admin front-end (the front-end code is
271
+   in [rustdesk-api-web](https://github.com/lejianwen/rustdesk-api-web)):
190 272
    ```bash
191 273
    cd resources
192 274
    mkdir -p admin
@@ -205,9 +287,12 @@ Download the release from [release](https://github.com/lejianwen/rustdesk-api/re
205 287
     go generate generate_api.go
206 288
     ```
207 289
 
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.
290
+5. To compile, change to the project root directory. For Windows, run `build.bat`, and for Linux, run `build.sh`. After
291
+   compiling, the corresponding executables will be generated in the `release` directory. Run the compiled executables
292
+   directly.
209 293
 
210
-6. Open your browser and visit `http://<your server>:21114/_admin/`, with default credentials `admin admin`. Please change the password promptly.
294
+6. Open your browser and visit `http://<your server>:21114/_admin/`, with default credentials `admin admin`. Please
295
+   change the password promptly.
211 296
 
212 297
 ## Miscellaneous
213 298