Skip to content

Commit 1f4644b

Browse files
committed
docs: clarify setup instructions
1 parent 1f28877 commit 1f4644b

1 file changed

Lines changed: 67 additions & 19 deletions

File tree

README.md

Lines changed: 67 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -166,23 +166,57 @@ sequenceDiagram
166166
end
167167
```
168168

169+
## Running Hyperion for testing in a development environment
169170

170-
## Running
171+
First, clone this repostiory with:
172+
173+
```bash
174+
git clone https://github.com/hyperion-mc/hyperion.git
175+
```
176+
177+
Then enter the repository directory with:
178+
179+
```bash
180+
cd hyperion
181+
```
182+
183+
Then generate keys. This requires `openssl` to be installed. Note that `-days 365` specifies the the number of days until the certificate expires.
184+
185+
> [!WARNING]
186+
> All private keys (`.pem` files) must be stored securely. Do not send these private keys to anyone.
187+
188+
```bash
189+
openssl req -new -nodes -newkey rsa:4096 -keyout root_ca.pem -x509 -out root_ca.crt -days 365 -subj /
190+
openssl req -nodes -newkey rsa:4096 -keyout game_private_key.pem -out game.csr -subj /
191+
openssl x509 -req -in game.csr -CA root_ca.crt -CAkey root_ca.pem -CAcreateserial -out game.crt -days 365 -sha256 -extfile <(printf "subjectAltName=DNS:localhost,IP:127.0.0.1")
192+
rm game.csr
193+
openssl req -nodes -newkey rsa:4096 -keyout proxy_private_key.pem -out proxy.csr -subj /
194+
openssl x509 -req -in proxy.csr -CA root_ca.crt -CAkey root_ca.pem -CAcreateserial -out proxy.crt -days 365 -sha256 -extfile <(printf "subjectAltName=DNS:localhost,IP:127.0.0.1")
195+
rm proxy.csr
196+
```
197+
198+
Now run the game server. Note that the game server automatically starts the proxy.
199+
200+
```bash
201+
cargo run --release --bin bedwars -- --ip 127.0.0.1 --root-ca-cert root_ca.crt --cert game.crt --private-key game_private_key.pem
202+
```
203+
204+
You can now connect a 1.20.1 Minecraft client to the game server at port `25565`, such as through `127.0.0.1:25565` or `domain_name:25565`.
205+
206+
## Running Hyperion in a production environment
171207

172208
### Network topology
173209

174210
Hyperion uses one game server which runs all game-related code (e.g. physics, game events). One or more proxies can connect to the game server. Players connect to one of the proxies.
175211

176-
For development and testing purposes, it is okay to run one game server and one proxy on the same server. When generating keys, you will need to change the key and certificate file names used below to avoid file name conflicts.
177-
178-
On a production environment, the game server and each proxy should run on separate servers for performance.
212+
On a production environment, the game server and each proxy should run on separate servers to improve performance.
179213

180214
### Generating keys and certificates
181215

182216
The connection between the game server and the proxies are encrypted through mTLS to ensure that the connection is secure and authenticate the proxies.
183217

184218
> [!WARNING]
185-
> All private keys must be stored securely, and it is strongly recommended to generate the private keys on the server that will use them instead of transferring them over the Internet. Malicious proxies that have access to a private key can circumvent player authentication and can cause the game server to exhibit undefined behavior which can potentially lead to arbitrary code execution on the game server. If any private key has been compromised, redo this section to create new keys.
219+
> All private keys (`.pem` files) must be stored securely, and it is strongly recommended to generate the private keys on the server that will use them instead of transferring them over the Internet. Do not send these private keys to anyone. Malicious proxies that have access to a private key can circumvent player authentication and can cause the game server to exhibit undefined behavior which can potentially lead to arbitrary code execution on the game server. If any private key has been compromised, redo this section to create new keys.
186220
187221
#### Create a private certificate authority (CA)
188222

@@ -191,14 +225,12 @@ A server should be picked to store the certificate authority keys and will be re
191225
On the certificate authority server, generate a key and certificate by running:
192226

193227
```bash
194-
openssl req -new -nodes -newkey rsa:4096 -keyout root_ca.pem -x509 -out root_ca.crt -days 365
228+
openssl req -new -nodes -newkey rsa:4096 -keyout root_ca.pem -x509 -out root_ca.crt -days 365 -subj /
195229
```
196230

197-
OpenSSL will ask for information when running the command. All fields can be left empty.
198-
199231
The `-days` field specifies when the certificate will expire. It will expire in 365 days in the above command, but this can be modified as needed.
200232

201-
`root_ca.crt` is the root CA cert and should be copied to the game server and all proxy servers. When running the game server or the proxy, make sure to pass `--root-ca-cert root_ca.crt` as a command line flag.
233+
`root_ca.crt` is the root CA cert and should be copied to the game server and all proxy servers.
202234

203235
#### Generate server keys and certificates
204236

@@ -207,11 +239,9 @@ Follow these instructions for the game server and each proxy server. The server
207239
On the target server, run:
208240

209241
```bash
210-
openssl req -nodes -newkey rsa:4096 -keyout server_private_key.pem -out server.csr
242+
openssl req -nodes -newkey rsa:4096 -keyout server_private_key.pem -out server.csr -subj /
211243
```
212244

213-
OpenSSL will ask for information when running the command. All fields can be left empty.
214-
215245
Afterwards, transfer `server.csr` to the certificate authority server. On the certificate authority server, run:
216246

217247
```bash
@@ -227,24 +257,42 @@ Then, transfer `server.crt` to the target server.
227257

228258
`server.csr` and `server.crt` on the certificate authority server and `server.csr` on the target server are no longer needed and may be deleted.
229259

230-
`server.crt` is the target server's certificate and `server_private_key.pem` is the target server's private key. When running the game server or the proxy, make sure to pass `--cert server.crt --private-key server_private_key.pem` as a command line flag.
260+
### With local build
261+
262+
#### Running the proxy
263+
264+
First, compile the proxy on a machine with Cargo installed:
231265

232-
### Without cloning
266+
```bash
267+
cargo build --release --bin hyperion-proxy
268+
```
269+
270+
If the proxy servers are running on different targets (e.g. different CPU architectures, different OS, different libc), you will need to compile the proxy for each target.
271+
272+
Now, copy `target/release/hyperion-proxy` to each proxy server.
273+
274+
On each proxy server, run:
233275

234276
```bash
235-
curl -L https://raw.githubusercontent.com/hyperion-mc/hyperion/main/docker-compose.yml | docker compose -f - up --pull always
277+
./hyperion-proxy 0.0.0.0:25565 --server game_server_ip:35565 --root-ca-cert root_ca.crt --cert server.crt --private-key server_private_key.pem
236278
```
237279

238-
### `main` branch
280+
Replace `game_server_ip` with the IP or domain name of the game server. Note that this must match the `subjectAltName` used to generate the game server certificate above.
281+
282+
#### Running the game server
283+
284+
First, compile the game server on a machine with Cargo installed that is the same target as the game server (i.e. same CPU architecture, same OS, same libc). This can also be compiled directly on the game server.
239285

240286
```bash
241-
docker compose up --pull always
287+
cargo build --release --bin bedwars
242288
```
243289

244-
### With local build (for development)
290+
Now, copy `target/release/bedwars` to the game server.
291+
292+
On the game server, run:
245293

246294
```bash
247-
docker compose up --build
295+
./bedwars --root-ca-cert root_ca.crt --cert server.crt --private-key server_private_key.pem
248296
```
249297

250298
## Features

0 commit comments

Comments
 (0)