From 05e78802ca540c098df51dd19280bd820e92554d Mon Sep 17 00:00:00 2001 From: Val Lorentz Date: Sun, 19 Dec 2021 00:45:51 +0100 Subject: [PATCH] Add support for Unreal 6 (#123) List of issues we had: * echo wallops missing `!user@host` [wallops: Send a full NUH as prefix in echoed WALLOPS unrealircd/unrealircd#186](https://github.com/unrealircd/unrealircd/pull/186) * RPL_MONONLINE is (re)sent on nick case change - https://bugs.unrealircd.org/view.php?id=6013 * MONITOR accepts masks - https://bugs.unrealircd.org/view.php?id=6014 * KICK doesn't support multiple channels anymore, despite unchanged TARGMAX - https://bugs.unrealircd.org/view.php?id=6015 --- .github/workflows/test-devel.yml | 83 +++++++++++++++++++++++++++++-- .github/workflows/test-stable.yml | 83 +++++++++++++++++++++++++++++-- Makefile | 2 + irctest/controllers/unrealircd.py | 28 ++++++++++- irctest/server_tests/monitor.py | 11 ++-- workflows.yml | 26 ++++++++-- 6 files changed, 214 insertions(+), 19 deletions(-) diff --git a/.github/workflows/test-devel.yml b/.github/workflows/test-devel.yml index 940e609..a428c06 100644 --- a/.github/workflows/test-devel.yml +++ b/.github/workflows/test-devel.yml @@ -297,13 +297,13 @@ jobs: uses: actions/setup-python@v2 with: python-version: 3.7 - - name: Checkout UnrealIRCd + - name: Checkout UnrealIRCd 6 uses: actions/checkout@v2 with: path: unrealircd - ref: unreal52 + ref: unreal60_dev repository: unrealircd/unrealircd - - name: Build UnrealIRCd + - name: Build UnrealIRCd 6 run: | cd $GITHUB_WORKSPACE/unrealircd/ cp $GITHUB_WORKSPACE/data/unreal/* . @@ -322,6 +322,50 @@ jobs: name: installed-unrealircd path: ~/artefacts-*.tar.gz retention-days: 1 + build-unrealircd-5: + runs-on: ubuntu-latest + steps: + - name: Create directories + run: cd ~/; mkdir -p .local/ go/ + - name: Cache dependencies + uses: actions/cache@v2 + with: + key: 3-${{ runner.os }}-unrealircd-5-devel + path: '~/.cache + + ${ github.workspace }/unrealircd + + ' + - uses: actions/checkout@v2 + - name: Set up Python 3.7 + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Checkout UnrealIRCd 5 + uses: actions/checkout@v2 + with: + path: unrealircd + ref: unreal52 + repository: unrealircd/unrealircd + - name: Build UnrealIRCd 5 + run: | + cd $GITHUB_WORKSPACE/unrealircd/ + cp $GITHUB_WORKSPACE/data/unreal/* . + # Need to use a specific -march, because GitHub has inconsistent + # architectures across workers, which result in random SIGILL with some + # worker combinations + sudo apt install libsodium-dev libargon2-dev + CFLAGS="-O0 -march=x86-64" CXXFLAGS="$CFLAGS" ./Config -quick + make -j 4 + make install + - name: Make artefact tarball + run: cd ~; tar -czf artefacts-unrealircd-5.tar.gz .local/ go/ + - name: Upload build artefacts + uses: actions/upload-artifact@v2 + with: + name: installed-unrealircd-5 + path: ~/artefacts-*.tar.gz + retention-days: 1 publish-test-results: if: success() || failure() name: Publish Unit Tests Results @@ -342,6 +386,7 @@ jobs: - test-solanum - test-sopel - test-unrealircd + - test-unrealircd-5 - test-unrealircd-anope - test-unrealircd-atheme runs-on: ubuntu-latest @@ -916,6 +961,38 @@ jobs: with: name: pytest results unrealircd (devel) path: pytest.xml + test-unrealircd-5: + needs: + - build-unrealircd-5 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.7 + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Download build artefacts + uses: actions/download-artifact@v2 + with: + name: installed-unrealircd-5 + path: '~' + - name: Unpack artefacts + run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; + - name: Install Atheme + run: sudo apt-get install atheme-services + - name: Install irctest dependencies + run: |- + python -m pip install --upgrade pip + pip install pytest pytest-xdist -r requirements.txt + - name: Test with pytest + run: PYTEST_ARGS='--junit-xml pytest.xml' PATH=$HOME/.local/bin:$PATH PATH=~/.local/unrealircd/sbin:~/.local/unrealircd/bin:$PATH + make unrealircd-5 + - if: always() + name: Publish results + uses: actions/upload-artifact@v2 + with: + name: pytest results unrealircd-5 (devel) + path: pytest.xml test-unrealircd-anope: needs: - build-unrealircd diff --git a/.github/workflows/test-stable.yml b/.github/workflows/test-stable.yml index 6a42820..2f1c254 100644 --- a/.github/workflows/test-stable.yml +++ b/.github/workflows/test-stable.yml @@ -337,13 +337,13 @@ jobs: uses: actions/setup-python@v2 with: python-version: 3.7 - - name: Checkout UnrealIRCd + - name: Checkout UnrealIRCd 6 uses: actions/checkout@v2 with: path: unrealircd - ref: 94993a03ca8d3c193c0295c33af39270c3f9d27d + ref: d77f42e4bef388ae344256eeef9a8000345ae381 repository: unrealircd/unrealircd - - name: Build UnrealIRCd + - name: Build UnrealIRCd 6 run: | cd $GITHUB_WORKSPACE/unrealircd/ cp $GITHUB_WORKSPACE/data/unreal/* . @@ -362,6 +362,50 @@ jobs: name: installed-unrealircd path: ~/artefacts-*.tar.gz retention-days: 1 + build-unrealircd-5: + runs-on: ubuntu-latest + steps: + - name: Create directories + run: cd ~/; mkdir -p .local/ go/ + - name: Cache dependencies + uses: actions/cache@v2 + with: + key: 3-${{ runner.os }}-unrealircd-5-stable + path: '~/.cache + + ${ github.workspace }/unrealircd + + ' + - uses: actions/checkout@v2 + - name: Set up Python 3.7 + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Checkout UnrealIRCd 5 + uses: actions/checkout@v2 + with: + path: unrealircd + ref: 94993a03ca8d3c193c0295c33af39270c3f9d27d + repository: unrealircd/unrealircd + - name: Build UnrealIRCd 5 + run: | + cd $GITHUB_WORKSPACE/unrealircd/ + cp $GITHUB_WORKSPACE/data/unreal/* . + # Need to use a specific -march, because GitHub has inconsistent + # architectures across workers, which result in random SIGILL with some + # worker combinations + sudo apt install libsodium-dev libargon2-dev + CFLAGS="-O0 -march=x86-64" CXXFLAGS="$CFLAGS" ./Config -quick + make -j 4 + make install + - name: Make artefact tarball + run: cd ~; tar -czf artefacts-unrealircd-5.tar.gz .local/ go/ + - name: Upload build artefacts + uses: actions/upload-artifact@v2 + with: + name: installed-unrealircd-5 + path: ~/artefacts-*.tar.gz + retention-days: 1 publish-test-results: if: success() || failure() name: Publish Unit Tests Results @@ -385,6 +429,7 @@ jobs: - test-solanum - test-sopel - test-unrealircd + - test-unrealircd-5 - test-unrealircd-anope - test-unrealircd-atheme runs-on: ubuntu-latest @@ -1076,6 +1121,38 @@ jobs: with: name: pytest results unrealircd (stable) path: pytest.xml + test-unrealircd-5: + needs: + - build-unrealircd-5 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.7 + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Download build artefacts + uses: actions/download-artifact@v2 + with: + name: installed-unrealircd-5 + path: '~' + - name: Unpack artefacts + run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; + - name: Install Atheme + run: sudo apt-get install atheme-services + - name: Install irctest dependencies + run: |- + python -m pip install --upgrade pip + pip install pytest pytest-xdist -r requirements.txt + - name: Test with pytest + run: PYTEST_ARGS='--junit-xml pytest.xml' PATH=$HOME/.local/bin:$PATH PATH=~/.local/unrealircd/sbin:~/.local/unrealircd/bin:$PATH + make unrealircd-5 + - if: always() + name: Publish results + uses: actions/upload-artifact@v2 + with: + name: pytest results unrealircd-5 (stable) + path: pytest.xml test-unrealircd-anope: needs: - build-unrealircd diff --git a/Makefile b/Makefile index 34321d2..6a7e9e2 100644 --- a/Makefile +++ b/Makefile @@ -316,6 +316,8 @@ unrealircd: -m 'not services' \ -k '$(UNREALIRCD_SELECTORS)' +unrealircd-5: unrealircd + unrealircd-atheme: $(PYTEST) $(PYTEST_ARGS) \ --controller=irctest.controllers.unrealircd \ diff --git a/irctest/controllers/unrealircd.py b/irctest/controllers/unrealircd.py index 64f7559..62af954 100644 --- a/irctest/controllers/unrealircd.py +++ b/irctest/controllers/unrealircd.py @@ -1,5 +1,7 @@ +import functools import os import subprocess +import textwrap from typing import Optional, Set, Type from irctest.basecontrollers import ( @@ -12,6 +14,7 @@ from irctest.irc_utils.junkdrawer import find_hostname_and_port TEMPLATE_CONFIG = """ include "modules.default.conf"; include "operclass.default.conf"; +{extras} me {{ name "My.Little.Server"; @@ -87,6 +90,7 @@ set {{ // Prevent throttling, especially test_buffering.py which // triggers anti-flood with its very long lines unknown-users {{ + nick-flood 255:10; lag-penalty 1; lag-penalty-bytes 10000; }} @@ -110,12 +114,23 @@ oper "operuser" {{ """ +@functools.lru_cache() +def installed_version() -> int: + output = subprocess.check_output(["unrealircd", "-v"], universal_newlines=True) + if output.startswith("UnrealIRCd-5."): + return 5 + elif output.startswith("UnrealIRCd-6."): + return 6 + else: + assert False, f"unexpected version: {output}" + + class UnrealircdController(BaseServerController, DirectoryBasedController): software_name = "UnrealIRCd" supported_sasl_mechanisms = {"PLAIN"} supports_sts = False - extban_mute_char = "q" + extban_mute_char = "quiet" if installed_version() >= 6 else "q" def create_config(self) -> None: super().create_config() @@ -155,6 +170,16 @@ class UnrealircdController(BaseServerController, DirectoryBasedController): # Unreal refuses to start without TLS enabled (tls_hostname, tls_port) = (unused_hostname, unused_port) + if installed_version() >= 6: + extras = textwrap.dedent( + """ + include "snomasks.default.conf"; + loadmodule "cloak_md5"; + """ + ) + else: + extras = "" + with self.open_file("empty.txt") as fd: fd.write("\n") @@ -172,6 +197,7 @@ class UnrealircdController(BaseServerController, DirectoryBasedController): key_path=self.key_path, pem_path=self.pem_path, empty_file=os.path.join(self.directory, "empty.txt"), + extras=extras, ) ) self.proc = subprocess.Popen( diff --git a/irctest/server_tests/monitor.py b/irctest/server_tests/monitor.py index 3070ffa..56e0306 100644 --- a/irctest/server_tests/monitor.py +++ b/irctest/server_tests/monitor.py @@ -188,15 +188,12 @@ class MonitorTestCase(cases.BaseServerTestCase): self.sendLine(1, "MONITOR + *!username@127.0.0.1") try: m = self.getMessage(1) - self.assertNotEqual( - m.command, - "731", - m, - fail_msg="Got 731 (RPL_MONOFFLINE) after adding a monitor " - "on a mask: {msg}", - ) + self.assertMessageMatch(m, command="731") except NoMessageException: pass + else: + m = self.getMessage(1) + self.assertMessageMatch(m, command="731") self.connectClient("bar") try: m = self.getMessage(1) diff --git a/workflows.yml b/workflows.yml index a7816c9..1dccc59 100644 --- a/workflows.yml +++ b/workflows.yml @@ -246,12 +246,12 @@ software: make install unrealircd: - name: UnrealIRCd + name: UnrealIRCd 6 repository: unrealircd/unrealircd - refs: &unrealircd_refs - stable: 94993a03ca8d3c193c0295c33af39270c3f9d27d # 5.2.1-rc1 - release: null - devel: unreal52 + refs: + stable: d77f42e4bef388ae344256eeef9a8000345ae381 # 6.0.0 + 2 commits + release: 893bf864f6c616e891d84916d27e342c252f31aaa # 6.0.0 + devel: unreal60_dev devel_release: null path: unrealircd prefix: ~/.local/unrealircd @@ -267,6 +267,19 @@ software: make -j 4 make install + unrealircd-5: + name: UnrealIRCd 5 + repository: unrealircd/unrealircd + refs: + stable: 94993a03ca8d3c193c0295c33af39270c3f9d27d # 5.2.1-rc1 + release: null + devel: unreal52 + devel_release: + path: unrealircd + prefix: ~/.local/unrealircd + separate_build_job: true + build_script: *unrealircd_build_script + ############################# # Clients: @@ -354,6 +367,9 @@ tests: ircu2: software: [ircu2] + unrealircd-5: + software: [unrealircd-5] + unrealircd: software: [unrealircd]