Skip to content

Commit

Permalink
Merge branch 'dev-1.2-beta3' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
bilintsui committed Jun 19, 2022
2 parents 5b37edd + ce99439 commit 32ada9a
Show file tree
Hide file tree
Showing 36 changed files with 1,169 additions and 841 deletions.
71 changes: 60 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,71 @@ jobs:
sudo apt upgrade -y
- name: Install toolchain
run: |
sudo apt install -y gcc gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu
sudo mv /etc/apt/sources.list /etc/apt/sources.list.d/main-amd64.list
sudo apt install -y gcc gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf gcc-powerpc64le-linux-gnu gcc-riscv64-linux-gnu gcc-s390x-linux-gnu
sudo mv /etc/apt/sources.list /etc/apt/sources.list.d/main.list
sudo touch /etc/apt/sources.list
sudo sed -i '/^$/d;/^#/d;s/deb/deb [arch=amd64]/g' /etc/apt/sources.list.d/main-amd64.list
sudo cp /etc/apt/sources.list.d/main-amd64.list /etc/apt/sources.list.d/main-arm.list
sudo sed -i 's/arch=amd64/arch=armhf,arm64/g;s/archive/ports/g;s/security\./security.ports./g;s/\/ubuntu/\/ubuntu-ports/g' /etc/apt/sources.list.d/main-arm.list
sudo dpkg --add-architecture armhf
sudo sed -i '/^$/d;/^#/d;s/deb/deb [arch=amd64]/g' /etc/apt/sources.list.d/main.list
sudo cp /etc/apt/sources.list.d/main.list /etc/apt/sources.list.d/port.list
sudo sed -i 's/arch=amd64/arch=arm64,armhf,ppc64el,riscv64,s390x/g;s/archive/ports/g;s/security\./security.ports./g;s/\/ubuntu/\/ubuntu-ports/g' /etc/apt/sources.list.d/port.list
sudo dpkg --add-architecture arm64
sudo dpkg --add-architecture armhf
sudo dpkg --add-architecture ppc64el
sudo dpkg --add-architecture riscv64
sudo dpkg --add-architecture s390x
sudo apt update
sudo apt install -y libcjson-dev:amd64 libcjson-dev:armhf libcjson-dev:arm64
- name: Build artifacts
sudo apt install -y libcjson-dev:amd64 libcjson-dev:arm64 libcjson-dev:armhf libcjson-dev:ppc64el libcjson-dev:riscv64 libcjson-dev:s390x
- name: Build amd64
run: |
mkdir build-amd64
cd build-amd64
cmake -DCMAKE_C_COMPILER=`which gcc` -DEXEC_SUFFIX="-amd64" ..
make
cd ..
- name: Build arm64
run: |
mkdir build-arm64
cd build-arm64
cmake -DCMAKE_C_COMPILER=`which aarch64-linux-gnu-gcc` -DEXEC_SUFFIX="-arm64" ..
make
cd ..
- name: Build armhf
run: |
mkdir build-armhf
cd build-armhf
cmake -DCMAKE_C_COMPILER=`which arm-linux-gnueabihf-gcc` -DEXEC_SUFFIX="-armhf" ..
make
cd ..
- name: Build ppc64el
run: |
mkdir build-ppc64el
cd build-ppc64el
cmake -DCMAKE_C_COMPILER=`which powerpc64le-linux-gnu-gcc` -DEXEC_SUFFIX="-ppc64el" ..
make
cd ..
- name: Build riscv64
run: |
mkdir build-riscv64
cd build-riscv64
cmake -DCMAKE_C_COMPILER=`which riscv64-linux-gnu-gcc` -DEXEC_SUFFIX="-riscv64" ..
make
cd ..
- name: Build s390x
run: |
mkdir build-s390x
cd build-s390x
cmake -DCMAKE_C_COMPILER=`which s390x-linux-gnu-gcc` -DEXEC_SUFFIX="-s390x" ..
make
cd ..
- name: Post build
run: |
mkdir build
gcc -o build/mcrelay-amd64 mcrelay.c -lresolv -lcjson
arm-linux-gnueabihf-gcc -o build/mcrelay-armhf mcrelay.c -lresolv -lcjson
aarch64-linux-gnu-gcc -o build/mcrelay-arm64 mcrelay.c -lresolv -lcjson
cd build
cp ../build-amd64/mcrelay-amd64 .
cp ../build-arm64/mcrelay-arm64 .
cp ../build-armhf/mcrelay-armhf .
cp ../build-ppc64el/mcrelay-ppc64el .
cp ../build-riscv64/mcrelay-riscv64 .
cp ../build-s390x/mcrelay-s390x .
- name: Upload artifacts
uses: AButler/[email protected]
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
build-*
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 3.0)
project(mcrelay${EXEC_SUFFIX}
VERSION 1.2
LANGUAGES C)
add_executable(mcrelay${EXEC_SUFFIX} src/basic.c src/config.c src/log.c src/main.c src/misc.c src/network.c src/protocols/common.c src/protocols/handshake.c src/protocols/handshake_legacy.c src/protocols/proxy.c)
target_link_libraries(mcrelay${EXEC_SUFFIX} -lresolv -lcjson)
2 changes: 0 additions & 2 deletions Makefile

This file was deleted.

39 changes: 23 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# mcrelay
Minecraft Relay Server
# Minecraft Relay Server (mcrelay)

A minecraft reverse proxy server with server address rewrite.

Expand All @@ -14,8 +13,8 @@ Minecraft Versions before 12w04a are **NOT SUPPORTED**!

## Requirements
* Linux
* libresolv.so
* libcjson.so
* libresolv.so (usually pre-installed)
* libcjson.so (on debian-like systems, contained in package "libcjson1")

## Compatibility
**Due to Minecraft Handshake restrictions, this server supports:**
Expand All @@ -24,22 +23,30 @@ Minecraft Versions before 12w04a are **NOT SUPPORTED**!
* MOTD relay / MOTD status notice on server & client with version 1.6.1 and later, except version 13w41a and 13w41b.

## Files
* mcrelay.c: Source code of Main program.
* config.json.example: config file example.
* mcrelay.service.forking.example: service unit file of mcrelay for systemd. (using runmode: forking)
* mcrelay.service.simple.example: service unit file of mcrelay for systemd. (using runmode: simple)
* mod: directory of essential modules.
* version.json: version manifest.
* loglevel.info: definations for messages.
* CMakeLists.txt: CMake configuration for compiling
* doc: Folder of documents
* doc/loglevel.info: Definations of log levels
* doc/versions.json: Version manifest
* examples: File templates
* examples/config: Folder of example configurations
* examples/systemd: Folder of example systemd service files
* src: Folder of source codes

## Compile
Before compiling, you need to install cJSON at first.

For example, you can install it on a debian-like systems by <code>apt install libcjson-dev</code>.

Then you can use CMake to compile it, by following:
<pre>
gcc -o mcrelay mcrelay.c -lresolv -lcjson
</pre>
or
<pre>
mkdir build
cd build
cmake ..
make
</pre>
Additionally, if you want cross compiling, following CMake properties will helpful:
* <code>-DCMAKE_C_COMPILER</code>: Specify an alternative compiler, CMake using <code>cc</code> by default.
* <code>-DEXEC_SUFFIX</code>: Add a suffix to the final binary file, the file will generated called <code>mcrelay</code>.

## Usage
<pre>
Expand All @@ -51,7 +58,7 @@ The program will run as a non-exit-style program by default.
When using "-f" or "--forking" option, the program will become daemonized, and store its main process' PID into /tmp/mcrelay.pid.

## Config
See "config.json.example" for instructions.
See "examples/config/config.json" for instructions.

## Instruction of using a DNS-based redirection (SRV)
If you are using a SRV record to provide your service, you should follow the instructions below.
Expand Down
File renamed without changes.
40 changes: 40 additions & 0 deletions version.json → doc/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,5 +210,45 @@
{
"version": 55,
"names": ["1.2-beta2-patch13","1.2-beta2"]
},
{
"version": 56,
"names": ["1.2-beta3-patch1"]
},
{
"version": 57,
"names": ["1.2-beta3-patch2","1.2-beta3-patch3"]
},
{
"version": 58,
"names": ["1.2-beta3-patch4"]
},
{
"version": 59,
"names": ["1.2-beta3-patch5"]
},
{
"version": 60,
"names": ["1.2-beta3-patch6"]
},
{
"version": 61,
"names": ["1.2-beta3-patch7"]
},
{
"version": 62,
"names": ["1.2-beta3-patch8"]
},
{
"version": 63,
"names": ["1.2-beta3-patch9"]
},
{
"version": 64,
"names": ["1.2-beta3-patch10"]
},
{
"version": 65,
"names": ["1.2-beta3-patch11","1.2-beta3"]
}
]
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ User=nobody
Group=nogroup
Restart=on-failure
RestartSec=5s
PID=/tmp/mcrelay.pid
ExecStart=/usr/bin/mcrelay -f /etc/mcrelay/mcrelay.conf
PIDFile=/tmp/mcrelay.pid
ExecStart=/usr/bin/mcrelay -f /etc/mcrelay/config.json
ExecStop=/usr/bin/mcrelay -t
ExecReload=/usr/bin/mcrelay -r

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ User=nobody
Group=nogroup
Restart=on-failure
RestartSec=5s
ExecStart=/usr/bin/mcrelay /etc/mcrelay/mcrelay.conf
ExecStart=/usr/bin/mcrelay /etc/mcrelay/config.json
ExecStop=/usr/bin/mcrelay -t
ExecReload=/usr/bin/mcrelay -r

Expand Down
12 changes: 0 additions & 12 deletions mcrelay.c

This file was deleted.

Loading

0 comments on commit 32ada9a

Please sign in to comment.