Skip to content

Commit ec50878

Browse files
authored
Merge pull request #4 from bilintsui/dev
v1.1
2 parents f6d10e2 + eddec14 commit ec50878

File tree

12 files changed

+2056
-171
lines changed

12 files changed

+2056
-171
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mcrelay:
2+
gcc -o mcrelay mcrelay.c -lresolv

README.md

Lines changed: 87 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,88 @@
1-
# Minecraft Relay Server
1+
# mcrelay
2+
Minecraft Relay Server<br/>
3+
A minecraft reverse proxy server with server address rewrite.<br/>
4+
Supports Minecraft Servers and Clients with version 12w04a or later. (Basically means release 1.2.1 and later.)<br/>
5+
Minecraft Versions before 12w04a are **NOT SUPPORTED**!<br/>
6+
7+
## Features
8+
* Support reverse proxy for Minecraft servers by server address in the handshake packet which client send to.
9+
* Support rewrite server address and server port to camouflage connection which using official server address. (eg: pretend to be a normal connection to Hypixel, avoiding their server address check.)
10+
* Support listening on an UNIX socket or relay to an UNIX socket. (eg: using nginx as your front-end server, connnect to this UNIX socket.)
11+
12+
## Requirements
13+
* Linux
14+
* libresolv.so
15+
16+
## Compatibility
17+
**Due to Minecraft Handshake restrictions, this server supports:**<br/>
18+
* Game relay on server & client with version 12w04a and later, except version 12w17a, 13w41a and 13w41b.
19+
* MOTD relay / MOTD status notice on server & client with version 1.6.1 and later, except version 13w41a and 13w41b.
20+
21+
## Files
22+
* mcrelay.c: Source code of Main program.
23+
* mcrelay.conf.example: config file example of mcrelay.
24+
* mcrelay.service.forking.example: service unit file of mcrelay for systemd(using runmode: forking).
25+
* mcrelay.service.simple.example: service unit file of mcrelay for systemd(using runmode: simple).
26+
* mod/*.h: header files of essential modules.
27+
* loglevel.info: definations for messages.
28+
29+
## Compile
30+
<pre>
31+
gcc -o mcrelay mcrelay.c -lresolv
32+
</pre>
33+
or
34+
<pre>
35+
make
36+
</pre>
37+
238
## Usage
3-
mcrelay bind_address bind_port target_address target_port
4-
## Informations
5-
Tested Clients:
6-
>Vanilla: 1.8.9, 1.12.2, 1.14.4, 1.16.1, 1.16.3<br/>
7-
>Forge: 1.8.9, 1.12.2<br/>
8-
>Fabric: 1.14.4, 1.16.1, 1.16.3<br/>
9-
Basically support 1.7.x + , after Netty rewrites
10-
## Compiles
11-
>gcc -o mcrelay mcrelay.c
39+
<pre>
40+
mcrelay config_file
41+
</pre>
42+
43+
## Config
44+
### Format
45+
<pre>
46+
runmode run_mode
47+
log logfile_path
48+
loglevel loglvl
49+
bind bind_object
50+
proxy_pass proxy_type
51+
ident_name destination_object
52+
proxy_pass proxy_type
53+
ident_name destination_object
54+
</pre>
55+
### Explanation
56+
* runmode: set program's runmode.
57+
>* run_mode: type of program's runmode, "simple" for a normal, non-exit program, "forking" for a daemonized program. In forking, it will store the PID in /tmp/mcrelay.pid.
58+
* log: set log file.
59+
>* logfile_path: path of the file which logs saved to.
60+
* loglevel: set max message level in logging message.
61+
>* loglvl: a unsigned short integer, range 0-255. This program will not log message with level higher than this level. 0: Critical, 1: Warning, 2+: Information. For more information, watch loglevel.info.
62+
* bind: set bind information.
63+
>* bind_object: (format: "address:port" or "unix:path") default: "0.0.0.0:25565".
64+
>>* address: the address you wish to bind as an Internet Service. Only x.x.x.x allowed.
65+
>>* port: the port you wish to bind as an Internet Service. Valid range: 1-65535.
66+
>>* path: the socket file you wish to bind as an UNIX Socket.
67+
* proxy_pass: list of relay/relay+rewrites.
68+
>* proxy_type: type of proxies, "relay" for raw relay, "rewrite" for relay with server address camouflage enabled.
69+
>* ident_name: name of destination identification. Usually a Fully Qualified Domain Name(FQDN) by CNAME to your server.
70+
>* destination_object: (format: "address_d[:port]" or "unix:path")
71+
>>* address_d: the address you wish to connect. Both FQDN or x.x.x.x allowed.
72+
>>* port: optional, the port you wish to connect. Valid range: 1-65535.<br/>
73+
If not set, the server will detect SRV record first(defined in address_d).<br/>
74+
If SRV record resolve failed, it will fallback to normal address resolve, also connect to this address with port 25565.<br/>
75+
**For rewrite enabled relay, it will use actual connect configuration to rewrite.**
76+
>>* path: the socket file you wish to connect.
77+
### Example
78+
<pre>
79+
runmode forking
80+
log /var/log/mcrelay/mcrelay.log
81+
bind 0.0.0.0:25565
82+
proxy_pass rewrite
83+
hypixel.example.com mc.hypixel.net:25565
84+
hivemc.example.com play.hivemc.com:25565
85+
proxy_pass relay
86+
mc1.example.com 127.0.0.1:25566
87+
mc2.example.com 192.168.1.254:25565
88+
</pre>

loglevel.info

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# LOG LEVEL DEFINATION for v1.1.
2+
# Log level mentioned here had already defined in the program, if new message type defined, this file will be changed
3+
Level Type Description
4+
0 Critical When a non-ignorable error occurs, program will output this message to STDERR.
5+
1 Warning When an ignorable error occurs, program will output this message to STDOUT.
6+
2 Information, rate 0 Normal information. eg: Incoming login request.
7+
3 Information, rate 1 Normal information, but annoying. eg: Incoming MOTD request.

0 commit comments

Comments
 (0)