This commit is contained in:
Rim 2024-05-30 19:39:04 -04:00
commit 6048d9f1c2
9 changed files with 388 additions and 254 deletions

View File

@ -3,10 +3,12 @@ name: Build
on: on:
push: push:
branches: branches:
- "*" - "**"
tags:
- '[0-9]+.[0-9]+.[0-9]+'
pull_request: pull_request:
branches: branches:
- "*" - "**"
types: [opened, synchronize, reopened] types: [opened, synchronize, reopened]
concurrency: concurrency:
@ -58,7 +60,11 @@ jobs:
uses: ammaraskar/msvc-problem-matcher@master uses: ammaraskar/msvc-problem-matcher@master
- name: Build ${{matrix.arch}} ${{matrix.configuration}} binaries - name: Build ${{matrix.arch}} ${{matrix.configuration}} binaries
<<<<<<< HEAD
run: msbuild /m /v:minimal /p:Configuration=${{matrix.configuration}} /p:Platform=${{matrix.platform}} build/master-server.sln run: msbuild /m /v:minimal /p:Configuration=${{matrix.configuration}} /p:Platform=${{matrix.platform}} build/master-server.sln
=======
run: msbuild /m /v:minimal /p:Configuration=${{matrix.configuration}} /p:Platform=${{matrix.platform}} build/alterware-master.sln
>>>>>>> 27c2b2b75b56e54dcfbec690dd086946a45587d7
- name: Upload ${{matrix.arch}} ${{matrix.configuration}} binaries - name: Upload ${{matrix.arch}} ${{matrix.configuration}} binaries
uses: actions/upload-artifact@main uses: actions/upload-artifact@main
@ -162,17 +168,28 @@ jobs:
with: with:
name: macos-${{matrix.arch}}-${{matrix.configuration}} name: macos-${{matrix.arch}}-${{matrix.configuration}}
path: | path: |
<<<<<<< HEAD
build/bin/${{matrix.arch}}/${{matrix.configuration}}/master-server build/bin/${{matrix.arch}}/${{matrix.configuration}}/master-server
=======
build/bin/${{matrix.arch}}/${{matrix.configuration}}/alterware-master
>>>>>>> 27c2b2b75b56e54dcfbec690dd086946a45587d7
deploy: deploy:
name: Deploy artifacts name: Deploy artifacts
needs: [build-win, build-linux, build-macos] needs: [build-win, build-linux, build-macos]
runs-on: ubuntu-latest runs-on: ubuntu-latest
<<<<<<< HEAD
if: github.event_name == 'push' && github.ref == 'refs/heads/master' if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps: steps:
- name: Setup main environment - name: Setup main environment
if: github.ref == 'refs/heads/master' if: github.ref == 'refs/heads/master'
run: echo "MASTER_SERVER_PATH=${{ secrets.MASTER_SERVER_SSH_PATH }}" >> $GITHUB_ENV run: echo "MASTER_SERVER_PATH=${{ secrets.MASTER_SERVER_SSH_PATH }}" >> $GITHUB_ENV
=======
if: github.ref_type == 'tag'
steps:
- name: Setup main environment
run: echo "ALTERWARE_MASTER_SERVER_PATH=${{ secrets.ALTERWARE_MASTER_SERVER_SSH_PATH }}" >> $GITHUB_ENV
>>>>>>> 27c2b2b75b56e54dcfbec690dd086946a45587d7
- name: Download Release binaries - name: Download Release binaries
uses: actions/download-artifact@main uses: actions/download-artifact@main
@ -182,6 +199,7 @@ jobs:
- name: Install SSH key - name: Install SSH key
uses: shimataro/ssh-key-action@v2.7.0 uses: shimataro/ssh-key-action@v2.7.0
with: with:
<<<<<<< HEAD
key: ${{ secrets.MASTER_SERVER_SSH_PRIVATE_KEY }} key: ${{ secrets.MASTER_SERVER_SSH_PRIVATE_KEY }}
known_hosts: 'just-a-placeholder-so-we-dont-get-errors' known_hosts: 'just-a-placeholder-so-we-dont-get-errors'
@ -193,3 +211,74 @@ jobs:
- name: Publish changes - name: Publish changes
run: ssh ${{ secrets.MASTER_SERVER_SSH_USER }}@${{ secrets.MASTER_SERVER_SSH_ADDRESS }} ${{ secrets.SSH_SERVER_PUBLISH_COMMAND }} run: ssh ${{ secrets.MASTER_SERVER_SSH_USER }}@${{ secrets.MASTER_SERVER_SSH_ADDRESS }} ${{ secrets.SSH_SERVER_PUBLISH_COMMAND }}
=======
key: ${{ secrets.ALTERWARE_MASTER_SERVER_SSH_PRIVATE_KEY }}
known_hosts: 'just-a-placeholder-so-we-dont-get-errors'
- name: Add known hosts
run: ssh-keyscan -H ${{ secrets.ALTERWARE_MASTER_SERVER_SSH_ADDRESS }} >> ~/.ssh/known_hosts
- name: Upload release binary
run: rsync -avz alterware-master ${{ secrets.ALTERWARE_MASTER_SERVER_SSH_USER }}@${{ secrets.ALTERWARE_MASTER_SERVER_SSH_ADDRESS }}:${{ env.ALTERWARE_MASTER_SERVER_PATH }}/
- name: Publish changes
run: ssh ${{ secrets.ALTERWARE_MASTER_SERVER_SSH_USER }}@${{ secrets.ALTERWARE_MASTER_SERVER_SSH_ADDRESS }} ${{ secrets.ALTERWARE_SSH_SERVER_PUBLISH_COMMAND }}
docker:
name: Create Docker Image
needs: [build-win, build-linux, build-macos]
runs-on: ubuntu-latest
if: github.ref_type == 'tag'
steps:
- name: Check out files
uses: actions/checkout@main
with:
sparse-checkout: |
Dockerfile
README.md
sparse-checkout-cone-mode: false
- name: Download Release binaries
uses: actions/download-artifact@main
- name: Compress Binaries
run: |
for dir in */; do
if [[ $dir == *"windows"* ]]; then
cd "$dir" && zip -r "../${dir%/}.zip" . && cd ..
else
tar -czvf "${dir%/}.tar.gz" -C "$dir" .
fi
done
shell: bash
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3.2.0
- name: Login to DockerHub
uses: docker/login-action@v3.1.0
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- id: meta
uses: docker/metadata-action@v5.5.1
with:
images: |
alterware/master-server
tags: |
${{ github.ref_name }}
latest
- name: Build and Push Docker Image
id: build-and-push
uses: docker/build-push-action@v5.1.0
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
>>>>>>> 27c2b2b75b56e54dcfbec690dd086946a45587d7

4
.gitmodules vendored
View File

@ -19,4 +19,8 @@
[submodule "deps/curl"] [submodule "deps/curl"]
path = deps/curl path = deps/curl
url = https://github.com/curl/curl.git url = https://github.com/curl/curl.git
<<<<<<< HEAD
branch = curl-8_7_1 branch = curl-8_7_1
=======
branch = curl-8_7_1
>>>>>>> 27c2b2b75b56e54dcfbec690dd086946a45587d7

13
Dockerfile Normal file
View File

@ -0,0 +1,13 @@
FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y libc++-dev libcurl4-gnutls-dev
COPY --chmod=755 ./linux-x64-release/alterware-master /usr/local/bin/
RUN groupadd alterware-master && useradd -r -g alterware-master alterware-master
USER alterware-master
EXPOSE 20810/udp
ENTRYPOINT ["/usr/local/bin/alterware-master"]

View File

@ -4,6 +4,13 @@
# Master Server # Master Server
This is the master server our clients use. It is based on the DP Master Server (ID Tech) protocol This is the master server our clients use. It is based on the DP Master Server (ID Tech) protocol
## Usage
Run using [Docker][docker-link]
```bash
docker run -p 20810:20810/udp alterware/master-server:latest
```
## Build ## Build
- Install [Premake5][premake5-link] and add it to your system PATH - Install [Premake5][premake5-link] and add it to your system PATH
- Clone this repository using [Git][git-link] - Clone this repository using [Git][git-link]
@ -18,6 +25,7 @@ Requirements for Unix systems:
- Customization: Modifications to the Premake5.lua script may be required - Customization: Modifications to the Premake5.lua script may be required
- Platform support: Details regarding supported platforms are available in [build.yml][build-link] - Platform support: Details regarding supported platforms are available in [build.yml][build-link]
[docker-link]: https://www.docker.com
[premake5-link]: https://premake.github.io [premake5-link]: https://premake.github.io
[git-link]: https://git-scm.com [git-link]: https://git-scm.com
[mold-link]: https://github.com/rui314/mold [mold-link]: https://github.com/rui314/mold

View File

@ -36,7 +36,7 @@ namespace crypto_key
if (!utils::io::write_file("./private.key", key.serialize())) if (!utils::io::write_file("./private.key", key.serialize()))
{ {
throw std::runtime_error("Failed to write server key!"); console::error("Failed to write server key!");
} }
console::info("Generated cryptographic key: %llX", key.get_hash()); console::info("Generated cryptographic key: %llX", key.get_hash());

View File

@ -30,6 +30,7 @@ void elimination_handler::run_frame()
(server.state == game_server::state::can_ping && diff > 15min)) (server.state == game_server::state::can_ping && diff > 15min))
{ {
context.remove(); context.remove();
return;
} }
if (server.game == game_type::unknown) if (server.game == game_type::unknown)
@ -43,6 +44,7 @@ void elimination_handler::run_frame()
console::log("Removing T7 server '%s' because they are using an outdated protocol (%i)", context.get_address().to_string().data(), server.protocol); console::log("Removing T7 server '%s' because they are using an outdated protocol (%i)", context.get_address().to_string().data(), server.protocol);
#endif #endif
context.remove(); context.remove();
return;
} }
++server_count[server.game][context.get_address().to_string(false)]; ++server_count[server.game][context.get_address().to_string(false)];
@ -50,6 +52,18 @@ void elimination_handler::run_frame()
{ {
console::log("Removing server '%s' because it exceeds MAX_SERVERS_PER_GAME", context.get_address().to_string().data()); console::log("Removing server '%s' because it exceeds MAX_SERVERS_PER_GAME", context.get_address().to_string().data());
context.remove(); context.remove();
return;
}
const auto name = utils::string::to_lower(server.name);
for (const auto& entry : bad_names)
{
if (const auto pos = name.find(entry); pos != std::string::npos)
{
console::log("Removing server '%s' (%s) because it contains a bad name", server.name.data(), context.get_address().to_string().data());
context.remove();
return;
}
} }
const auto name = utils::string::to_lower(server.name); const auto name = utils::string::to_lower(server.name);

View File

@ -142,8 +142,14 @@ void kill_list::write_to_disk()
stream << entry.ip_address_ << " " << entry.reason_ << "\n"; stream << entry.ip_address_ << " " << entry.reason_ << "\n";
} }
utils::io::write_file(kill_file, stream.str(), false); if (utils::io::write_file(kill_file, stream.str(), false))
console::info("Wrote %s to disk (%zu entries)", kill_file, entries.size()); {
console::info("Wrote %s to disk (%zu entries)", kill_file, entries.size());
}
else
{
console::error("Failed to write %s!", kill_file);
}
}); });
} }