1
0
mirror of https://github.com/anope/anope.git synced 2026-07-10 02:23:12 +02:00

Compare commits

..

104 Commits

Author SHA1 Message Date
Sadie Powell d3bf09b65b Split up big timezones into multiple help categories. 2026-07-09 21:40:07 +01:00
Sadie Powell 9b609c1ccb Various improvements to the timezone list.
- Correctly translate the time region message.
- Squash time regions with only one zone like Antactica into Misc.
- Make sure we use a comma in the zone list even at the end of a
  line.
2026-07-09 21:03:35 +01:00
Sadie Powell cf05a92401 Consistently use imperative statements in command descriptions. 2026-07-09 19:08:35 +01:00
Sadie Powell 673b04f1fc Make the description of nickserv/sendpass more accurate. 2026-07-09 18:55:05 +01:00
Sadie Powell 215eba2704 Redocument nickserv/set/keepmodes. 2026-07-09 18:50:13 +01:00
Sadie Powell eb37dd0af1 Fix places where "user modes" is written as usermodes. 2026-07-09 18:23:26 +01:00
Sadie Powell 58e278410d Update the change log. 2026-07-09 17:22:59 +01:00
Sadie Powell 13f99f1ca7 Update utfcpp. 2026-07-08 14:05:16 +01:00
Sadie Powell f15f8e3454 Drop support for the draft reply tag. 2026-07-08 12:20:26 +01:00
Kufat ff52ade0cc Fix setting the chosen channel founder/successor in db_atheme. 2026-07-08 12:18:56 +01:00
Sadie Powell 4c81f45232 Fix a crash in the ns_cert module when upgrading fingerprints. 2026-07-06 14:40:34 +01:00
Sadie Powell cdccfaf99a Run irctest on Ubuntu 26.04 ARM. 2026-07-05 12:13:55 +01:00
Kufat e47d379d98 Fix a crash on exit when uplink lost and globaloncycledown set. 2026-07-05 08:18:59 +01:00
dependabot[bot] c784f08002 Bump actions/cache from 5 to 6
Bumps [actions/cache](https://github.com/actions/cache) from 5 to 6.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-01 20:20:23 +01:00
dependabot[bot] 6de2ae0046 Bump actions/checkout from 6 to 7
Bumps [actions/checkout](https://github.com/actions/checkout) from 6 to 7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-01 20:19:59 +01:00
Sadie Powell c26f742662 Run irctest on GitHub Actions.
[skip alpine ci]
[skip ubuntu ci]
[skip windows ci]
2026-06-29 17:45:04 +01:00
Sadie Powell e3bff85339 Disable unity builds for targets with only one source file. 2026-06-29 17:17:43 +01:00
TehPeGaSuS 5819c1fcf3 Document the ns_flexible and ns_monospace options. 2026-06-29 12:21:06 +01:00
Sadie Powell 4b8f073cb7 Improve configuring paths. 2026-06-29 01:31:55 +01:00
Kufat 67026b184d Enhance Atheme database import functionality. 2026-06-29 01:28:59 +01:00
Sadie Powell b49f984598 Improve support for versioning builds.
- Don't increment the build id when doing reproducible builds.
- Generate the build date in build.h so it always gets updated.
2026-06-17 22:52:14 +01:00
Sadie Powell b9cacf1d0f Fix HostServ request timeouts for DNS validated vhosts. 2026-06-14 18:16:43 +01:00
Sadie Powell 09d0bd6987 Fix the bcrypt/md5 vendored libraries not being marked as extern C. 2026-06-14 17:45:06 +01:00
Sadie Powell f150ee857f Build vendored libraries as static libraries and link against them.
This avoids rebuilding code we've already built.
2026-06-14 12:45:18 +01:00
Sadie Powell d60c80a4a3 Build with -fPIC. 2026-06-14 12:44:49 +01:00
Sadie Powell 44b7493eb1 Add support for HostServ request cooldowns. 2026-06-13 23:53:16 +01:00
Sadie Powell a03e765172 Fix a crash when FindFromService can not find a command.
Closes #583.
2026-06-12 19:23:39 +01:00
Sadie Powell 17cd10ef21 Fix a crashed caused by invalidation of an iterator in os_mode.
Closes #582.
2026-06-12 10:47:58 +01:00
Sadie Powell ca8fcbe119 Allow protocol modules to apply tags to sent messages.
This is useful because for some IRCv3 specifications we need to
apply tags to all messages and its annoying to have to do this
inline when sending each message.
2026-06-10 09:14:09 +01:00
Sadie Powell b9d0762f2b Add a function for building an ISO 8601 timestamp. 2026-06-10 09:14:09 +01:00
Sadie Powell 4878b1787e Only send tags on InspIRCd when we are done syncing. 2026-06-09 23:29:35 +01:00
Sadie Powell 0163d92b1d Fix showing tags in the protocoldebug output for sent messages. 2026-06-09 23:23:18 +01:00
Sadie Powell a861a059f6 Fix the config parser using int for values that can not be negative. 2026-06-08 15:41:00 +01:00
Sadie Powell 90da25f84f Add Block::GetBlocks which returns an iterable list of blocks. 2026-06-08 15:39:28 +01:00
Sadie Powell ab362c9828 Pascalize some typedefs in Configuration::Block. 2026-06-08 14:17:30 +01:00
Kufat d1f6da1817 Allow specifying the order of ns_set_misc entries. 2026-06-08 09:36:18 +01:00
Sadie Powell 9280d90aba Make it clear that the hmac-* algos can't be used in the config. 2026-06-08 09:09:19 +01:00
Sadie Powell c71f69208d Add various config options to the argon2 algo in anope-mkpasswd. 2026-06-08 09:08:19 +01:00
Sadie Powell d0080b85a7 Fix a typo in the default Argon2 priority in the example config. 2026-06-08 09:07:16 +01:00
Sadie Powell 745e94783d Respect BCRYPT_ROUNDS from the environment in anope-mkpasswd. 2026-06-08 08:58:15 +01:00
Sadie Powell c32be6a711 Fix a missing colon when REPRODUCIBLE_BUILD is defined. 2026-06-08 08:54:46 +01:00
Kufat 9dd3acfc87 Append EXTRA_CONFIG_ARGS to CMake command 2026-06-05 20:34:09 +01:00
Sadie Powell 82b6da3763 Merge branch '2.0' into 2.1. 2026-05-26 10:48:07 +01:00
Sadie Powell 8e691eac80 Update the change log. 2026-05-26 10:44:44 +01:00
Sadie Powell 2327c6ac9a Fix an escaped value that wasn't escaped enough in chanstats. 2026-05-26 10:36:50 +01:00
Sadie Powell e23ea8f8ea Escape user-provided values in ldap_authentication and ldap_oper. 2026-05-26 09:30:15 +01:00
Sadie Powell 449cfa6503 Add EscapeDN and EscapeSF to the LDAP API. 2026-05-26 09:29:57 +01:00
Sadie Powell 59c60849b6 Remove hard coded references to default access levels. 2026-05-21 11:52:32 +01:00
Sadie Powell 6d2c4fb612 Merge branch '2.0' into 2.1. 2026-05-20 22:14:37 +01:00
Sadie Powell 01fc7421b6 Backport the pull request checks from 2.0. 2026-05-20 22:13:38 +01:00
TehPeGaSuS 3a59a81aa4 Update the Portuguese translation. 2026-05-20 20:57:10 +01:00
Sadie Powell c24de0ca8f Fix update.sh on recent gettext. 2026-05-20 17:42:17 +01:00
KidProtect 18555638c9 Update the Romanian translation. 2026-05-20 09:59:48 +01:00
Sadie Powell d5a653fe94 Make it clearer how to enable localisation. 2026-05-19 16:14:14 +01:00
Sadie Powell ad3be96283 Increase {nickserv}:regdelay to 15 minutes, add {ns_group}:delay. 2026-05-17 16:06:42 +01:00
Sadie Powell d689c0686d Update the Conan dependencies. 2026-05-16 20:57:44 +01:00
Sadie Powell 4ca2952069 Update the change log. 2026-05-16 20:57:44 +01:00
Sadie Powell caf904c938 Fix updating the access description in cs_flags. 2026-05-16 11:23:25 +01:00
Sadie Powell 8930cc2a92 Avoid potential crashes from calling strftime on a weird value. 2026-05-15 19:51:57 +01:00
Sadie Powell 47b927d788 Fix a crash from an uninitialised field in migrated flags. 2026-05-15 19:45:28 +01:00
Sadie Powell 647a07ff96 Fix an crash when a user migrates their own access. 2026-05-15 15:54:57 +01:00
Sadie Powell a856e80b1e Move migration messages to cs_flags, split non-migratable and non-migrated. 2026-05-15 09:06:02 +01:00
Sadie Powell 55746e1098 Fix users getting extra privileges when migrating to flags. 2026-05-15 08:43:03 +01:00
Sadie Powell e0da3bae18 Fix confirming accounts when admin-only confirmation is enabled. 2026-05-14 19:24:29 +01:00
Sadie Powell c1cf7b0bcc Fix checking if an access entry has a flag when migrating.
Closes #574.
2026-05-13 23:41:01 +01:00
Sadie Powell 1cf64a49c0 Fix the unique runtime library names on Windows. 2026-05-12 14:20:21 +01:00
Sadie Powell 92ed0071d7 Make the runtime copy error more verbose. 2026-05-12 14:10:04 +01:00
Sadie Powell 9469cb8b0e Merge branch '2.0' into 2.1 2026-05-12 13:53:36 +01:00
Sadie Powell e0b715b185 Sync the CI scripts. 2026-05-12 11:28:28 +01:00
Sadie Powell e6d7306202 Backport the mailmap changes from 2.1. 2026-05-12 11:26:06 +01:00
Sadie Powell 2107d18d9e Remove suggestion to email language file updates to team@.
Its 2026 and its way easier for everyone involved to just file a
pull request.
2026-05-11 13:00:55 +01:00
Sadie Powell acb9428635 Backport the locales-all advice from 2.1. 2026-05-11 12:58:47 +01:00
Sadie Powell d942da1df5 Update author list. 2026-05-06 12:01:57 +01:00
Sadie Powell a961259556 Merge branch '2.0' into 2.1. 2026-05-06 12:00:21 +01:00
Sadie Powell 27a19dcc52 Update the mailmap. 2026-05-06 11:59:03 +01:00
Sadie Powell e45814bfd6 Deduplicate the timer constructors with delegation. 2026-05-02 15:40:19 +01:00
Sadie Powell f12b590a6d Change Timer::Tick to return bool, get rid of the repeating field. 2026-05-02 15:40:19 +01:00
Sadie Powell c0bafe10b4 Avoid double deleting the ban timer in cs_ban. 2026-05-02 10:55:25 +01:00
dependabot[bot] 5f40d0d6bb Bump negrutiu/nsis-install from 2 to 3
Bumps [negrutiu/nsis-install](https://github.com/negrutiu/nsis-install) from 2 to 3.
- [Release notes](https://github.com/negrutiu/nsis-install/releases)
- [Commits](https://github.com/negrutiu/nsis-install/compare/v2...v3)

---
updated-dependencies:
- dependency-name: negrutiu/nsis-install
  dependency-version: '3'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-01 21:27:36 +01:00
Sadie Powell 6b416cc64d Bump for 2.1.25-git. 2026-05-01 12:39:20 +01:00
Sadie Powell 331c33c350 Release 2.1.24. 2026-05-01 12:38:33 +01:00
Sadie Powell 10eef1af23 Update the change log. 2026-05-01 12:38:18 +01:00
Sadie Powell 90ff716ed3 Remove using statements that break unity builds. 2026-04-30 13:37:03 +01:00
Sadie Powell f67c70e485 Get rid of the using statement for Configuration::Uplink.
This breaks unity builds.
2026-04-30 13:23:06 +01:00
Sadie Powell fd5e10c54c Fix an inverted default for should_commit. 2026-04-27 20:10:53 +01:00
Sadie Powell 029565c894 Convert some messages in cs_enforce to use format strings. 2026-04-26 18:26:23 +01:00
Sadie Powell 9b8862826c Sort the files before running xgettext so we get consistent output. 2026-04-26 18:24:19 +01:00
Sadie Powell e2dc77641a Add some helper methods to CommandSource for translation. 2026-04-26 18:07:56 +01:00
Sadie Powell 7eb710a009 Update the change log. 2026-04-26 12:57:03 +01:00
Sadie Powell b33b5a6630 Use versioned prefixes for the SQL database tables. 2026-04-26 12:49:54 +01:00
Sadie Powell f4d5b1f01d Clean up the Config script a bit. 2026-04-26 12:45:57 +01:00
Sadie Powell b61daf81b0 Allow as many dashes as provided on Config options. 2026-04-23 19:23:12 +01:00
Sadie Powell da3f667188 Update the change log. 2026-04-23 19:08:55 +01:00
Sadie Powell 040cd99027 Add more debug logging to db_json. 2026-04-23 19:08:55 +01:00
Sadie Powell 6c7977f239 Remove duplicate objects from corrupt databases on database write. 2026-04-23 19:08:55 +01:00
Sadie Powell 9b8570a2ee Banish Redis support to the shadow realm.
Nobody actually uses this and it hasn't been tested in years so it
a massive pain to maintain. It may be replaced with an alternate
NoSQL database such as MongoDB in the future.
2026-04-23 17:42:42 +01:00
Sadie Powell 64f386e29e Skip deserialising the old cert column when its empty. 2026-04-23 13:48:12 +01:00
Sadie Powell 9434be29bc Delete the cert object after removing it from the cert list. 2026-04-23 13:41:11 +01:00
Sadie Powell 9aff71fb2f Merge branch '2.0' into 2.1. 2026-04-16 11:54:36 +01:00
Sadie Powell ba26d9a15c Add a missing FNAME handler on InspIRCd 3+.
Closes #572.
2026-04-16 11:50:10 +01:00
Sadie Powell 22dc33de9f Add support for the ratified channel-context tag. 2026-04-09 12:01:16 +01:00
dependabot[bot] 11d6f58a1a Bump microsoft/setup-msbuild from 2 to 3
Bumps [microsoft/setup-msbuild](https://github.com/microsoft/setup-msbuild) from 2 to 3.
- [Release notes](https://github.com/microsoft/setup-msbuild/releases)
- [Commits](https://github.com/microsoft/setup-msbuild/compare/v2...v3)

---
updated-dependencies:
- dependency-name: microsoft/setup-msbuild
  dependency-version: '3'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-01 22:06:38 +01:00
Sadie Powell f32d6453f5 Bump for 2.1.24-git. 2026-04-01 10:58:23 +01:00
Sadie Powell 9834040948 Fix checking the wrong config option in os_stats. 2026-03-11 16:41:50 +00:00
158 changed files with 6311 additions and 2641 deletions
+2 -1
View File
@@ -35,5 +35,6 @@ I have ensured that:
- [ ] The code I am submitting is my own work and/or I have permission from the author to share it. - [ ] The code I am submitting is my own work and/or I have permission from the author to share it.
- [ ] Generative AI (Copilot, ChatGPT, etc) was not used to create any part of this pull request. - [ ] Generative AI (Copilot, ChatGPT, etc) was not used to create any part of this pull request.
- [ ] I have documented any features added by this pull request. - [ ] If the pull request contains a security fix I have followed the reporting rules mentioned in [the security policy](https://github.com/anope/anope/security/policy) (delete if not applicable).
- [ ] I have documented any features added by this pull request (delete if not applicable).
- [ ] This pull request does not introduce any incompatible API changes (stable branches only, delete if not applicable). - [ ] This pull request does not introduce any incompatible API changes (stable branches only, delete if not applicable).
+25 -16
View File
@@ -3,21 +3,18 @@ on:
pull_request: pull_request:
push: push:
schedule: schedule:
- cron: '0 0 * * 0' - cron: 0 0 * * 0
workflow_dispatch: workflow_dispatch:
jobs: jobs:
build: build:
if: "!contains(github.event.head_commit.message, '[skip alpine ci]')" if: "!contains(github.event.head_commit.message, '[skip alpine ci]')"
container: alpine:edge container: alpine:latest
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
CXX: ${{ matrix.compiler }}
CXXFLAGS: -Werror
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@v7
- name: Install dependencies - name: Install dependencies
run: | run: |-
echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
apk update apk update
apk add \ apk add \
@@ -37,24 +34,36 @@ jobs:
tre-dev tre-dev
- name: Enable extras - name: Enable extras
run: | run: |-
for MODULE in enc_argon2 enc_posix ldap mysql regex_pcre2 regex_posix regex_tre sqlite ssl_gnutls ssl_openssl for MODULE in enc_argon2 enc_posix ldap mysql regex_pcre2 regex_posix regex_tre sqlite ssl_gnutls ssl_openssl
do do
ln -s $PWD/modules/extra/$MODULE.cpp $PWD/modules ln -s $PWD/modules/extra/$MODULE.cpp $PWD/modules
done done
- name: Run CMake - name: Run CMake
run: | env:
mkdir build && cd build CC: ${{ matrix.compiler.cc }}
cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=DEBUG -DINSTDIR:STRING=$(readlink -f ../run) .. CXX: ${{ matrix.compiler.cxx }}
CXXFLAGS: -Werror
run: |-
cmake -B "build" \
-D "CMAKE_BUILD_TYPE=Debug" \
-D "INSTDIR=$(readlink -f ../run)" \
-G "Ninja" \
-Wdeprecated \
-Wdev
- name: Build Anope - name: Build and install
run: | env:
ninja -C build install VERBOSE: ${{ runner.debug }}
run: |-
ninja -C "build" ${{ runner.debug == '1' && '-v' || '' }} install
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
compiler: compiler:
- clang++ - cc: clang
- g++ cxx: clang++
- cc: gcc
cxx: g++
+25 -16
View File
@@ -3,20 +3,17 @@ on:
pull_request: pull_request:
push: push:
schedule: schedule:
- cron: '0 0 * * 0' - cron: 0 0 * * 0
workflow_dispatch: workflow_dispatch:
jobs: jobs:
build: build:
if: "!contains(github.event.head_commit.message, '[skip ubuntu ci]')" if: "!contains(github.event.head_commit.message, '[skip ubuntu ci]')"
runs-on: ubuntu-24.04 runs-on: ubuntu-latest
env:
CXX: ${{ matrix.compiler }}
CXXFLAGS: -Werror
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@v7
- name: Install dependencies - name: Install dependencies
run: | run: |-
sudo apt-get update --assume-yes sudo apt-get update --assume-yes
sudo apt-get install --assume-yes --no-install-recommends \ sudo apt-get install --assume-yes --no-install-recommends \
clang \ clang \
@@ -34,24 +31,36 @@ jobs:
ninja-build ninja-build
- name: Enable extras - name: Enable extras
run: | run: |-
for MODULE in enc_argon2 enc_posix ldap mysql regex_pcre2 regex_posix regex_tre sqlite ssl_gnutls ssl_openssl for MODULE in enc_argon2 enc_posix ldap mysql regex_pcre2 regex_posix regex_tre sqlite ssl_gnutls ssl_openssl
do do
ln -s ${{ github.workspace }}/modules/extra/$MODULE.cpp ${{ github.workspace }}/modules ln -s ${{ github.workspace }}/modules/extra/$MODULE.cpp ${{ github.workspace }}/modules
done done
- name: Run CMake - name: Run CMake
run: | env:
mkdir build && cd build CC: ${{ matrix.compiler.cc }}
cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=DEBUG -DINSTDIR:STRING=${{ github.workspace }}/run .. CXX: ${{ matrix.compiler.cxx }}
CXXFLAGS: -Werror
run: |-
cmake -B "build" \
-D "CMAKE_BUILD_TYPE=Debug" \
-D "INSTDIR=${{ github.workspace }}/run" \
-G "Ninja" \
-Wdeprecated \
-Wdev
- name: Build Anope - name: Build and install
run: | env:
ninja -C ${{ github.workspace }}/build install VERBOSE: ${{ runner.debug }}
run: |-
ninja -C "build" ${{ runner.debug == '1' && '-v' || '' }} install
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
compiler: compiler:
- clang++ - cc: clang
- g++ cxx: clang++
- cc: gcc
cxx: g++
+41 -28
View File
@@ -6,77 +6,90 @@ on:
types: types:
- published - published
schedule: schedule:
- cron: '0 0 * * 0' - cron: 0 0 * * 0
workflow_dispatch: workflow_dispatch:
jobs: jobs:
build: build:
if: "!contains(github.event.head_commit.message, '[skip windows ci]')" if: "!contains(github.event.head_commit.message, '[skip windows ci]')"
runs-on: windows-2025 runs-on: windows-2025
env: env:
BUILD_PATH: ${{ github.workspace }}\build
BUILD_TYPE: ${{ github.event_name == 'release' && 'Release' || 'Debug' }} BUILD_TYPE: ${{ github.event_name == 'release' && 'Release' || 'Debug' }}
CONAN_FILE: ${{ github.workspace }}\src\win32\conanfile.txt
CONAN_HOME: ${{ github.workspace }}\build\conan CONAN_HOME: ${{ github.workspace }}\build\conan
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@v7
- name: Install NSIS - name: Setup MSVC
uses: negrutiu/nsis-install@v2 uses: TheMrMilchmann/setup-msvc-dev@v4
with:
arch: x64
- name: Setup NSIS
uses: negrutiu/nsis-install@v3
with: with:
distro: official distro: official
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- name: Setup Conan - name: Setup Conan
uses: turtlebrowser/get-conan@v1.2 uses: turtlebrowser/get-conan@v1.2
- name: Create Conan profile - name: Create Conan configuration
run: |- run: |-
conan profile detect conan profile detect
(Get-Content ${{ env.CONAN_HOME }}\profiles\default).replace('build_type=Release', 'build_type=${{ env.BUILD_TYPE }}') | Set-Content ${{ env.CONAN_HOME }}\profiles\default (Get-Content ${{ env.CONAN_HOME }}\profiles\default).replace('build_type=Release', 'build_type=${{ env.BUILD_TYPE }}') | Set-Content ${{ env.CONAN_HOME }}\profiles\default
(Get-Content ${{ env.CONAN_HOME }}\profiles\default).replace('compiler.cppstd=14', 'compiler.cppstd=17') | Set-Content ${{ env.CONAN_HOME }}\profiles\default (Get-Content ${{ env.CONAN_HOME }}\profiles\default).replace('compiler.cppstd=14', 'compiler.cppstd=17') | Set-Content ${{ env.CONAN_HOME }}\profiles\default
Write-Output 'core.sources:download_urls=["origin", "https://c3i.jfrog.io/artifactory/conan-center-backup-sources/"]' | Out-File -Append ${{ env.CONAN_HOME }}\global.conf Write-Output 'core.sources:download_urls=["origin", "https://c3i.jfrog.io/artifactory/conan-center-backup-sources/"]' | Out-File -Append ${{ env.CONAN_HOME }}\global.conf
Write-Output 'tools.cmake.cmaketoolchain:generator=Ninja' | Out-File -Append ${{ env.CONAN_HOME }}\global.conf
Write-Output 'user.openssl:windows_use_jom=True' | Out-File -Append ${{ env.CONAN_HOME }}\global.conf
- name: Try to restore libraries from the cache - name: Try to restore libraries from the cache
uses: actions/cache/restore@v5 if: github.event_name != 'release'
uses: actions/cache/restore@v6
id: library-cache id: library-cache
with: with:
key: conan-${{ env.BUILD_TYPE }}-${{ hashFiles('src\win32\conanfile.txt') }} key: Conan VS${{ env.VisualStudioVersion }} ${{ env.BUILD_TYPE }} ${{ hashFiles(env.CONAN_FILE) }}
path: ${{ env.CONAN_HOME }}\p path: ${{ env.CONAN_HOME }}/p
- name: Install libraries - name: Install libraries
run: | working-directory: ${{ env.BUILD_PATH }}
(Get-Content ${{ github.workspace }}\src\win32\conanfile.txt).replace('##', '') | Set-Content ${{ github.workspace }}\src\win32\conanfile.txt run: |-
conan install ${{ github.workspace }}\src\win32 --build missing --deployer runtime_deploy --deployer-folder ${{ github.workspace }}\build\extradll --output-folder . (Get-Content ${{ env.CONAN_FILE }}).replace('##', '') | Set-Content ${{ env.CONAN_FILE }}
conan install ${{ env.CONAN_FILE }} --build missing --deployer runtime_deploy --deployer-folder extradll --output-folder .
conan cache clean "*"
- name: Save libraries to the cache - name: Save libraries to the cache
if: ${{ steps.library-cache.outputs.cache-hit != 'true' }} if: steps.library-cache.outputs.cache-hit != 'true' && github.event_name != 'release'
uses: actions/cache/save@v5 uses: actions/cache/save@v6
with: with:
key: ${{ steps.library-cache.outputs.cache-primary-key }} key: ${{ steps.library-cache.outputs.cache-primary-key }}
path: ${{ env.CONAN_HOME }}\p path: ${{ env.CONAN_HOME }}\p
- name: Run CMake - name: Run CMake
shell: cmd # work around a conan-io/conan-center-index bug #21823 working-directory: ${{ env.BUILD_PATH }}
working-directory: ${{ github.workspace }}\build run: |-
run: | cmake -D "CMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}" `
call ${{ github.workspace }}\conanbuild.bat -D "CMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake" `
cmake -A x64 -D "CMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}" -D CMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -G "Visual Studio 17 2022" .. -G "Ninja Multi-Config" `
-S "${{ github.workspace }}" `
-Wdeprecated `
-Wdev
- name: Build Anope - name: Build installer
working-directory: ${{ github.workspace }}\build working-directory: ${{ env.BUILD_PATH }}
run: | run: |-
msbuild PACKAGE.vcxproj /M:5 /P:Configuration=${{ env.BUILD_TYPE }} /P:Platform=x64 /VERBOSITY:MINIMAL ninja -f "build-${{ env.BUILD_TYPE }}.ninja" ${{ runner.debug == '1' && '-v' || '' }} package
- name: Upload installer - name: Upload installer
if: "${{ github.event_name == 'release' }}" if: github.event_name == 'release'
working-directory: ${{ github.workspace }}\build working-directory: ${{ env.BUILD_PATH }}
env: env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: | run: |
gh release upload ${{ github.event.release.tag_name }} $(Get-ChildItem anope-*.exe) gh release upload ${{ github.event.release.tag_name }} $(Get-ChildItem anope-*.exe)
- name: Upload artifact - name: Upload artifact
if: "${{ github.event_name != 'release' }}" if: github.event_name != 'release'
uses: actions/upload-artifact@v7 uses: actions/upload-artifact@v7
with: with:
name: windows-installer name: windows-installer
+223
View File
@@ -0,0 +1,223 @@
name: irctest
# Last checked: 2026-06-29
env:
INSPIRCD_REF: v4.11.0 # 2026-06-06
IRCTEST_REF: ff6ef19d96cacd79ea8033dda2cf660fe5cdba52 # 2026-06-20
SOLANUM_REF: a17cc145a7de564e49b84807d335289f30b12d00 # 2026-06-23
UNREALIRCD_REF: 1250b7f014dbbe1dae13138dbef6e52c6dcd5557 # 2026-05-15 (6.2.5)
on:
pull_request:
push:
schedule:
- cron: 0 0 * * 0
workflow_dispatch:
jobs:
check-skip:
if: "!contains(github.event.head_commit.message, '[skip irctest ci]')"
runs-on: ubuntu-26.04-arm
steps:
- run: true # Avoids skip check duplication.
build-anope:
needs:
- check-skip
runs-on: ubuntu-26.04-arm
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Build
run: |-
sudo apt-get install build-essential cmake --assume-yes
cmake \
-B "${{ github.workspace }}/build" \
-D "CMAKE_UNITY_BUILD=ON" \
-D "CMAKE_UNITY_BUILD_BATCH_SIZE=0" \
-D "INSTDIR=$HOME/software/anope" \
-G "Ninja" \
-S "${{ github.workspace }}"
ninja -C "${{ github.workspace }}/build" install
- name: Make artifact
run: |-
tar \
--auto-compress \
--create \
--file installed-anope.tar.gz \
$HOME/software/anope
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: installed-anope
path: installed-anope.tar.gz
retention-days: 1
build-inspircd:
needs:
- check-skip
runs-on: ubuntu-26.04-arm
steps:
- name: Checkout
uses: actions/checkout@v7
with:
ref: ${{ env.INSPIRCD_REF }}
repository: inspircd/inspircd
- name: Build
run: |-
sudo apt-get install build-essential --assume-yes
./configure \
--development \
--disable-auto-extras \
--prefix $HOME/software/inspircd
export CXXFLAGS="-DINSPIRCD_UNLIMITED_MAINLOOP"
make -j$(($(getconf _NPROCESSORS_ONLN) + 1)) install
- name: Make artifact
run: |-
tar \
--auto-compress \
--create \
--file installed-inspircd.tar.gz \
$HOME/software/inspircd
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: installed-inspircd
path: installed-inspircd.tar.gz
retention-days: 1
build-solanum:
needs:
- check-skip
runs-on: ubuntu-26.04-arm
steps:
- name: Checkout
uses: actions/checkout@v7
with:
ref: ${{ env.SOLANUM_REF }}
repository: solanum-ircd/solanum
- name: Build
run: |-
sudo apt-get install build-essential libltdl-dev --assume-yes
./autogen.sh
./configure \
--enable-fhs-paths \
--prefix $HOME/software/solanum
make -j$(($(getconf _NPROCESSORS_ONLN) + 1)) install
- name: Make artifact
run: |-
tar \
--auto-compress \
--create \
--file installed-solanum.tar.gz \
$HOME/software/solanum
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: installed-solanum
path: installed-solanum.tar.gz
retention-days: 1
build-unrealircd:
needs:
- check-skip
runs-on: ubuntu-26.04-arm
steps:
- name: Checkout
uses: actions/checkout@v7
with:
ref: ${{ env.UNREALIRCD_REF }}
repository: unrealircd/unrealircd
- name: Build
run: |-
sudo apt-get install build-essential libssl-dev --assume-yes
wget --output-document src/modules/third/metadata2.c https://raw.githubusercontent.com/progval/unrealircd-contrib/metadata2/files/metadata2.c
echo "BASEPATH=$HOME/software/unrealircd" >> config.settings
echo "GEOIP=none" >> config.settings
yes "" | ./Config
make -j$(($(getconf _NPROCESSORS_ONLN) + 1)) install
- name: Make artifact
run: |-
tar \
--auto-compress \
--create \
--file installed-unrealircd.tar.gz \
$HOME/software/unrealircd
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: installed-unrealircd
path: installed-unrealircd.tar.gz
retention-days: 1
test:
runs-on: ubuntu-26.04-arm
needs:
- build-anope
- build-inspircd
- build-solanum
- build-unrealircd
steps:
- name: Download Anope artifact
uses: actions/download-artifact@v8
with:
name: installed-anope
- name: Download server artifact
uses: actions/download-artifact@v8
with:
name: installed-${{ matrix.server }}
- name: Unpack artifacts
run: |-
for ARCHIVE in installed-anope installed-${{ matrix.server }}
do
tar \
--directory / \
--extract \
--file ${ARCHIVE}.tar.gz
done
for SOFTWARE in $HOME/software/*
do
echo "Adding ${SOFTWARE} to the PATH"
export PATH=$SOFTWARE/bin:$SOFTWARE/sbin:$PATH
done
echo PATH=$PATH >> $GITHUB_ENV
- name: Checkout irctest
uses: actions/checkout@v7
with:
ref: ${{ env.IRCTEST_REF }}
repository: progval/irctest
- name: Install irctest dependencies
run: |-
sudo apt-get install faketime
pip3 install --requirement requirements.txt pytest-xdist pytest-timeout
- name: Run irctest
env:
IRCTEST_DEBUG_LOGS: ${{ runner.debug }}
PYTEST_ARGS: --color=yes --verbose
run: |-
make ${{ matrix.server}}-anope
strategy:
fail-fast: false
matrix:
server:
- inspircd
- solanum
- unrealircd
+2 -1
View File
@@ -51,7 +51,8 @@ Robby <robby@chatbelgie.be> <robby@chat.be>
Robert Scheck <robert@fedoraproject.org> <robert-scheck@users.noreply.github.com> Robert Scheck <robert@fedoraproject.org> <robert-scheck@users.noreply.github.com>
Robin Burchell <w00t@inspircd.org> <rburchell@5417fbe8-f217-4b02-8779-1006273d7864> Robin Burchell <w00t@inspircd.org> <rburchell@5417fbe8-f217-4b02-8779-1006273d7864>
Robin Burchell <w00t@inspircd.org> <Robin Burchell w00t@inspircd.org@5417fbe8-f217-4b02-8779-1006273d7864> Robin Burchell <w00t@inspircd.org> <Robin Burchell w00t@inspircd.org@5417fbe8-f217-4b02-8779-1006273d7864>
Sadie Powell <sadie@witchery.services> <petpow@saberuk.com> Sadie Powell <sadie@sadiepowell.dev> <petpow@saberuk.com>
Sadie Powell <sadie@sadiepowell.dev> <sadie@witchery.services>
Sebastian Barfurth <github@afreshmelon.com> Sebastian Barfurth <github@afreshmelon.com>
Sebastian V. <hal9000@denorastats.org> Sebastian V. <hal9000@denorastats.org>
Sebastian V. <hal9000@denorastats.org> <pimpmylinux@5417fbe8-f217-4b02-8779-1006273d7864> Sebastian V. <hal9000@denorastats.org> <pimpmylinux@5417fbe8-f217-4b02-8779-1006273d7864>
+42 -31
View File
@@ -1,8 +1,8 @@
# This usage of CMake requires at least version 3.20 # This usage of CMake requires at least version 3.20
cmake_minimum_required(VERSION 3.20 FATAL_ERROR) cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
# Set the project as C++ primarily # Set the project as C++ primarily with C for the vendored libraries
project(Anope CXX) project(Anope CXX C)
# Force the locale to C for later uses of things like gcc so the messages come up in English, not the user's default language # Force the locale to C for later uses of things like gcc so the messages come up in English, not the user's default language
set(ENV{LC_ALL} C) set(ENV{LC_ALL} C)
@@ -25,6 +25,7 @@ include(CheckFunctionExists)
include(CheckTypeSize) include(CheckTypeSize)
include(CheckLibraryExists) include(CheckLibraryExists)
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
include(CheckPIESupported)
if(NOT WIN32) if(NOT WIN32)
include(FindPkgConfig) include(FindPkgConfig)
@@ -40,15 +41,19 @@ if(EXTRA_LIBS)
link_directories(${EXTRA_LIBS}) link_directories(${EXTRA_LIBS})
endif() endif()
# Enable -fPIC for all targets.
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
check_pie_supported()
# Find gettext # Find gettext
find_package(Gettext) find_package(Gettext)
find_package(Intl) find_package(Intl)
if(GETTEXT_FOUND AND Intl_FOUND) if(Gettext_FOUND AND Intl_FOUND)
set(HAVE_LOCALIZATION ON) set(HAVE_LOCALIZATION ON)
include_directories(${Intl_INCLUDE_DIRS}) include_directories(${Intl_INCLUDE_DIRS})
link_libraries(${Intl_LIBRARIES}) link_libraries(${Intl_LIBRARIES})
else() else()
message("Unable to find gettext and libintl; disabling localization") message(STATUS "Unable to find gettext and/or libintl -- read docs/LANGUAGE for how to enable localization")
set(HAVE_LOCALIZATION OFF) set(HAVE_LOCALIZATION OFF)
endif() endif()
@@ -144,28 +149,37 @@ elseif(NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/anope-${VERSION_MAJOR}-${VERSION_MINOR}") set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/anope-${VERSION_MAJOR}-${VERSION_MINOR}")
endif() endif()
function(configure_path VARIABLE DEFAULT)
if(NOT DEFINED ${VARIABLE})
set(${VARIABLE} ${DEFAULT} CACHE PATH "Location of the ${DEFAULT} directory")
endif()
if(WIN32)
set(ABSOLUTE_${VARIABLE} ${${VARIABLE}})
else()
cmake_path(
APPEND CMAKE_INSTALL_PREFIX "${${VARIABLE}}"
OUTPUT_VARIABLE ABSOLUTE_${VARIABLE}
)
cmake_path(NORMAL_PATH ABSOLUTE_${VARIABLE})
endif()
set(ABSOLUTE_${VARIABLE} ${ABSOLUTE_${VARIABLE}} CACHE INTERNAL "" FORCE)
install(
DIRECTORY
DESTINATION ${${VARIABLE}}
)
endfunction()
# Set default paths for various directories if not already defined # Set default paths for various directories if not already defined
if(NOT BIN_DIR) configure_path(BIN_DIR "bin")
set(BIN_DIR "bin") configure_path(DATA_DIR "data")
endif() configure_path(DOC_DIR "doc")
if(NOT DATA_DIR) configure_path(CONF_DIR "conf")
set(DATA_DIR "data") configure_path(MODULE_DIR "modules")
endif() configure_path(LOCALE_DIR "locale")
if(NOT DOC_DIR) configure_path(LOG_DIR "logs")
set(DOC_DIR "doc")
endif()
if(NOT CONF_DIR)
set(CONF_DIR "conf")
endif()
if(NOT MODULE_DIR)
set(MODULE_DIR "modules")
endif()
if(NOT LOCALE_DIR)
set(LOCALE_DIR "locale")
endif()
if(NOT LOG_DIR)
set(LOG_DIR "logs")
endif()
# Version number processing # Version number processing
# Find all lines in src/version.sh that start with VERSION_ # Find all lines in src/version.sh that start with VERSION_
@@ -218,12 +232,9 @@ set(SERVICES_BINARY "$<TARGET_FILE:${PROGRAM_NAME}>")
cmake_path(GET SERVICES_BINARY FILENAME SERVICES_BINARY) cmake_path(GET SERVICES_BINARY FILENAME SERVICES_BINARY)
# At install time, create the following additional directories # At install time, create the following additional directories
file(REAL_PATH ${DATA_DIR} ABSOLUTE_DATA_DIR BASE_DIRECTORY ${CMAKE_INSTALL_PREFIX}) install(DIRECTORY DESTINATION "${DATA_DIR}/backups")
file(REAL_PATH ${LOG_DIR} ABSOLUTE_LOG_DIR BASE_DIRECTORY ${CMAKE_INSTALL_PREFIX})
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ABSOLUTE_DATA_DIR}/backups\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ABSOLUTE_LOG_DIR}\")")
if(WIN32) if(WIN32)
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ABSOLUTE_DATA_DIR}/runtime\")") install(DIRECTORY DESTINATION "${DATA_DIR}/runtime")
endif() endif()
# On non-Windows platforms, if RUNGROUP is set, change the permissions of the below directories, as well as the group of the data directory # On non-Windows platforms, if RUNGROUP is set, change the permissions of the below directories, as well as the group of the data directory
if(NOT WIN32 AND RUNGROUP) if(NOT WIN32 AND RUNGROUP)
@@ -238,7 +249,6 @@ if(WIN32)
) )
endif() endif()
file(REAL_PATH ${MODULE_DIR} ABSOLUTE_MODULE_DIR BASE_DIRECTORY ${CMAKE_INSTALL_PREFIX})
install(CODE "file(REMOVE_RECURSE \"$ENV{DESTDIR}${ABSOLUTE_MODULE_DIR}\")") install(CODE "file(REMOVE_RECURSE \"$ENV{DESTDIR}${ABSOLUTE_MODULE_DIR}\")")
# Only process the CPack section if we have CPack # Only process the CPack section if we have CPack
@@ -289,6 +299,7 @@ endif()
add_subdirectory(data) add_subdirectory(data)
add_subdirectory(docs) add_subdirectory(docs)
add_subdirectory(language) add_subdirectory(language)
add_subdirectory(vendor)
add_subdirectory(src) add_subdirectory(src)
add_subdirectory(modules) add_subdirectory(modules)
add_subdirectory(include) add_subdirectory(include)
+25 -26
View File
@@ -29,43 +29,41 @@ Load_Cache () {
} }
Run_Build_System () { Run_Build_System () {
WITH_INST="" BUILD_DIR="${SOURCE_DIR}/build"
WITH_RUN="" CMAKE_COMMAND="${CMAKE:-cmake} -B ${BUILD_DIR} -S ${SOURCE_DIR}"
WITH_PERM=""
EXTRA_INCLUDE=""
EXTRA_LIBS=""
if [ "$INSTDIR" != "" ] ; then if [ "$INSTDIR" != "" ] ; then
WITH_INST="-DINSTDIR=$INSTDIR" CMAKE_COMMAND="${CMAKE_COMMAND} -D INSTDIR=$INSTDIR"
fi fi
if [ "$RUNGROUP" != "" ] ; then if [ "$RUNGROUP" != "" ] ; then
WITH_RUN="-DRUNGROUP=$RUNGROUP" CMAKE_COMMAND="${CMAKE_COMMAND} -D RUNGROUP=$RUNGROUP"
fi fi
if [ "$UMASK" != "" ] ; then if [ "$UMASK" != "" ] ; then
WITH_PERM="-DDEFUMASK=$UMASK" CMAKE_COMMAND="${CMAKE_COMMAND} -D DEFUMASK=$UMASK"
fi fi
if [ "$DEBUG" = "yes" ] ; then if [ "$DEBUG" = "yes" ] ; then
BUILD_TYPE="-DCMAKE_BUILD_TYPE=Debug" CMAKE_COMMAND="${CMAKE_COMMAND} -D CMAKE_BUILD_TYPE=Debug"
else else
BUILD_TYPE="-DCMAKE_BUILD_TYPE=Release" CMAKE_COMMAND="${CMAKE_COMMAND} -D CMAKE_BUILD_TYPE=Release"
fi fi
if [ "$EXTRA_INCLUDE_DIRS" != "" ] ; then if [ "$EXTRA_INCLUDE_DIRS" != "" ] ; then
EXTRA_INCLUDE="-DEXTRA_INCLUDE=$EXTRA_INCLUDE_DIRS" CMAKE_COMMAND="${CMAKE_COMMAND} -D EXTRA_INCLUDE=$EXTRA_INCLUDE_DIRS"
fi fi
if [ "$EXTRA_LIB_DIRS" != "" ] ; then if [ "$EXTRA_LIB_DIRS" != "" ] ; then
EXTRA_LIBS="-DEXTRA_LIBS=$EXTRA_LIB_DIRS" CMAKE_COMMAND="${CMAKE_COMMAND} -D EXTRA_LIBS=$EXTRA_LIB_DIRS"
fi fi
BUILD_PATHS="-B ${SOURCE_DIR}/build ${SOURCE_DIR}" if [ "$EXTRA_CONFIG_ARGS" != "" ] ; then
CMAKE_COMMAND="${CMAKE_COMMAND} $EXTRA_CONFIG_ARGS"
fi
CMAKE="cmake $GEN_TYPE $WITH_INST $WITH_RUN $WITH_PERM $BUILD_TYPE $EXTRA_INCLUDE $EXTRA_LIBS $EXTRA_CONFIG_ARGS $BUILD_PATHS" echo $CMAKE_COMMAND
echo $CMAKE $CMAKE_COMMAND
$CMAKE
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "You should fix these issues and then run ./Config -quick to rerun CMake." echo "You should fix these issues and then run ./Config -quick to rerun CMake."
@@ -73,11 +71,7 @@ Run_Build_System () {
fi fi
echo "" echo ""
if [ "$PWD" = "${SOURCE_DIR}/build" ]; then echo "Now run 'make -C ${BUILD_DIR#"$PWD/"} install' to build and install Anope."
echo "Now run make to build Anope."
else
echo "Now cd build, then run make to build Anope."
fi
} }
########################################################################### ###########################################################################
@@ -98,7 +92,12 @@ CAN_QUICK="no"
########################################################################### ###########################################################################
while [ $# -ge 1 ] ; do while [ $# -ge 1 ] ; do
if [ $1 = "--help" ] ; then OPTION=$1
while [ "${OPTION#-}" != "$OPTION" ]; do
OPTION="${OPTION#-}"
done
if [ "$OPTION" = "--help" ] ; then
echo "Config utility for Anope" echo "Config utility for Anope"
echo "------------------------" echo "------------------------"
echo "Syntax: ./Config [options]" echo "Syntax: ./Config [options]"
@@ -106,15 +105,15 @@ while [ $# -ge 1 ] ; do
echo "-nointro Skip intro (disclaimer, etc)" echo "-nointro Skip intro (disclaimer, etc)"
echo "-quick Skip questions, go straight to cmake" echo "-quick Skip questions, go straight to cmake"
exit 0 exit 0
elif [ $1 = "-devel" ] ; then elif [ "$OPTION" = "devel" ] ; then
DEBUG="yes" DEBUG="yes"
DEVEL="yes" DEVEL="yes"
INSTDIR="$SOURCE_DIR/run" INSTDIR="$SOURCE_DIR/run"
elif [ $1 = "-nocache" ] ; then elif [ "$OPTION" = "nocache" ] ; then
IGNORE_CACHE="1" IGNORE_CACHE="1"
elif [ $1 = "-nointro" ] ; then elif [ "$OPTION" = "nointro" ] ; then
NO_INTRO="1" NO_INTRO="1"
elif [ $1 = "-quick" -o $1 = "-q" ] ; then elif [ "$OPTION" = "quick" -o "$OPTION" = "q" ] ; then
Load_Cache Load_Cache
if [ "$CAN_QUICK" = "yes" ] ; then if [ "$CAN_QUICK" = "yes" ] ; then
Run_Build_System Run_Build_System
+2 -22
View File
@@ -1228,7 +1228,7 @@ module
* An optional prefix to prepended to the name of each created table. * An optional prefix to prepended to the name of each created table.
* Do not use the same prefix for other programs. * Do not use the same prefix for other programs.
*/ */
#prefix = "anope_db_" #prefix = "anope21_"
/* /*
* Whether or not to import data from another database module in to SQL on * Whether or not to import data from another database module in to SQL on
@@ -1248,26 +1248,6 @@ module
import = no import = no
} }
/*
* db_redis.
*
* This module allows using Redis (https://redis.io/) as a database backend.
* This module requires that redis is loaded and configured properly.
*
* Redis 2.8 supports keyspace notifications which allows Redis to push notifications
* to Anope about outside modifications to the database. This module supports this and
* will internally reflect any changes made to the database immediately once notified.
* See docs/REDIS for more information regarding this.
*/
#module
{
name = "db_redis"
/*
* Redis database to use. This must be configured with redis.
*/
engine = "redis/main"
}
/* /*
* [RECOMMENDED] Encryption modules. * [RECOMMENDED] Encryption modules.
@@ -1316,7 +1296,7 @@ module
/** The memory hardness in kibibytes of the Argon2 algorithm. Defaults to /** The memory hardness in kibibytes of the Argon2 algorithm. Defaults to
* 128 mebibytes. * 128 mebibytes.
*/ */
#memory_cost = 121072 #memory_cost = 131072
/** The time hardness (iterations) of the Argon2 algorithm. Defaults to 3. /** The time hardness (iterations) of the Argon2 algorithm. Defaults to 3.
*/ */
+5
View File
@@ -252,6 +252,7 @@ privilege
rank = 10 rank = 10
level = 3 level = 3
flag = "f" flag = "f"
flag_migration_requires = "ACCESS_CHANGE"
xop = "VOP" xop = "VOP"
} }
@@ -496,6 +497,7 @@ privilege
rank = 110 rank = 110
level = 4 level = 4
flag = "h" flag = "h"
flag_migration_requires = "HALFOP"
xop = "HOP" xop = "HOP"
} }
@@ -638,6 +640,7 @@ privilege
rank = 220 rank = 220
level = 5 level = 5
flag = "o" flag = "o"
flag_migration_requires = "OP"
xop = "AOP" xop = "AOP"
} }
@@ -710,6 +713,7 @@ privilege
rank = 300 rank = 300
level = 10 level = 10
flag = "a" flag = "a"
flag_migration_requires = "PROTECT"
xop = "SOP" xop = "SOP"
} }
@@ -853,6 +857,7 @@ privilege
rank = 60 rank = 60
level = 3 level = 3
flag = "v" flag = "v"
flag_migration_requires = "VOICE"
xop = "VOP" xop = "VOP"
} }
+1 -1
View File
@@ -22,7 +22,7 @@ module
* An optional prefix to prepended to the name of each created table. * An optional prefix to prepended to the name of each created table.
* Do not use the same prefix for other programs. * Do not use the same prefix for other programs.
*/ */
prefix = "anope_" #prefix = "chanstats21_"
smileyshappy = ":) :-) ;) ;-) :D :-D :P :-P" smileyshappy = ":) :-) ;) ;-) :D :-D :P :-P"
smileyssad = ":( :-( ;( ;-(" smileyssad = ":( :-( ;( ;-("
+13
View File
@@ -201,6 +201,19 @@ module
{ {
name = "hs_request" name = "hs_request"
/*
* How long after a requested vhost is activated does a user have to wait
* before they can request a new vhost. Defaults to 24 hours.
*/
#activationcooldown = 24h
/*
* How long after a requested vhost is rejected does a user have to wait
* before they can request a new vhost. Defaults to 24 hours.
*/
#rejectioncooldown = 24h
/* /*
* If set, Anope will send a memo to the user requesting a vhost when it's been * If set, Anope will send a memo to the user requesting a vhost when it's been
* approved or rejected. * approved or rejected.
-24
View File
@@ -374,30 +374,6 @@ module { name = "help" }
} }
} }
/*
* redis
*
* This module allows other modules to use Redis.
*/
#module
{
name = "redis"
/* A redis database */
redis
{
/* The name of this service */
name = "redis/main"
/*
* The redis database to use. New connections default to 0.
*/
db = 0
ip = "127.0.0.1"
port = 6379
}
}
/* /*
* [EXTRA] regex_pcre2 * [EXTRA] regex_pcre2
+15 -2
View File
@@ -120,6 +120,10 @@ module
* - ns_keep_modes: Enables keepmodes, which retains user modes across sessions * - ns_keep_modes: Enables keepmodes, which retains user modes across sessions
* - protect: Protects the registered nickname from use by unidentified users. * - protect: Protects the registered nickname from use by unidentified users.
* - ns_stats: Enable Chanstats for newly registered nicks * - ns_stats: Enable Chanstats for newly registered nicks
* - ns_flexible: Set FLEXIBLE as layout for messages from services (can not be set at the same
* time as ns_monospace)
* - ns_monospace: Set MONOSPACE as layout for messages from services (can not be set as the same
* time as ns_flexible)
* *
* This directive is optional, if left blank, the options will default to memo_signon, and * This directive is optional, if left blank, the options will default to memo_signon, and
* memo_receive. If you really want no defaults, use "none" by itself as the option. * memo_receive. If you really want no defaults, use "none" by itself as the option.
@@ -128,9 +132,9 @@ module
/* /*
* The minimum length of time between consecutive uses of NickServ's REGISTER command. This * The minimum length of time between consecutive uses of NickServ's REGISTER command. This
* directive is optional, but recommended. If not set, this restriction will be disabled. * directive is optional, but recommended. If not set, it defaults to 15 minutes.
*/ */
regdelay = 5m regdelay = 15m
/* /*
* The length of time before a nick's registration expires. * The length of time before a nick's registration expires.
@@ -416,6 +420,12 @@ module
{ {
name = "ns_group" name = "ns_group"
/*
* The minimum length of time between consecutive uses of the GROUP command. This directive is
* optional, but recommended. If not set, it defaults to 5 minutes.
*/
delay = 5m
/* /*
* The maximum number of nicks allowed in a group. * The maximum number of nicks allowed in a group.
* *
@@ -741,6 +751,9 @@ command { service = "NickServ"; name = "SASET LAYOUT"; command = "nickserv/saset
* *
* misc_description: A description of the command to show in the help. * misc_description: A description of the command to show in the help.
* misc_title: A human-readable description of the stored data. * misc_title: A human-readable description of the stored data.
* misc_priority: Positive integer representing display order in nickserv/info
* and (if enabled) WHOIS output. Entries with unspecified
* priority will be prioritized in the order of declaration.
* misc_pattern: If defined then a regex pattern (using the engine specified * misc_pattern: If defined then a regex pattern (using the engine specified
* in <options:regexengine> to validate the data with). * in <options:regexengine> to validate the data with).
* misc_syntax: If defined then the syntax to show in the help output and, if * misc_syntax: If defined then the syntax to show in the help output and, if
+3 -3
View File
@@ -3,7 +3,7 @@ and other useful contributions to Anope. These people, ordered by the number of
contributions they have made, are: contributions they have made, are:
* Adam <adam@anope.org> * Adam <adam@anope.org>
* Sadie Powell <sadie@witchery.services> * Sadie Powell <sadie@sadiepowell.dev>
* Robin Burchell <w00t@inspircd.org> * Robin Burchell <w00t@inspircd.org>
* Naram Qashat <cyberbotx@anope.org> * Naram Qashat <cyberbotx@anope.org>
* Pieter Bootsma <geniusdex@anope.org> * Pieter Bootsma <geniusdex@anope.org>
@@ -20,8 +20,8 @@ contributions they have made, are:
* Adam Kramer <ribosome@anope.org> * Adam Kramer <ribosome@anope.org>
* Attila Molnar <attilamolnar@hush.com> * Attila Molnar <attilamolnar@hush.com>
* Michael Wobst <wobst.michael@web.de> * Michael Wobst <wobst.michael@web.de>
* Matt Schatz <genius3000@g3k.solutions>
* PeGaSuS <droider.pc@gmail.com> * PeGaSuS <droider.pc@gmail.com>
* Matt Schatz <genius3000@g3k.solutions>
* Mark Summers <mark@goopler.net> * Mark Summers <mark@goopler.net>
* Daniel Vassdal <shutter@canternet.org> * Daniel Vassdal <shutter@canternet.org>
* MatthewM <mcm@they-got.us> * MatthewM <mcm@they-got.us>
@@ -49,6 +49,7 @@ contributions they have made, are:
* Robert Scheck <robert@fedoraproject.org> * Robert Scheck <robert@fedoraproject.org>
* Dennis Friis <peavey@inspircd.org> * Dennis Friis <peavey@inspircd.org>
* Filippo Cortigiani <simos@simosnap.org> * Filippo Cortigiani <simos@simosnap.org>
* KidProtect
* Michał Zegan <webczat_200@poczta.onet.pl> * Michał Zegan <webczat_200@poczta.onet.pl>
* AlphaTech <alphat3ch@icloud.com> * AlphaTech <alphat3ch@icloud.com>
* Austin Ellis <siniStar@IRC4Fun.net> * Austin Ellis <siniStar@IRC4Fun.net>
@@ -71,7 +72,6 @@ contributions they have made, are:
* Jason Foster <retsofaj@gmail.com> * Jason Foster <retsofaj@gmail.com>
* Jeremy <jeremy@ssnet.ca> * Jeremy <jeremy@ssnet.ca>
* Josh Soref * Josh Soref
* KidProtect
* KindOne <ineedalifetoday@live.com> * KindOne <ineedalifetoday@live.com>
* linuxdaemon * linuxdaemon
* Mantas MikulÄ—nas <grawity@gmail.com> * Mantas MikulÄ—nas <grawity@gmail.com>
+94
View File
@@ -1,5 +1,99 @@
# Anope Change Log # Anope Change Log
## Anope 2.1.25 (unreleased)
### General Changes
* Added a cooldown timer to `hs_request` for after a vhost is approved or rejected.
* Added environment variables for configuring hashing algorithms to `anope-mkpasswd`.
* Added support for building with position-independent code on supported platforms.
* Added support for prioritising WHOIS entries in `ns_set_misc`.
* Documented the `ns_flexible` and `ns_monospace` account options.
* Dropped support for the `+draft/reply` tag in favour of the non-draft variant.
* Fixed a crash on shutdown when trying to send a global without an uplink.
* Fixed a crash when a temporary ban expires.
* Fixed a crash when trying to upgrade TLS fingerprints from an older algorithm.
* Fixed a potential crash caused by unusual timestamps being passed to `Anope::strftime`.
* Fixed confirming accounts when `{ns_register}:registration` is set to "admin".
* Fixed extra CMake arguments from `./Config` being ignored.
* Fixed flag migration sometimes giving users higher privileges than they had originally when a flag provides multiple privileges.
* Fixed not being able to update the description of a flags access entry.
* Fixed not migrating the last seen time with an access entry.
* Fixed not using the extra CMake arguments from `./Config`.
* Fixed some help messages that did not reflect the default flag/level/xop access when changed in the configuration.
* Fixed the default memory hardness in the `enc_argon2` module.
* Improved configuring paths at build time.
* Improved importing databases from Atheme.
* Improved support for reproducible builds.
* Separated the delay between nickname registrations from the delay between grouping nicknames.
* Updated the Portuguese translation.
* Updated the Romanian translation.
### Developer Changes
* Added `Block::GetBlocks` to allow using a range-based for loop to iterate config blocks.
* Added an event to `IRCDProto` to populate common tags onto a S2S message.
* Added automated testing on InspIRCd, Solanum, and UnrealIRCd using irctest.
* Added support for adding ajoin entries from modules.
* Changed various configuration block index fields to use an unsigned integer.
* Changed vendored libraries to be built as static libraries and linked into the modules that require them.
* Simplified timer repeat logic by allowing tick events to return bool to control whether the timer continues running.
## Anope 2.1.24 (2026-04-01)
### Breaking Changes
* If a database contains duplicate corrupt entries from a prior write failure the oldest ones will now be purged from the database. This is a destructive action so make sure you take a manual backup of your database before upgrading.
* Removed support for storing the Anope database in Redis. The Redis code was extremely bitrotted, had not been tested in years, and to our knowledge has almost no (if any) users. It is recommended that db_redis users migrate to db_json or db_sql.
* SQL tables now use versioned prefixes by default. For the SQL database backends the default is `anope21_` and for ChanStats the default is `chanstats21_`. If you do not have a prefix explicitly set in your config you will need to add one it. Alternatively, you may also want to consider exporting to db_json and re-importing to update your SQL schema for the recent database layout changes.
### Changes
* Added some helper methods to `CommandSource` to allow quickly translting messages.
* Changed the Config script to allow multiple dashes in front of options, i.e. `-quick` and `--quick` are now equivalent.
* Converted some language strings to use format strings instead of concatenation.
* Fixed a rare crash in the ns_cert module.
* Fixed building Anope as a unity build.
* Fixed the ns_cert module erasing certificate entries if using an old database.
* Fixed users having the wrong real name in log messages on InspIRCd if it has been previously changed with `CHGNAME` or `SETNAME`.
## Anope 2.1.23 (2026-04-01) ## Anope 2.1.23 (2026-04-01)
### Changes ### Changes
+1 -2
View File
@@ -32,8 +32,7 @@ Anope Multi Language Support
but 0x1B is special to Anope and is used to prevent the automatic linewrapper from breaking messages in the middle of but 0x1B is special to Anope and is used to prevent the automatic linewrapper from breaking messages in the middle of
text that should not be split (e.g. commands). Your editor may not show these so be careful you don't delete them! text that should not be split (e.g. commands). Your editor may not show these so be careful you don't delete them!
If you have finished a language file translation and you want others to use it, please file a pull request on GitHub If you have finished a language file translation and you want others to use it, please file a pull request on GitHub.
or send it to team@anope.org (don't forget to mention clearly your (nick)name, your email and the language name).
You'll of course get full credit for it. You'll of course get full credit for it.
3) Using languages with modules 3) Using languages with modules
-160
View File
@@ -1,160 +0,0 @@
Anope has Redis database support (https://redis.io/).
This document explains the data structure used by Anope, and explains how
keyspace notification works.
This is not a tutorial on how to use Redis, see https://redis.io/documentation
for that.
Table of Contents
-----------------
1) Data structure
2) Keyspace notifications
3) Examples of modifying, deleting, and creating objects
1) Data structure
There are 4 key namespaces in Anope, they are:
id - The keys in id are used to atomically create object ids for new
objects. For example, if I were to create a new BotInfo I would first:
redis 127.0.0.1:6379> INCR id:BotInfo
To get the object ID of the new object.
ids - The keys in ids contain a set of all object ids of the given type.
For example:
redis 127.0.0.1:6379> SMEMBERS ids:BotInfo
Returns "1", "2", "3", "4", "5", "6", "7", "8" because I have 8 bots that
have IDs 1, 2, 3, 4, 5, 6, 7, and 8, respectively.
hash - The keys in hash are the actual objects, stored as hashes. For
example, if I had just looked up all BotInfo ids and wanted to iterate
over all of them, I would start by:
redis 127.0.0.1:6379> HGETALL hash:BotInfo:1
Which gets all keys and values from the hash of type BotInfo with id 1.
This may return:
"nick" -> "BotServ"
"user" -> "services"
"host" -> "services.anope.org"
"created" -> "1368704765"
value - The keys in value only exist to aid looking up object IDs. They
are sets of object IDs and are used to map key+value pairs to objects.
For example:
redis 127.0.0.1:6379> SMEMBERS value:NickAlias:nick:Adam
Returns a set of object ids of NickAlias objects that have the key
'nick' set to the value 'Adam' in its hash. Clearly this can only
ever contain at most one object, since it is not possible to have
more than one registered nick with the same name, but other keys
will contain more than one, such as:
redis 127.0.0.1:6379> SMEMBERS value:NickCore:email:adam@anope.org
Which would return all accounts with the email "adam@anope.org".
redis 127.0.0.1:6379> SMEMBERS value:ChanAccess:mask:Adam
Which would return all access entries set on the account "Adam".
Behavior similar to SQL's AND, can be achieved using the
SINTER command, which does set intersection on one or more sets.
2) Keyspace notifications
Redis 2.7 (unstable) and 2.8 (stable) and newer support keyspace notifications
(https://redis.io/topics/notifications). This allows Redis to notify Anope of
any external changes to objects in the database. Once notified, Anope will
immediately update the object. Otherwise, Anope keeps all objects in memory
and will not regularly read from the database once started.
You can use this to modify objects in Redis and have them immediately reflected
back into Anope. Additionally you can use this feature to run multiple Anope
instances simultaneously from the same database (see also, Redis database
replication).
To use keyspace notifications you MUST execute
redis 127.0.0.1:6379> CONFIG SET notify-keyspace-events KA
OK
or set notify-keyspace-events in redis.conf properly. Anope always executes
CONFIG SET when it first connects.
If you do not enable keyspace events properly Anope will be UNABLE to see any
object modifications you do.
The key space ids and value are managed entirely by Anope, you do
not (and should not) modify them. Once you modify the object (hash), Anope will
update them for you to correctly reflect any changes made to the object.
Finally, always use atomic operations. If you are inserting a new object with
multiple commands, or inserting multiple objects at once, specifically if the
objects depend on each other, you MUST use a transaction.
3) Examples of modifying, deleting, and creating objects
These examples will ONLY work if you meet the criteria in section 2.
If I want to change the email account 'Adam' to 'Adam@anope.org', I would execute the following:
redis 127.0.0.1:6379> SMEMBERS value:NickCore:display:Adam
Which returns a value of "1", which is the object id I want to modify.
Now to change the email:
redis 127.0.0.1:6379> HSET hash:NickCore:1 email Adam@anope.org
You can now see this in NickServ's INFO command:
-NickServ- Email address: Adam@anope.org
If I want to drop the account "Adam", I would execute the following:
redis 127.0.0.1:6379> SMEMBERS value:NickCore:display:Adam
Which returns a value of "1". I would then check:
redis 127.0.0.1:6379> SMEMBERS value:NickAlias:nc:Adam
To see what nicknames depend on this account to exist, as I will
have to remove those too. This returns the values "2", and "3".
Finally, I can drop the nick using a transaction via:
redis 127.0.0.1:6379> MULTI
OK
redis 127.0.0.1:6379> DEL hash:NickAlias:2
QUEUED
redis 127.0.0.1:6379> DEL hash:NickAlias:3
QUEUED
redis 127.0.0.1:6379> DEL hash:NickCore:1
QUEUED
redis 127.0.0.1:6379> EXEC
Or alternatively simply:
redis 127.0.0.1:6379> DEL hash:NickAlias:2 hash:NickAlias:3 hash:NickCore:1
If I wanted to create a BotServ bot, I would execute the following:
redis 127.0.0.1:6379> INCR id:BotInfo
Which returns a new object ID for me, in this example it will be "8".
Now I can create the object:
HMSET hash:BotInfo:8 nick redis user redis host services.anope.org realname "Anope IRC Services"
Note if you are using HSET instead of HMSET you will need to use a transaction, as shown in the above example.
If you are watching your services logs you will immediately see:
USERS: redis!redis@services.anope.org (Anope IRC Services) connected to the network (services.anope.org)
And the bot redis will be in BotServ's bot list.
Notice how ids:BotInfo and the value keys are updated automatically.
+3
View File
@@ -67,6 +67,9 @@ public:
*/ */
virtual ChanAccess *Create() = 0; virtual ChanAccess *Create() = 0;
virtual void GetAccess(CommandSource& source, const Privilege *p, Anope::map<Anope::string> &access) = 0;
static void SendAccess(CommandSource &source, const Anope::string &pname);
private: private:
static std::list<AccessProvider *> Providers; static std::list<AccessProvider *> Providers;
public: public:
-4
View File
@@ -362,10 +362,6 @@ namespace Anope
template<typename T> template<typename T>
using unordered_map = std::unordered_map<string, T, hash_ci, compare>; using unordered_map = std::unordered_map<string, T, hash_ci, compare>;
#if !REPRODUCIBLE_BUILD
static const char *const compiled = __TIME__ " " __DATE__;
#endif
/** The time Anope started. /** The time Anope started.
*/ */
extern CoreExport time_t StartTime; extern CoreExport time_t StartTime;
+5
View File
@@ -90,6 +90,11 @@ public:
void Reply(int count, const char *singular, const char *plural, ...) ATTR_FORMAT(4, 5); void Reply(int count, const char *singular, const char *plural, ...) ATTR_FORMAT(4, 5);
void Reply(const Anope::string &message); void Reply(const Anope::string &message);
const char *Translate(const char *message);
const char *Translate(const Anope::string &message);
const char *Translate(int count, const char *single, const char *plural);
const char *Translate(int count, const Anope::string &single, const Anope::string &plural);
bool HasCommand(const Anope::string &cmd); bool HasCommand(const Anope::string &cmd);
bool HasPriv(const Anope::string &cmd); bool HasPriv(const Anope::string &cmd);
bool IsServicesOper(); bool IsServicesOper();
+13 -10
View File
@@ -18,6 +18,7 @@
#include "regchannel.h" #include "regchannel.h"
#include "users.h" #include "users.h"
#include "opertype.h" #include "opertype.h"
#include "miscutils.h"
namespace Configuration namespace Configuration
{ {
@@ -26,14 +27,15 @@ namespace Configuration
friend class Configuration::Conf; friend class Configuration::Conf;
public: public:
typedef Anope::map<Anope::string> item_map; typedef Anope::map<Anope::string> ItemMap;
typedef Anope::multimap<Block> block_map; typedef Anope::multimap<Block> BlockMap;
typedef Anope::iterator_range<BlockMap::const_iterator> BlockList;
private: private:
Anope::string name; Anope::string name;
item_map items; ItemMap items;
block_map blocks; BlockMap blocks;
int linenum; unsigned linenum;
/* Represents a missing tag. */ /* Represents a missing tag. */
static Block EmptyBlock; static Block EmptyBlock;
@@ -41,9 +43,10 @@ namespace Configuration
public: public:
Block(const Anope::string &); Block(const Anope::string &);
const Anope::string &GetName() const; const Anope::string &GetName() const;
int CountBlock(const Anope::string &name) const; size_t CountBlock(const Anope::string &name) const;
const Block &GetBlock(const Anope::string &name, int num = 0) const; BlockList GetBlocks(const Anope::string &name) const;
Block *GetMutableBlock(const Anope::string &name, int num = 0); const Block &GetBlock(const Anope::string &name, size_t num = 0) const;
Block *GetMutableBlock(const Anope::string &name, size_t num = 0);
template<typename T> T Get(const Anope::string &tag, const Anope::string &def = "") const template<typename T> T Get(const Anope::string &tag, const Anope::string &def = "") const
{ {
@@ -51,7 +54,7 @@ namespace Configuration
} }
bool Set(const Anope::string &tag, const Anope::string &value); bool Set(const Anope::string &tag, const Anope::string &value);
const item_map &GetItems() const; const ItemMap &GetItems() const;
}; };
template<> CoreExport const Anope::string Block::Get(const Anope::string &tag, const Anope::string &def) const; template<> CoreExport const Anope::string Block::Get(const Anope::string &tag, const Anope::string &def) const;
@@ -85,7 +88,7 @@ namespace Configuration
{ {
private: private:
/** Replaces defined variables within a string. */ /** Replaces defined variables within a string. */
Anope::string ReplaceVars(const Anope::string &str, const File &file, int linenumber); Anope::string ReplaceVars(const Anope::string &str, const File &file, unsigned linenumber);
public: public:
/* options:readtimeout */ /* options:readtimeout */
-4
View File
@@ -142,10 +142,6 @@ namespace Language
#define CHAN_ACCESS_LEVEL_RANGE _("Access level must be between %d and %d inclusive.") #define CHAN_ACCESS_LEVEL_RANGE _("Access level must be between %d and %d inclusive.")
#define CHAN_ACCESS_MALFORMED _("You cannot add a malformed mask to an access list. Did you mean to add %s instead?") #define CHAN_ACCESS_MALFORMED _("You cannot add a malformed mask to an access list. Did you mean to add %s instead?")
#define CHAN_ACCESS_FOREIGN N_("%u access entry from other access systems not shown; use \002%s\033ALL\002 to view all access entries.", "%u access entries from other access systems not shown; use \002%s\033ALL\002 to view all access entries.") #define CHAN_ACCESS_FOREIGN N_("%u access entry from other access systems not shown; use \002%s\033ALL\002 to view all access entries.", "%u access entries from other access systems not shown; use \002%s\033ALL\002 to view all access entries.")
#define CHAN_ACCESS_MIGRATED_1 _("\002%s\002 has been migrated to the %s access system.")
#define CHAN_ACCESS_MIGRATED_N N_("\002%u\002 entry has been migrated to the %s access system.", "\002%u\002 entries have been migrated to the %s access system.")
#define CHAN_ACCESS_NOT_MIGRATED_1 _("\002%s\002 can not be migrated to the %s access system because they have privileges that you do not.")
#define CHAN_ACCESS_NOT_MIGRATED_N N_("\002%u\002 entry can not be migrated to the %s access system because they have privileges that you do not.", "\002%u\002 entries can not be migrated to the %s access system because they have privileges that you do not.")
#define CHAN_EXCEPTED _("\002%s\002 matches an except on %s and cannot be banned until the except has been removed.") #define CHAN_EXCEPTED _("\002%s\002 matches an except on %s and cannot be banned until the except has been removed.")
#define CHAN_INFO_HEADER _("Information about channel \002%s\002:") #define CHAN_INFO_HEADER _("Information about channel \002%s\002:")
#define CHAN_LIMIT_EXCEEDED _("You have already exceeded your limit of \002%d\002 channels.") #define CHAN_LIMIT_EXCEEDED _("You have already exceeded your limit of \002%d\002 channels.")
+87
View File
@@ -0,0 +1,87 @@
// Anope IRC Services <https://www.anope.org/>
//
// Copyright (C) 2003-2026 Anope Contributors
//
// Anope is free software. You can use, modify, and/or distribute it under the
// terms of version 2 of the GNU General Public License. See docs/LICENSE.txt
// for the complete terms of this license and docs/AUTHORS.txt for a list of
// contributors.
//
// Based on the original code of Epona by Lara
// Based on the original code of Services by Andy Church
//
// SPDX-License-Identifier: GPL-2.0-only
#pragma once
#include <iterator>
#include <utility>
namespace Anope
{
template <typename Iterator>
class iterator_range;
/** Returns a range containing all elements equivalent to \p value.
* @param collection The collection to search within.
* @param value The value to search for.
*/
template <typename Collection, typename Value>
auto equal_range(const Collection& collection, const Value& value)
{
return iterator_range(collection.equal_range(value));
}
/** Returns a range representing a reverse iterator for the specified colleciton.
* @param collection The collection to create a reverse iterator for.
*/
template <typename Collection>
auto reverse_range(const Collection& collection)
{
return iterator_range(collection.rbegin(), collection.rend());
}
}
/** Represents a range of iterators. */
template <typename Iterator>
class Anope::iterator_range final
{
private:
/** An iterator which points to the start of the range. */
const Iterator begini;
/* An iterator which points to one past the end of the range. */
const Iterator endi;
public:
/** Initialises a new iterator range with the specified iterators.
* @param begin An iterator which points to the start of the range.
* @param end An iterator which points to one past the end of the range.
*/
explicit iterator_range(Iterator begin, Iterator end)
: begini(begin)
, endi(end)
{
}
/** Initialises a new iterator range from a pair of iterators.
* @param range A pair of iterators in the format [first, last).
*/
explicit iterator_range(std::pair<Iterator, Iterator> range)
: begini(range.first)
, endi(range.second)
{
}
/** Determines whether the iterator range is empty. */
bool empty() const { return begini == endi; }
/** Retrieves an iterator which points to the start of the range. */
const Iterator& begin() const { return begini; }
/** Retrieves an iterator which points to one past the end of the range. */
const Iterator& end() const { return endi; }
/** Retrieves the number of hops within the iterator range. */
typename std::iterator_traits<Iterator>::difference_type count() const { return std::distance(begini, endi); }
};
+2 -1
View File
@@ -194,12 +194,13 @@ namespace DNS
/** Used to time out the query, xalls OnError and lets the TimerManager /** Used to time out the query, xalls OnError and lets the TimerManager
* delete this request. * delete this request.
*/ */
void Tick() override bool Tick() override
{ {
Log(LOG_DEBUG_2) << "Resolver: timeout for query " << this->name; Log(LOG_DEBUG_2) << "Resolver: timeout for query " << this->name;
Query rr(*this); Query rr(*this);
rr.error = ERROR_TIMEDOUT; rr.error = ERROR_TIMEDOUT;
this->OnError(&rr); this->OnError(&rr);
return false;
} }
}; };
+10
View File
@@ -173,4 +173,14 @@ public:
* @param attributes The attributes to modify * @param attributes The attributes to modify
*/ */
virtual void Modify(LDAPInterface *i, const Anope::string &base, LDAPMods &attributes) = 0; virtual void Modify(LDAPInterface *i, const Anope::string &base, LDAPMods &attributes) = 0;
/** Escapes a LDAP string for use in a DN.
* @param str The string to escape.
*/
virtual Anope::string EscapeDN(const Anope::string &str) const = 0;
/** Escapes a LDAP string for use in a search filter.
* @param str The string to escape.
*/
virtual Anope::string EscapeSF(const Anope::string &str) const = 0;
}; };
+47
View File
@@ -0,0 +1,47 @@
// Anope IRC Services <https://www.anope.org/>
//
// Copyright (C) 2003-2026 Anope Contributors
//
// Anope is free software. You can use, modify, and/or distribute it under the
// terms of version 2 of the GNU General Public License. See docs/LICENSE.txt
// for the complete terms of this license and docs/AUTHORS.txt for a list of
// contributors.
//
// Based on the original code of Epona by Lara
// Based on the original code of Services by Andy Church
//
// SPDX-License-Identifier: GPL-2.0-only
#pragma once
#define NICKSERV_AJOIN_LIST_EXT "ajoinlist"
struct AJoinEntry;
struct AJoinList
: Serialize::Checker<std::vector<AJoinEntry *> >
{
AJoinList(Extensible *) : Serialize::Checker<std::vector<AJoinEntry *> >("AJoinEntry") { }
virtual ~AJoinList() = default;
};
struct AJoinEntry final
: Serializable
{
Serialize::Reference<NickCore> owner;
Anope::string channel;
Anope::string key;
AJoinEntry(Extensible *) : Serializable("AJoinEntry") { }
~AJoinEntry() override
{
auto *channels = owner->GetExt<AJoinList>(NICKSERV_AJOIN_LIST_EXT);
if (channels)
{
auto it = std::find((*channels)->begin(), (*channels)->end(), this);
if (it != (*channels)->end())
(*channels)->erase(it);
}
}
};
-83
View File
@@ -1,83 +0,0 @@
// Anope IRC Services <https://www.anope.org/>
//
// Copyright (C) 2003-2026 Anope Contributors
//
// Anope is free software. You can use, modify, and/or distribute it under the
// terms of version 2 of the GNU General Public License. See docs/LICENSE.txt
// for the complete terms of this license and docs/AUTHORS.txt for a list of
// contributors.
//
// Based on the original code of Epona by Lara
// Based on the original code of Services by Andy Church
//
// SPDX-License-Identifier: GPL-2.0-only
#pragma once
namespace Redis
{
struct Reply final
{
enum Type
{
NOT_PARSED,
NOT_OK,
OK,
INT,
BULK,
MULTI_BULK
}
type;
Reply() { Clear(); }
~Reply() { Clear(); }
void Clear()
{
type = NOT_PARSED;
i = 0;
bulk.clear();
multi_bulk_size = 0;
for (const auto *reply : multi_bulk)
delete reply;
multi_bulk.clear();
}
int64_t i;
Anope::string bulk;
int multi_bulk_size;
std::deque<Reply *> multi_bulk;
};
class Interface
{
public:
Module *owner;
Interface(Module *m) : owner(m) { }
virtual ~Interface() = default;
virtual void OnResult(const Reply &r) = 0;
virtual void OnError(const Anope::string &error) { Log(owner) << error; }
};
class Provider
: public Service
{
public:
Provider(Module *c, const Anope::string &n) : Service(c, "Redis::Provider", n) { }
virtual bool IsSocketDead() = 0;
virtual void SendCommand(Interface *i, const std::vector<Anope::string> &cmds) = 0;
virtual void SendCommand(Interface *i, const Anope::string &str) = 0;
virtual bool BlockAndProcess() = 0;
virtual void Subscribe(Interface *i, const Anope::string &pattern) = 0;
virtual void Unsubscribe(const Anope::string &pattern) = 0;
virtual void StartTransaction() = 0;
virtual void CommitTransaction() = 0;
};
}
+9 -1
View File
@@ -58,6 +58,14 @@ public:
*/ */
virtual bool Parse(const Anope::string &message, Anope::map<Anope::string> &tags, Anope::string &source, Anope::string &command, std::vector<Anope::string> &params); virtual bool Parse(const Anope::string &message, Anope::map<Anope::string> &tags, Anope::string &source, Anope::string &command, std::vector<Anope::string> &params);
/* Populates the tags that should be sent on all messages.
* @param tags The location to store tags.
* @param source Source of the message.
* @param command Command name.
* @param params Any extra parameters.
*/
virtual void PopulateTags(Anope::map<Anope::string> &tags, const MessageSource &source, const Anope::string &command, const std::vector<Anope::string> &params);
/* Formats an outgoing message so it can be sent to the IRC server. /* Formats an outgoing message so it can be sent to the IRC server.
* @param message The location to store the formatted message. * @param message The location to store the formatted message.
* @param tags IRCv3 message tags. * @param tags IRCv3 message tags.
@@ -279,7 +287,7 @@ public:
virtual void SendSVSHold(const Anope::string &, time_t) { } virtual void SendSVSHold(const Anope::string &, time_t) { }
virtual void SendSVSHoldDel(const Anope::string &) { } virtual void SendSVSHoldDel(const Anope::string &) { }
virtual void SendSWhois(const MessageSource &source, User *target, const Anope::string &tag, const Anope::string &message) { }; virtual void SendSWhois(const MessageSource &source, User *target, const Anope::string &tag, time_t priority, const Anope::string &message) { };
virtual void SendSWhoisDel(const MessageSource &source, User *target, const Anope::string &tag, const Anope::string &message) { } virtual void SendSWhoisDel(const MessageSource &source, User *target, const Anope::string &tag, const Anope::string &message) { }
/** Introduces a server to the uplink /** Introduces a server to the uplink
+20 -3
View File
@@ -74,6 +74,8 @@ private:
size_t last_commit = 0; size_t last_commit = 0;
/* The last time this object was committed to the database */ /* The last time this object was committed to the database */
time_t last_commit_time = 0; time_t last_commit_time = 0;
/** Whether this object should be committed to the database. */
bool should_commit = true;
protected: protected:
Serializable(const Anope::string &serialize_type); Serializable(const Anope::string &serialize_type);
@@ -81,6 +83,20 @@ protected:
Serializable &operator=(const Serializable &); Serializable &operator=(const Serializable &);
template<typename Container,
typename Key = typename Container::key_type,
typename Value = typename Container::mapped_type>
bool InsertUnique(Container &container, const Key &key)
{
auto res = container.emplace(key, static_cast<Value>(this));
if (res.second)
return true;
res.first->second->should_commit = false;
res.first->second = static_cast<Value>(this);
return false;
}
public: public:
using Id = uint64_t; using Id = uint64_t;
virtual ~Serializable(); virtual ~Serializable();
@@ -88,13 +104,13 @@ public:
/* Unique ID (per type, not globally) for this object */ /* Unique ID (per type, not globally) for this object */
Id object_id = 0; Id object_id = 0;
/* Only used by redis, to ignore updates */
unsigned short redis_ignore = 0;
/** Marks the object as potentially being updated "soon". /** Marks the object as potentially being updated "soon".
*/ */
void QueueUpdate(); void QueueUpdate();
/** Determines whether the object should be committed to the database. */
bool ShouldCommit() const { return this->should_commit; }
bool IsCached(Serialize::Data &); bool IsCached(Serialize::Data &);
void UpdateCache(Serialize::Data &); void UpdateCache(Serialize::Data &);
@@ -105,6 +121,7 @@ public:
* @return The serializable object type * @return The serializable object type
*/ */
Serialize::Type *GetSerializableType() const { return this->s_type; } Serialize::Type *GetSerializableType() const { return this->s_type; }
const auto &GetSerializableName() const { return this->s_name; }
static const std::list<Serializable *> &GetItems(); static const std::list<Serializable *> &GetItems();
}; };
+6
View File
@@ -79,6 +79,12 @@ namespace Anope
*/ */
extern CoreExport Anope::string FormatCTCP(const Anope::string &name, const Anope::string &body = ""); extern CoreExport Anope::string FormatCTCP(const Anope::string &name, const Anope::string &body = "");
/** Formats a date/time as an IS0 8601 timestamp.
* @param ts UNIX timestamp to format.
* @param ms Number of milliseconds to format.
*/
extern CoreExport Anope::string FormatISO8601(time_t ts, unsigned long long ms);
/** Parses a CTCP message received from a client. /** Parses a CTCP message received from a client.
* @param text The raw message to parse. * @param text The raw message to parse.
* @param name The location to store the name of the CTCP. * @param name The location to store the name of the CTCP.
+3 -14
View File
@@ -31,23 +31,17 @@ private:
*/ */
time_t secs; time_t secs;
/** True if this is a repeating timer
*/
bool repeat;
public: public:
/** Constructor, initializes the triggering time /** Constructor, initializes the triggering time
* @param time_from_now The number of seconds from now to trigger the timer * @param time_from_now The number of seconds from now to trigger the timer
* @param repeating Repeat this timer every time_from_now if this is true
*/ */
Timer(time_t time_from_now, bool repeating = false); Timer(time_t time_from_now);
/** Constructor, initializes the triggering time /** Constructor, initializes the triggering time
* @param creator The creator of the timer * @param creator The creator of the timer
* @param time_from_now The number of seconds from now to trigger the timer * @param time_from_now The number of seconds from now to trigger the timer
* @param repeating Repeat this timer every time_from_now if this is true
*/ */
Timer(Module *creator, time_t time_from_now, bool repeating = false); Timer(Module *creator, time_t time_from_now);
/** Destructor, removes the timer from the list /** Destructor, removes the timer from the list
*/ */
@@ -63,11 +57,6 @@ public:
*/ */
time_t GetTimer() const; time_t GetTimer() const;
/** Returns true if the timer is set to repeat
* @return Returns true if the timer is set to repeat
*/
bool GetRepeat() const;
/** Set the interval between ticks /** Set the interval between ticks
* @paramt t The new interval * @paramt t The new interval
*/ */
@@ -86,7 +75,7 @@ public:
/** Called when the timer ticks /** Called when the timer ticks
* This should be overridden with something useful * This should be overridden with something useful
*/ */
virtual void Tick() = 0; virtual bool Tick() = 0;
}; };
/** This class manages sets of Timers, and triggers them at their defined times. /** This class manages sets of Timers, and triggers them at their defined times.
+17 -2
View File
@@ -18,6 +18,8 @@
#include <sstream> #include <sstream>
#include <map> #include <map>
#include "sysconf.h"
static std::string get_git_hash(const std::string &git_dir) static std::string get_git_hash(const std::string &git_dir)
{ {
std::fstream fd; std::fstream fd;
@@ -78,14 +80,18 @@ static bool read_version_sh(const std::string &version_sh, std::map<std::string,
static bool write_build_h(const std::string &buildh, const std::string &git_version) static bool write_build_h(const std::string &buildh, const std::string &git_version)
{ {
std::fstream fd(buildh.c_str(), std::ios::in); std::fstream fd;
std::string build = "#define BUILD 1"; std::string build = "#define BUILD 1";
#if !REPRODUCIBLE_BUILD
fd.open(buildh.c_str(), std::ios::in);
if (fd.is_open()) if (fd.is_open())
{ {
for (std::string filebuf; getline(fd, filebuf);) for (std::string filebuf; getline(fd, filebuf);)
{ {
if (!filebuf.find("#define BUILD")) if (!filebuf.find("#define BUILD\t"))
{ {
size_t tab = filebuf.find(' '); size_t tab = filebuf.find(' ');
@@ -101,6 +107,8 @@ static bool write_build_h(const std::string &buildh, const std::string &git_vers
} }
fd.clear(); fd.clear();
#endif
fd.open(buildh.c_str(), std::ios::out); fd.open(buildh.c_str(), std::ios::out);
if (!fd.is_open()) if (!fd.is_open())
{ {
@@ -111,6 +119,13 @@ static bool write_build_h(const std::string &buildh, const std::string &git_vers
fd << "/* This file is automatically generated by version.cpp - do not edit it! */" << std::endl fd << "/* This file is automatically generated by version.cpp - do not edit it! */" << std::endl
<< "#pragma once" << std::endl << "#pragma once" << std::endl
<< build << std::endl; << build << std::endl;
#if !REPRODUCIBLE_BUILD
auto time_now = time(NULL);
auto *local_tm = localtime(&time_now);
char buffer[100];
strftime(buffer, sizeof(buffer), "%a %b %e %Y %T %Z", local_tm);
fd << "#define BUILD_DATE \"" << buffer << "\"" << std::endl;
#endif
if (!git_version.empty()) if (!git_version.empty())
fd << "#define VERSION_GIT \"" << git_version << "\"" << std::endl; fd << "#define VERSION_GIT \"" << git_version << "\"" << std::endl;
fd.close(); fd.close();
+378 -344
View File
File diff suppressed because it is too large Load Diff
+2001 -13
View File
File diff suppressed because it is too large Load Diff
+2000 -12
View File
File diff suppressed because it is too large Load Diff
+2 -3
View File
@@ -21,10 +21,9 @@ find ../ \
-o -name '*.h' \ -o -name '*.h' \
-o -name '*.conf' \ -o -name '*.conf' \
\) \ \) \
-exec \ -print0 | sort -z | xargs -0 -I {} \
xgettext \ xgettext \
--language=C++ \ --language=C++ \
--sort-output \
--default-domain=Anope \ --default-domain=Anope \
--join-existing \ --join-existing \
--output=anope.pot \ --output=anope.pot \
@@ -32,7 +31,7 @@ find ../ \
--keyword \ --keyword \
--keyword=_ \ --keyword=_ \
--keyword=N_:1,2 \ --keyword=N_:1,2 \
{} + {}
for f in *.po for f in *.po
do do
+7 -1
View File
@@ -50,7 +50,7 @@ macro(inline_cmake TARGET FILE)
set(CODE "${CODE}\n${CLEAN_LINE}") set(CODE "${CODE}\n${CLEAN_LINE}")
endif() endif()
elseif(LINE MATCHES "^/// BEGIN CMAKE$") elseif(LINE MATCHES "^/// BEGIN CMAKE$")
message(STATUS "Executing inline CMake code for ${TARGET}") message(DEBUG "Executing inline CMake code for ${TARGET}")
set(IN_CODE ON) set(IN_CODE ON)
endif() endif()
endforeach() endforeach()
@@ -77,6 +77,12 @@ macro(build_module SRC MODULE_SRC)
PREFIX "" PREFIX ""
SUFFIX "" SUFFIX ""
) )
list(LENGTH MODULE_SRC MODULE_SRC_COUNT)
if(MODULE_SRC_COUNT LESS_EQUAL 1)
set_target_properties(${SO} PROPERTIES
UNITY_BUILD OFF
)
endif()
add_dependencies(${SO} ${PROGRAM_NAME}) add_dependencies(${SO} ${PROGRAM_NAME})
if(HAVE_LOCALIZATION) if(HAVE_LOCALIZATION)
add_dependencies(${SO} module_language) add_dependencies(${SO} module_language)
+2 -2
View File
@@ -20,7 +20,7 @@ class CommandBSAssign final
public: public:
CommandBSAssign(Module *creator) : Command(creator, "botserv/assign", 2, 2) CommandBSAssign(Module *creator) : Command(creator, "botserv/assign", 2, 2)
{ {
this->SetDesc(_("Assigns a bot to a channel")); this->SetDesc(_("Assign a bot to a channel"));
this->SetSyntax(_("\037channel\037 \037nick\037")); this->SetSyntax(_("\037channel\037 \037nick\037"));
} }
@@ -101,7 +101,7 @@ class CommandBSUnassign final
public: public:
CommandBSUnassign(Module *creator) : Command(creator, "botserv/unassign", 1, 1) CommandBSUnassign(Module *creator) : Command(creator, "botserv/unassign", 1, 1)
{ {
this->SetDesc(_("Unassigns a bot from a channel")); this->SetDesc(_("Unassign a bot from a channel"));
this->SetSyntax(_("\037channel\037")); this->SetSyntax(_("\037channel\037"));
} }
+1 -1
View File
@@ -416,7 +416,7 @@ private:
public: public:
CommandBSBadwords(Module *creator) : Command(creator, "botserv/badwords", 2, 3) CommandBSBadwords(Module *creator) : Command(creator, "botserv/badwords", 2, 3)
{ {
this->SetDesc(_("Maintains the bad words list")); this->SetDesc(_("Maintain the bad words list"));
this->SetSyntax(_("\037channel\037 ADD \037word\037 [\037SINGLE\037 | \037START\037 | \037END\037]")); this->SetSyntax(_("\037channel\037 ADD \037word\037 [\037SINGLE\037 | \037START\037 | \037END\037]"));
this->SetSyntax(_("\037channel\037 DEL {\037word\037 | \037entry-num\037 | \037list\037}")); this->SetSyntax(_("\037channel\037 DEL {\037word\037 | \037entry-num\037 | \037list\037}"));
this->SetSyntax(_("\037channel\037 LIST [\037mask\037 | \037list\037]")); this->SetSyntax(_("\037channel\037 LIST [\037mask\037 | \037list\037]"));
+1 -1
View File
@@ -264,7 +264,7 @@ private:
public: public:
CommandBSBot(Module *creator) : Command(creator, "botserv/bot", 1, 6) CommandBSBot(Module *creator) : Command(creator, "botserv/bot", 1, 6)
{ {
this->SetDesc(_("Maintains network bot list")); this->SetDesc(_("Maintain network bot list"));
this->SetSyntax(_("\002ADD \037nick\037 \037user\037 \037host\037 \037real\037\002")); this->SetSyntax(_("\002ADD \037nick\037 \037user\037 \037host\037 \037real\037\002"));
this->SetSyntax(_("\002CHANGE \037oldnick\037 \037newnick\037 [\037user\037 [\037host\037 [\037real\037]]]\002")); this->SetSyntax(_("\002CHANGE \037oldnick\037 \037newnick\037 [\037user\037 [\037host\037 [\037real\037]]]\002"));
this->SetSyntax(_("\002DEL \037nick\037\002")); this->SetSyntax(_("\002DEL \037nick\037\002"));
+1 -1
View File
@@ -20,7 +20,7 @@ class CommandBSBotList final
public: public:
CommandBSBotList(Module *creator) : Command(creator, "botserv/botlist", 0, 1) CommandBSBotList(Module *creator) : Command(creator, "botserv/botlist", 0, 1)
{ {
this->SetDesc(_("Lists available bots")); this->SetDesc(_("List available bots"));
this->SetSyntax("[OPERONLY] [UNUSED] [VANITY]"); this->SetSyntax("[OPERONLY] [UNUSED] [VANITY]");
} }
+2 -2
View File
@@ -20,7 +20,7 @@ class CommandBSSay final
public: public:
CommandBSSay(Module *creator) : Command(creator, "botserv/say", 2, 2) CommandBSSay(Module *creator) : Command(creator, "botserv/say", 2, 2)
{ {
this->SetDesc(_("Makes the bot say the specified text on the specified channel")); this->SetDesc(_("Make the bot say the specified text on the specified channel"));
this->SetSyntax(_("\037channel\037 \037text\037")); this->SetSyntax(_("\037channel\037 \037text\037"));
} }
@@ -88,7 +88,7 @@ class CommandBSAct final
public: public:
CommandBSAct(Module *creator) : Command(creator, "botserv/act", 2, 2) CommandBSAct(Module *creator) : Command(creator, "botserv/act", 2, 2)
{ {
this->SetDesc(_("Makes the bot do the equivalent of a \"/me\" command")); this->SetDesc(_("Make the bot do the equivalent of a \"/me\" command"));
this->SetSyntax(_("\037channel\037 \037text\037")); this->SetSyntax(_("\037channel\037 \037text\037"));
} }
+4 -4
View File
@@ -58,7 +58,7 @@ public:
info[_("Real name")] = bi->realname; info[_("Real name")] = bi->realname;
info[_("Created")] = Anope::strftime(bi->created, source.GetAccount()); info[_("Created")] = Anope::strftime(bi->created, source.GetAccount());
info[_("Options")] = bi->oper_only ? _("Private") : _("None"); info[_("Options")] = bi->oper_only ? _("Private") : _("None");
info[_("Used on")] = Anope::Format(Language::Translate(source.nc, bi->GetChannelCount(), N_("%u channel", "%u channels")), bi->GetChannelCount()); info[_("Used on")] = Anope::Format(source.Translate(bi->GetChannelCount(), N_("%u channel", "%u channels")), bi->GetChannelCount());
FOREACH_MOD(OnBotInfo, (source, bi, ci, info)); FOREACH_MOD(OnBotInfo, (source, bi, ci, info));
info.SendTo(source); info.SendTo(source);
@@ -83,8 +83,8 @@ public:
source.Reply(CHAN_INFO_HEADER, ci->name.c_str()); source.Reply(CHAN_INFO_HEADER, ci->name.c_str());
info[_("Bot nick")] = ci->bi ? ci->bi->nick : _("not assigned yet"); info[_("Bot nick")] = ci->bi ? ci->bi->nick : _("not assigned yet");
Anope::string enabled = Language::Translate(source.nc, _("Enabled")); Anope::string enabled = source.Translate(_("Enabled"));
Anope::string disabled = Language::Translate(source.nc, _("Disabled")); Anope::string disabled = source.Translate(_("Disabled"));
FOREACH_MOD(OnBotInfo, (source, bi, ci, info)); FOREACH_MOD(OnBotInfo, (source, bi, ci, info));
info.SendTo(source); info.SendTo(source);
@@ -120,7 +120,7 @@ public:
Anope::string GetDesc(CommandSource &source) const override Anope::string GetDesc(CommandSource &source) const override
{ {
return Anope::Format(Language::Translate(source.GetAccount(), _("Allows you to see %s information about a channel or a bot")), source.service->nick.c_str()); return Anope::Format(source.Translate(_("Allows you to see %s information about a channel or a bot")), source.service->nick.c_str());
} }
}; };
+16 -15
View File
@@ -129,7 +129,7 @@ class CommandBSKick final
public: public:
CommandBSKick(Module *creator) : Command(creator, "botserv/kick", 0) CommandBSKick(Module *creator) : Command(creator, "botserv/kick", 0)
{ {
this->SetDesc(_("Configures kickers")); this->SetDesc(_("Configure kickers"));
this->SetSyntax(_("\037option\037 \037channel\037 {\037ON|OFF\037} [\037settings\037]")); this->SetSyntax(_("\037option\037 \037channel\037 {\037ON|OFF\037} [\037settings\037]"));
} }
@@ -258,7 +258,7 @@ class CommandBSKickAMSG final
public: public:
CommandBSKickAMSG(Module *creator) : CommandBSKickBase(creator, "botserv/kick/amsg", 2, 3) CommandBSKickAMSG(Module *creator) : CommandBSKickBase(creator, "botserv/kick/amsg", 2, 3)
{ {
this->SetDesc(_("Configures AMSG kicker")); this->SetDesc(_("Configure AMSG kicker"));
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]")); this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]"));
} }
@@ -298,7 +298,7 @@ class CommandBSKickBadwords final
public: public:
CommandBSKickBadwords(Module *creator) : CommandBSKickBase(creator, "botserv/kick/badwords", 2, 3) CommandBSKickBadwords(Module *creator) : CommandBSKickBase(creator, "botserv/kick/badwords", 2, 3)
{ {
this->SetDesc(_("Configures badwords kicker")); this->SetDesc(_("Configure badwords kicker"));
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]")); this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]"));
} }
@@ -342,7 +342,7 @@ class CommandBSKickBolds final
public: public:
CommandBSKickBolds(Module *creator) : CommandBSKickBase(creator, "botserv/kick/bolds", 2, 3) CommandBSKickBolds(Module *creator) : CommandBSKickBase(creator, "botserv/kick/bolds", 2, 3)
{ {
this->SetDesc(_("Configures bolds kicker")); this->SetDesc(_("Configure bolds kicker"));
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]")); this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]"));
} }
@@ -379,7 +379,7 @@ class CommandBSKickCaps final
public: public:
CommandBSKickCaps(Module *creator) : CommandBSKickBase(creator, "botserv/kick/caps", 2, 5) CommandBSKickCaps(Module *creator) : CommandBSKickBase(creator, "botserv/kick/caps", 2, 5)
{ {
this->SetDesc(_("Configures caps kicker")); this->SetDesc(_("Configure caps kicker"));
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037 [\037min\037 [\037percent\037]]]\002")); this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037 [\037min\037 [\037percent\037]]]\002"));
} }
@@ -475,7 +475,7 @@ class CommandBSKickColors final
public: public:
CommandBSKickColors(Module *creator) : CommandBSKickBase(creator, "botserv/kick/colors", 2, 3) CommandBSKickColors(Module *creator) : CommandBSKickBase(creator, "botserv/kick/colors", 2, 3)
{ {
this->SetDesc(_("Configures color kicker")); this->SetDesc(_("Configure color kicker"));
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]")); this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]"));
} }
@@ -512,7 +512,7 @@ class CommandBSKickFlood final
public: public:
CommandBSKickFlood(Module *creator) : CommandBSKickBase(creator, "botserv/kick/flood", 2, 5) CommandBSKickFlood(Module *creator) : CommandBSKickBase(creator, "botserv/kick/flood", 2, 5)
{ {
this->SetDesc(_("Configures flood kicker")); this->SetDesc(_("Configure flood kicker"));
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037 [\037ln\037 [\037secs\037]]]\002")); this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037 [\037ln\037 [\037secs\037]]]\002"));
} }
@@ -602,7 +602,7 @@ class CommandBSKickItalics final
public: public:
CommandBSKickItalics(Module *creator) : CommandBSKickBase(creator, "botserv/kick/italics", 2, 3) CommandBSKickItalics(Module *creator) : CommandBSKickBase(creator, "botserv/kick/italics", 2, 3)
{ {
this->SetDesc(_("Configures italics kicker")); this->SetDesc(_("Configure italics kicker"));
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]")); this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]"));
} }
@@ -639,7 +639,7 @@ class CommandBSKickRepeat final
public: public:
CommandBSKickRepeat(Module *creator) : CommandBSKickBase(creator, "botserv/kick/repeat", 2, 4) CommandBSKickRepeat(Module *creator) : CommandBSKickBase(creator, "botserv/kick/repeat", 2, 4)
{ {
this->SetDesc(_("Configures repeat kicker")); this->SetDesc(_("Configure repeat kicker"));
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037 [\037num\037]]\002")); this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037 [\037num\037]]\002"));
} }
@@ -750,7 +750,7 @@ class CommandBSKickReverses final
public: public:
CommandBSKickReverses(Module *creator) : CommandBSKickBase(creator, "botserv/kick/reverses", 2, 3) CommandBSKickReverses(Module *creator) : CommandBSKickBase(creator, "botserv/kick/reverses", 2, 3)
{ {
this->SetDesc(_("Configures reverses kicker")); this->SetDesc(_("Configure reverses kicker"));
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]")); this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]"));
} }
@@ -787,7 +787,7 @@ class CommandBSKickUnderlines final
public: public:
CommandBSKickUnderlines(Module *creator) : CommandBSKickBase(creator, "botserv/kick/underlines", 2, 3) CommandBSKickUnderlines(Module *creator) : CommandBSKickBase(creator, "botserv/kick/underlines", 2, 3)
{ {
this->SetDesc(_("Configures underlines kicker")); this->SetDesc(_("Configure underlines kicker"));
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]")); this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]"));
} }
@@ -1030,11 +1030,11 @@ class BanDataPurger final
{ {
public: public:
BanDataPurger(Module *o) BanDataPurger(Module *o)
: Timer(o, 300, true) : Timer(o, 300)
{ {
} }
void Tick() override bool Tick() override
{ {
Log(LOG_DEBUG) << "bs_main: Running bandata purger"; Log(LOG_DEBUG) << "bs_main: Running bandata purger";
@@ -1048,6 +1048,7 @@ public:
c->Shrink<BanData>("bandata"); c->Shrink<BanData>("bandata");
} }
} }
return true;
} }
}; };
@@ -1151,8 +1152,8 @@ public:
if (!ci) if (!ci)
return; return;
Anope::string enabled = Language::Translate(source.nc, _("Enabled")); Anope::string enabled = source.Translate(_("Enabled"));
Anope::string disabled = Language::Translate(source.nc, _("Disabled")); Anope::string disabled = source.Translate(_("Disabled"));
auto *kd = kickerdata.Get(ci); auto *kd = kickerdata.Get(ci);
if (kd && kd->badwords) if (kd && kd->badwords)
+4 -3
View File
@@ -20,7 +20,7 @@ class CommandBSSet final
public: public:
CommandBSSet(Module *creator) : Command(creator, "botserv/set", 3, 3) CommandBSSet(Module *creator) : Command(creator, "botserv/set", 3, 3)
{ {
this->SetDesc(_("Configures bot options")); this->SetDesc(_("Configure bot options"));
this->SetSyntax(_("\037option\037 \037(channel | bot)\037 \037settings\037")); this->SetSyntax(_("\037option\037 \037(channel | bot)\037 \037settings\037"));
} }
@@ -92,17 +92,18 @@ public:
{ {
} }
void Tick() override bool Tick() override
{ {
Channel *c = Channel::Find(chname); Channel *c = Channel::Find(chname);
if (c) if (c)
c->RemoveMode(NULL, "BAN", mask); c->RemoveMode(NULL, "BAN", mask);
return false;
} }
}; };
CommandBSSetBanExpire(Module *creator, const Anope::string &sname = "botserv/set/banexpire") : Command(creator, sname, 2, 2) CommandBSSetBanExpire(Module *creator, const Anope::string &sname = "botserv/set/banexpire") : Command(creator, sname, 2, 2)
{ {
this->SetDesc(_("Configures the time bot bans expire in")); this->SetDesc(_("Configure the time bot bans expire in"));
this->SetSyntax(_("\037channel\037 \037time\037")); this->SetSyntax(_("\037channel\037 \037time\037"));
} }
+4 -2
View File
@@ -82,10 +82,10 @@ public:
/** Called when the delay is up /** Called when the delay is up
* @param The current time * @param The current time
*/ */
void Tick() override bool Tick() override
{ {
if (!c) if (!c)
return; return false; // Dead channel.
/* In the event we don't part */ /* In the event we don't part */
c->RemoveMode(NULL, "SECRET"); c->RemoveMode(NULL, "SECRET");
@@ -101,6 +101,8 @@ public:
/* If someone has rejoined this channel in the meantime, don't part the bot */ /* If someone has rejoined this channel in the meantime, don't part the bot */
else if (c->users.size() <= 1) else if (c->users.size() <= 1)
c->ci->bi->Part(c); c->ci->bi->Part(c);
return false;
} }
}; };
+11 -6
View File
@@ -26,10 +26,10 @@ static inline void reset_levels(ChannelInfo *ci)
static Anope::string LevelToString(CommandSource &source, int16_t level) static Anope::string LevelToString(CommandSource &source, int16_t level)
{ {
if (level == ACCESS_INVALID) if (level == ACCESS_INVALID)
return Language::Translate(source.GetAccount(), _("(disabled)")); return source.Translate(_("(disabled)"));
if (level == ACCESS_FOUNDER) if (level == ACCESS_FOUNDER)
return Language::Translate(source.GetAccount(), _("(founder only)")); return source.Translate(_("(founder only)"));
return Anope::ToString(level); return Anope::ToString(level);
} }
@@ -92,6 +92,13 @@ public:
{ {
return new AccessChanAccess(this); return new AccessChanAccess(this);
} }
void GetAccess(CommandSource& source, const Privilege *p, Anope::map<Anope::string> &access) override
{
auto it = defaultLevels.find(p->name);
if (it != defaultLevels.end())
access[_("Level")] = LevelToString(source, it->second);
}
}; };
AccessAccessProvider *AccessAccessProvider::me; AccessAccessProvider *AccessAccessProvider::me;
@@ -893,7 +900,7 @@ public:
ListFormatter::ListEntry entry; ListFormatter::ListEntry entry;
entry["Name"] = p.name; entry["Name"] = p.name;
entry["Default"] = LevelToString(source, defaultLevels[p.name]); entry["Default"] = LevelToString(source, defaultLevels[p.name]);
entry["Description"] = Language::Translate(source.nc, p.desc.c_str()); entry["Description"] = source.Translate(p.desc.c_str());
list.AddEntry(entry); list.AddEntry(entry);
} }
@@ -956,10 +963,8 @@ public:
{ {
defaultLevels.clear(); defaultLevels.clear();
for (int i = 0; i < conf.CountBlock("privilege"); ++i) for (const auto &[_, priv] : conf.GetBlocks("privilege"))
{ {
const auto &priv = conf.GetBlock("privilege", i);
const Anope::string &pname = priv.Get<const Anope::string>("name"); const Anope::string &pname = priv.Get<const Anope::string>("name");
Privilege *p = PrivilegeManager::FindPrivilege(pname); Privilege *p = PrivilegeManager::FindPrivilege(pname);
+16 -7
View File
@@ -28,6 +28,8 @@ private:
Anope::string mode; Anope::string mode;
public: public:
bool ticked = false;
TempBan(time_t seconds, Channel *c, const Anope::string &banmask, const Anope::string &mod) TempBan(time_t seconds, Channel *c, const Anope::string &banmask, const Anope::string &mod)
: Timer(me, seconds) : Timer(me, seconds)
, channel(c->name) , channel(c->name)
@@ -51,11 +53,17 @@ public:
&& bmask == this->mask; && bmask == this->mask;
} }
void Tick() override bool Tick() override
{ {
// We need to do this to prevent the remove-on-unban logic from double
// deleting the timer.
ticked = true;
Channel *c = Channel::Find(this->channel); Channel *c = Channel::Find(this->channel);
if (c) if (c)
c->RemoveMode(NULL, mode, this->mask); c->RemoveMode(NULL, mode, this->mask);
return false;
} }
}; };
@@ -65,7 +73,7 @@ class CommandCSBan final
public: public:
CommandCSBan(Module *creator) : Command(creator, "chanserv/ban", 2, 4) CommandCSBan(Module *creator) : Command(creator, "chanserv/ban", 2, 4)
{ {
this->SetDesc(_("Bans a given nick or mask on a channel")); this->SetDesc(_("Ban a given nick or mask on a channel"));
this->SetSyntax(_("\037channel\037 [+\037expiry\037] {\037nick\037 | \037mask\037} [\037reason\037]")); this->SetSyntax(_("\037channel\037 [+\037expiry\037] {\037nick\037 | \037mask\037} [\037reason\037]"));
} }
@@ -264,11 +272,12 @@ public:
source.Reply(_( source.Reply(_(
"Bans a given nick or mask on a channel. An optional expiry may " "Bans a given nick or mask on a channel. An optional expiry may "
"be given to cause services to remove the ban after a set amount " "be given to cause services to remove the ban after a set amount "
"of time." "of time. Channel founders may ban masks."
"\n\n"
"By default, limited to AOPs or those with level 5 access "
"and above on the channel. Channel founders may ban masks."
)); ));
source.Reply(" ");
AccessProvider::SendAccess(source, "BAN");
return true; return true;
} }
}; };
@@ -290,7 +299,7 @@ public:
{ {
for (const auto *tempban : tempbans) for (const auto *tempban : tempbans)
{ {
if (tempban->Matches(c, cmode, param)) if (!tempban->ticked && tempban->Matches(c, cmode, param))
{ {
delete tempban; delete tempban;
break; break;
+5 -5
View File
@@ -64,7 +64,7 @@ private:
for (auto *user : users) for (auto *user : users)
{ {
Anope::string mask = ci->GetIdealBan(user); Anope::string mask = ci->GetIdealBan(user);
Anope::string reason = Language::Translate(user, _("RESTRICTED enforced by ")) + source.GetNick(); Anope::string reason = Anope::Format(Language::Translate(user, _("RESTRICTED enforced by %s")), source.GetNick().c_str());
ci->c->SetMode(NULL, "BAN", mask); ci->c->SetMode(NULL, "BAN", mask);
ci->c->Kick(NULL, user, reason); ci->c->Kick(NULL, user, reason);
} }
@@ -92,7 +92,7 @@ private:
for (auto *user : users) for (auto *user : users)
{ {
Anope::string mask = ci->GetIdealBan(user); Anope::string mask = ci->GetIdealBan(user);
Anope::string reason = Language::Translate(user, _("REGONLY enforced by ")) + source.GetNick(); Anope::string reason = Anope::Format(Language::Translate(user, _("REGONLY enforced by %s")), source.GetNick().c_str());
if (!ci->c->HasMode("REGISTEREDONLY")) if (!ci->c->HasMode("REGISTEREDONLY"))
ci->c->SetMode(NULL, "BAN", mask); ci->c->SetMode(NULL, "BAN", mask);
ci->c->Kick(NULL, user, reason); ci->c->Kick(NULL, user, reason);
@@ -121,7 +121,7 @@ private:
for (auto *user : users) for (auto *user : users)
{ {
Anope::string mask = ci->GetIdealBan(user); Anope::string mask = ci->GetIdealBan(user);
Anope::string reason = Language::Translate(user, _("SSLONLY enforced by ")) + source.GetNick(); Anope::string reason = Anope::Format(Language::Translate(user, _("SSLONLY enforced by %s")), source.GetNick().c_str());
if (!ci->c->HasMode("SSL")) if (!ci->c->HasMode("SSL"))
ci->c->SetMode(NULL, "BAN", mask); ci->c->SetMode(NULL, "BAN", mask);
ci->c->Kick(NULL, user, reason); ci->c->Kick(NULL, user, reason);
@@ -149,7 +149,7 @@ private:
for (auto *user : users) for (auto *user : users)
{ {
Anope::string reason = Language::Translate(user, _("BANS enforced by ")) + source.GetNick(); Anope::string reason = Anope::Format(Language::Translate(user, _("BANS enforced by %s")), source.GetNick().c_str());
ci->c->Kick(NULL, user, reason); ci->c->Kick(NULL, user, reason);
} }
@@ -197,7 +197,7 @@ private:
for (auto *user : users) for (auto *user : users)
{ {
Anope::string reason = Language::Translate(user, _("LIMIT enforced by ")) + source.GetNick(); Anope::string reason = Anope::Format(Language::Translate(user, _("LIMIT enforced by %s")), source.GetNick().c_str());
ci->c->Kick(NULL, user, reason); ci->c->Kick(NULL, user, reason);
} }
+1 -5
View File
@@ -299,11 +299,7 @@ public:
{ {
Anope::map<Anope::string> tags; Anope::map<Anope::string> tags;
if (timestamp) if (timestamp)
{ tags["time"] = Anope::FormatISO8601(message->when, 0);
char timebuf[32];
strftime(timebuf, sizeof(timebuf), "%Y-%m-%dT%H:%M:%S.000Z", gmtime(&message->when));
tags["time"] = timebuf;
}
if (u->ShouldPrivmsg()) if (u->ShouldPrivmsg())
IRCD->SendContextPrivmsg(c->ci->WhoSends(), u, c, message->message, tags); IRCD->SendContextPrivmsg(c->ci->WhoSends(), u, c, message->message, tags);
+3 -3
View File
@@ -41,7 +41,7 @@ class CommandCSStats final
public: public:
CommandCSStats(Module *creator) : Command (creator, "chanserv/stats", 0, 2) CommandCSStats(Module *creator) : Command (creator, "chanserv/stats", 0, 2)
{ {
this->SetDesc(_("Displays your Channel Stats")); this->SetDesc(_("Display your Channel Stats"));
this->SetSyntax(_("[\037channel\037] [\037nick\037]")); this->SetSyntax(_("[\037channel\037] [\037nick\037]"));
} }
@@ -54,7 +54,7 @@ class CommandCSGStats final
public: public:
CommandCSGStats(Module *creator) : Command (creator, "chanserv/gstats", 0, 2) CommandCSGStats(Module *creator) : Command (creator, "chanserv/gstats", 0, 2)
{ {
this->SetDesc(_("Displays your Global Stats")); this->SetDesc(_("Display your Global Stats"));
this->SetSyntax(_("\037nick\037")); this->SetSyntax(_("\037nick\037"));
} }
@@ -86,7 +86,7 @@ public:
void OnReload(Configuration::Conf &conf) override void OnReload(Configuration::Conf &conf) override
{ {
const auto &block = conf.GetModule("chanstats"); const auto &block = conf.GetModule("chanstats");
prefix = block.Get<const Anope::string>("prefix", "anope_"); prefix = block.Get<const Anope::string>("prefix", "chanstats21_");
this->sql.SetServiceName(block.Get<const Anope::string>("engine")); this->sql.SetServiceName(block.Get<const Anope::string>("engine"));
} }
+5 -5
View File
@@ -40,7 +40,7 @@ class CommandCSTop final
public: public:
CommandCSTop(Module *creator) : Command (creator, "chanserv/top", 0, 2) CommandCSTop(Module *creator) : Command (creator, "chanserv/top", 0, 2)
{ {
this->SetDesc(_("Displays the top 3 users of a channel")); this->SetDesc(_("Display the top 3 users of a channel"));
this->SetSyntax(_("\037channel\037")); this->SetSyntax(_("\037channel\037"));
} }
@@ -53,7 +53,7 @@ class CommandCSTop10 final
public: public:
CommandCSTop10(Module *creator) : Command (creator, "chanserv/top10", 0, 2) CommandCSTop10(Module *creator) : Command (creator, "chanserv/top10", 0, 2)
{ {
this->SetDesc(_("Displays the top 10 users of a channel")); this->SetDesc(_("Display the top 10 users of a channel"));
this->SetSyntax(_("\037channel\037")); this->SetSyntax(_("\037channel\037"));
} }
@@ -66,7 +66,7 @@ class CommandCSGTop final
public: public:
CommandCSGTop(Module *creator) : Command (creator, "chanserv/gtop", 0, 1) CommandCSGTop(Module *creator) : Command (creator, "chanserv/gtop", 0, 1)
{ {
this->SetDesc(_("Displays the top 3 users of the network")); this->SetDesc(_("Display the top 3 users of the network"));
} }
void Execute(CommandSource &source, const std::vector<Anope::string> &params); void Execute(CommandSource &source, const std::vector<Anope::string> &params);
@@ -78,7 +78,7 @@ class CommandCSGTop10 final
public: public:
CommandCSGTop10(Module *creator) : Command (creator, "chanserv/gtop10", 0, 1) CommandCSGTop10(Module *creator) : Command (creator, "chanserv/gtop10", 0, 1)
{ {
this->SetDesc(_("Displays the top 10 users of the network")); this->SetDesc(_("Display the top 10 users of the network"));
} }
void Execute(CommandSource &source, const std::vector<Anope::string> &params); void Execute(CommandSource &source, const std::vector<Anope::string> &params);
@@ -114,7 +114,7 @@ public:
void OnReload(Configuration::Conf &conf) override void OnReload(Configuration::Conf &conf) override
{ {
const auto &block = conf.GetModule("chanstats"); const auto &block = conf.GetModule("chanstats");
prefix = block.Get<const Anope::string>("prefix", "anope_"); prefix = block.Get<const Anope::string>("prefix", "chanstats21_");
this->sql.SetServiceName(block.Get<const Anope::string>("engine")); this->sql.SetServiceName(block.Get<const Anope::string>("engine"));
} }
+54 -15
View File
@@ -14,7 +14,15 @@
#include "module.h" #include "module.h"
#define FLAGS_MIGRATED_1 _("\002%s\002 has been migrated to the %s access system.")
#define FLAGS_MIGRATED_N N_("\002%u\002 entry has been migrated to the %s access system.", "\002%u\002 entries have been migrated to the %s access system.")
#define FLAGS_NOT_MIGRATABLE_1 _("\002%s\002 can not be migrated to the %s access system because they have no migratable privileges.")
#define FLAGS_NOT_MIGRATABLE_N N_("\002%u\002 entry can not be migrated to the %s access system because they have no migratable privileges.", "\002%u\002 entries can not be migrated to the %s access system because they have no migratable privileges.")
#define FLAGS_NOT_MIGRATED_1 _("\002%s\002 can not be migrated to the %s access system because they have privileges that you do not.")
#define FLAGS_NOT_MIGRATED_N N_("\002%u\002 entry can not be migrated to the %s access system because they have privileges that you do not.", "\002%u\002 entries can not be migrated to the %s access system because they have privileges that you do not.")
static std::map<Anope::string, char> defaultFlags; static std::map<Anope::string, char> defaultFlags;
static Anope::map<Anope::string> migrationRequires;
class FlagsChanAccess final class FlagsChanAccess final
: public ChanAccess : public ChanAccess
@@ -76,6 +84,13 @@ public:
{ {
return new FlagsChanAccess(this); return new FlagsChanAccess(this);
} }
void GetAccess(CommandSource& source, const Privilege *p, Anope::map<Anope::string> &access) override
{
auto it = defaultFlags.find(p->name);
if (it != defaultFlags.end())
access[_("Flag")] = Anope::ToString(it->second);
}
}; };
FlagsAccessProvider *FlagsAccessProvider::ap; FlagsAccessProvider *FlagsAccessProvider::ap;
@@ -303,8 +318,8 @@ class CommandCSFlags final
return; return;
auto *access = anope_dynamic_static_cast<FlagsChanAccess *>(provider->Create()); auto *access = anope_dynamic_static_cast<FlagsChanAccess *>(provider->Create());
access->SetMask(mask, ci); access->SetMask(mask, ci);
access->creator = source.GetNick(); access->creator = source.GetNick();
access->description = current ? current->description : description; access->description = current && description.empty() ? current->description : description;
access->last_seen = current ? current->last_seen : 0; access->last_seen = current ? current->last_seen : 0;
access->created = Anope::CurTime; access->created = Anope::CurTime;
access->flags = current_flags; access->flags = current_flags;
@@ -411,10 +426,9 @@ class CommandCSFlags final
void DoMigrate(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> &params) void DoMigrate(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> &params)
{ {
auto override = false; auto override = false;
const auto source_access = source.AccessFor(ci);
unsigned migrated = 0, notmigrated = 0; unsigned migrated = 0, notmigratable = 0, notmigrated = 0;
Anope::string migratedmask, notmigratedmask; Anope::string migratedmask, notmigratablemask, notmigratedmask;
const auto &entry = params.size() > 2 ? params[2] : "*"; const auto &entry = params.size() > 2 ? params[2] : "*";
for (auto idx = ci->GetAccessCount(); idx > 0; --idx) for (auto idx = ci->GetAccessCount(); idx > 0; --idx)
{ {
@@ -428,34 +442,52 @@ class CommandCSFlags final
std::set<char> newflags; std::set<char> newflags;
for (auto &[priv, flag] : defaultFlags) for (auto &[priv, flag] : defaultFlags)
{ {
if (access->HasPriv(priv)) if (!access->HasPriv(priv))
continue; // Source doesn't have this flag. continue; // Source doesn't have this flag.
// Check that the source has access to set this entry. // Check that the source has access to set this entry.
const auto source_access = source.AccessFor(ci);
if (!override && !source_access.HasPriv(priv) && !source_access.founder) if (!override && !source_access.HasPriv(priv) && !source_access.founder)
{ {
if (!source.HasPriv("chanserv/access/modify")) if (!source.HasPriv("chanserv/access/modify"))
{ {
notmigrated++; notmigrated++;
notmigratedmask = access->Mask(); notmigratedmask = access->Mask();
Log(LOG_DEBUG) << source.GetNick() << " does not have the access to migrate " << access->Mask() << " to flags";
continue; // No privs continue; // No privs
} }
override = true; override = true;
} }
auto req = migrationRequires.find(priv);
if (req != migrationRequires.end() && !access->HasPriv(req->second))
{
Log(LOG_DEBUG) << access->Mask() << " has " << priv << " but not " << req->second << " so it will be lost on migration to flags";
continue; // Required flag missing.
}
newflags.insert(flag); newflags.insert(flag);
} }
if (newflags.empty())
{
notmigratable++;
notmigratablemask = access->Mask();
Log(LOG_DEBUG) << access->Mask() << " has " << access->AccessSerialize() << " that can not be migrated to flags";
continue; // No privs that are migratable
}
migrated++; migrated++;
migratedmask = access->Mask(); migratedmask = access->Mask();
auto *newaccess = anope_dynamic_static_cast<FlagsChanAccess *>(FlagsAccessProvider::ap->Create()); auto *newaccess = anope_dynamic_static_cast<FlagsChanAccess *>(FlagsAccessProvider::ap->Create());
newaccess->SetMask(access->Mask(), ci); newaccess->SetMask(access->Mask(), ci);
newaccess->created = access->created;
newaccess->creator = access->creator; newaccess->creator = access->creator;
newaccess->description = access->description; newaccess->description = access->description;
newaccess->created = access->created;
newaccess->flags = newflags; newaccess->flags = newflags;
newaccess->last_seen = access->last_seen;
ci->EraseAccess(idx - 1); ci->EraseAccess(idx - 1);
FOREACH_MOD(OnAccessDel, (ci, source, access, true)); FOREACH_MOD(OnAccessDel, (ci, source, access, true));
@@ -468,18 +500,23 @@ class CommandCSFlags final
if (migrated == 1) if (migrated == 1)
{ {
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to migrate " << migratedmask; Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to migrate " << migratedmask;
source.Reply(CHAN_ACCESS_MIGRATED_1, migratedmask.c_str(), source.command.nobreak().c_str()); source.Reply(FLAGS_MIGRATED_1, migratedmask.c_str(), source.command.nobreak().c_str());
} }
else if (migrated > 1) else if (migrated > 1)
{ {
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to migrate " << migrated << " access entries"; Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to migrate " << migrated << " access entries";
source.Reply(migrated, CHAN_ACCESS_MIGRATED_N, migrated, source.command.nobreak().c_str()); source.Reply(migrated, FLAGS_MIGRATED_N, migrated, source.command.nobreak().c_str());
} }
if (notmigratable == 1)
source.Reply(FLAGS_NOT_MIGRATABLE_1, notmigratablemask.c_str(), source.command.nobreak().c_str());
else if (notmigratable > 1)
source.Reply(notmigratable, FLAGS_NOT_MIGRATABLE_N, notmigratable, source.command.nobreak().c_str());
if (notmigrated == 1) if (notmigrated == 1)
source.Reply(CHAN_ACCESS_NOT_MIGRATED_1, notmigratedmask.c_str(), source.command.nobreak().c_str()); source.Reply(FLAGS_NOT_MIGRATED_1, notmigratedmask.c_str(), source.command.nobreak().c_str());
else if (notmigrated > 1) else if (notmigrated > 1)
source.Reply(migrated, CHAN_ACCESS_NOT_MIGRATED_N, notmigrated, source.command.nobreak().c_str()); source.Reply(notmigrated, FLAGS_NOT_MIGRATED_N, notmigrated, source.command.nobreak().c_str());
} }
void DoClear(CommandSource &source, ChannelInfo *ci) void DoClear(CommandSource &source, ChannelInfo *ci)
@@ -599,7 +636,7 @@ public:
Privilege *p = PrivilegeManager::FindPrivilege(priv); Privilege *p = PrivilegeManager::FindPrivilege(priv);
if (p == NULL) if (p == NULL)
continue; continue;
source.Reply(" %c - %s", flag, Language::Translate(source.nc, p->desc.c_str())); source.Reply(" %c - %s", flag, source.Translate(p->desc.c_str()));
} }
return true; return true;
@@ -624,10 +661,8 @@ public:
{ {
defaultFlags.clear(); defaultFlags.clear();
for (int i = 0; i < conf.CountBlock("privilege"); ++i) for (const auto &[_, priv] : conf.GetBlocks("privilege"))
{ {
const auto &priv = conf.GetBlock("privilege", i);
const Anope::string &pname = priv.Get<const Anope::string>("name"); const Anope::string &pname = priv.Get<const Anope::string>("name");
Privilege *p = PrivilegeManager::FindPrivilege(pname); Privilege *p = PrivilegeManager::FindPrivilege(pname);
@@ -638,6 +673,10 @@ public:
if (value.empty()) if (value.empty())
continue; continue;
const auto &migration_requires = priv.Get<const Anope::string>("flag_migration_requires");
if (!migration_requires.empty())
migrationRequires[p->name] = migration_requires;
defaultFlags[p->name] = value[0]; defaultFlags[p->name] = value[0];
} }
} }
+1 -1
View File
@@ -20,7 +20,7 @@ class CommandCSGetKey final
public: public:
CommandCSGetKey(Module *creator) : Command(creator, "chanserv/getkey", 1, 1) CommandCSGetKey(Module *creator) : Command(creator, "chanserv/getkey", 1, 1)
{ {
this->SetDesc(_("Returns the key of the given channel")); this->SetDesc(_("Return the key of the given channel"));
this->SetSyntax(_("\037channel\037")); this->SetSyntax(_("\037channel\037"));
} }
+1 -1
View File
@@ -20,7 +20,7 @@ class CommandCSInfo final
public: public:
CommandCSInfo(Module *creator) : Command(creator, "chanserv/info", 1, 2) CommandCSInfo(Module *creator) : Command(creator, "chanserv/info", 1, 2)
{ {
this->SetDesc(_("Lists information about the specified registered channel")); this->SetDesc(_("List information about the specified registered channel"));
this->SetSyntax(_("\037channel\037")); this->SetSyntax(_("\037channel\037"));
this->AllowUnregistered(true); this->AllowUnregistered(true);
} }
+5 -4
View File
@@ -20,7 +20,7 @@ class CommandCSInvite final
public: public:
CommandCSInvite(Module *creator) : Command(creator, "chanserv/invite", 1, 3) CommandCSInvite(Module *creator) : Command(creator, "chanserv/invite", 1, 3)
{ {
this->SetDesc(_("Invites you or an optionally specified nick into a channel")); this->SetDesc(_("Invite you or an optionally specified nick into a channel"));
this->SetSyntax(_("\037channel\037 [\037nick\037]")); this->SetSyntax(_("\037channel\037 [\037nick\037]"));
} }
@@ -95,11 +95,12 @@ public:
source.Reply(_( source.Reply(_(
"Tells %s to invite you or an optionally specified " "Tells %s to invite you or an optionally specified "
"nick into the given channel." "nick into the given channel."
"\n\n"
"By default, limited to AOPs or those with level 5 access and above "
"on the channel."
), ),
source.service->nick.c_str()); source.service->nick.c_str());
source.Reply(" ");
AccessProvider::SendAccess(source, "INVITE");
return true; return true;
} }
}; };
+6 -7
View File
@@ -20,7 +20,7 @@ class CommandCSKick final
public: public:
CommandCSKick(Module *creator) : Command(creator, "chanserv/kick", 2, 3) CommandCSKick(Module *creator) : Command(creator, "chanserv/kick", 2, 3)
{ {
this->SetDesc(_("Kicks a specified nick from a channel")); this->SetDesc(_("Kick a specified nick from a channel"));
this->SetSyntax(_("\037channel\037 \037nick\037 [\037reason\037]")); this->SetSyntax(_("\037channel\037 \037nick\037 [\037reason\037]"));
this->SetSyntax(_("\037channel\037 \037mask\037 [\037reason\037]")); this->SetSyntax(_("\037channel\037 \037mask\037 [\037reason\037]"));
} }
@@ -134,12 +134,11 @@ public:
{ {
this->SendSyntax(source); this->SendSyntax(source);
source.Reply(" "); source.Reply(" ");
source.Reply(_( source.Reply(_("Kicks a specified nick from a channel. Channel founders can also specify masks."));
"Kicks a specified nick from a channel."
"\n\n" source.Reply(" ");
"By default, limited to AOPs or those with level 5 access " AccessProvider::SendAccess(source, "KICK");
"and above on the channel. Channel founders can also specify masks."
));
return true; return true;
} }
}; };
+2 -2
View File
@@ -21,7 +21,7 @@ class CommandCSList final
public: public:
CommandCSList(Module *creator) : Command(creator, "chanserv/list", 1, 2) CommandCSList(Module *creator) : Command(creator, "chanserv/list", 1, 2)
{ {
this->SetDesc(_("Lists all registered channels matching the given pattern")); this->SetDesc(_("List all registered channels matching the given pattern"));
this->SetSyntax(_("\037pattern\037 [SUSPENDED] [NOEXPIRE]")); this->SetSyntax(_("\037pattern\037 [SUSPENDED] [NOEXPIRE]"));
} }
@@ -122,7 +122,7 @@ public:
ListFormatter::ListEntry entry; ListFormatter::ListEntry entry;
entry["Name"] = (isnoexpire ? "!" : "") + ci->name; entry["Name"] = (isnoexpire ? "!" : "") + ci->name;
if (ci->HasExt("CS_SUSPENDED")) if (ci->HasExt("CS_SUSPENDED"))
entry["Description"] = Language::Translate(source.GetAccount(), _("[Suspended]")); entry["Description"] = source.Translate(_("[Suspended]"));
else else
entry["Description"] = ci->desc; entry["Description"] = ci->desc;
list.AddEntry(entry); list.AddEntry(entry);
+2 -4
View File
@@ -118,7 +118,7 @@ class CommandCSLog final
public: public:
CommandCSLog(Module *creator) : Command(creator, "chanserv/log", 1, 4) CommandCSLog(Module *creator) : Command(creator, "chanserv/log", 1, 4)
{ {
this->SetDesc(_("Configures channel logging settings")); this->SetDesc(_("Configure channel logging settings"));
this->SetSyntax(_("\037channel\037")); this->SetSyntax(_("\037channel\037"));
this->SetSyntax(_("\037channel\037 \037command\037 \037method\037 [\037status\037]")); this->SetSyntax(_("\037channel\037 \037command\037 \037method\037 [\037status\037]"));
} }
@@ -331,10 +331,8 @@ public:
const auto &block = conf.GetModule(this); const auto &block = conf.GetModule(this);
defaults.clear(); defaults.clear();
for (int i = 0; i < block.CountBlock("default"); ++i) for (const auto &[_, def] : block.GetBlocks("default"))
{ {
const auto &def = block.GetBlock("default", i);
LogDefault ld; LogDefault ld;
ld.service = def.Get<const Anope::string>("service"); ld.service = def.Get<const Anope::string>("service");
+3 -5
View File
@@ -945,9 +945,9 @@ public:
if (!m.second.empty()) if (!m.second.empty())
{ {
if (m.first) if (m.first)
return Anope::Format(Language::Translate(source.GetAccount(), _("Gives you or the specified nick %s status on a channel")), m.second.c_str()); return Anope::Format(source.Translate(_("Gives you or the specified nick %s status on a channel")), m.second.c_str());
else else
return Anope::Format(Language::Translate(source.GetAccount(), _("Removes %s status from you or the specified nick on a channel")), m.second.c_str()); return Anope::Format(source.Translate(_("Removes %s status from you or the specified nick on a channel")), m.second.c_str());
} }
else else
return ""; return "";
@@ -999,10 +999,8 @@ public:
{ {
modes.clear(); modes.clear();
for (int i = 0; i < conf.CountBlock("command"); ++i) for (const auto &[_, block] : conf.GetBlocks("command"))
{ {
const auto &block = conf.GetBlock("command", i);
const Anope::string &cname = block.Get<const Anope::string>("name"), const Anope::string &cname = block.Get<const Anope::string>("name"),
&cmd = block.Get<const Anope::string>("command"); &cmd = block.Get<const Anope::string>("command");
+4 -4
View File
@@ -242,7 +242,7 @@ class CommandSeen final
public: public:
CommandSeen(Module *creator) : Command(creator, "chanserv/seen", 1, 2) CommandSeen(Module *creator) : Command(creator, "chanserv/seen", 1, 2)
{ {
this->SetDesc(_("Tells you about the last time a user was seen")); this->SetDesc(_("Tell you about the last time a user was seen"));
this->SetSyntax(_("\037nick\037")); this->SetSyntax(_("\037nick\037"));
this->AllowUnregistered(true); this->AllowUnregistered(true);
} }
@@ -281,7 +281,7 @@ public:
if (u2) if (u2)
onlinestatus = "."; onlinestatus = ".";
else else
onlinestatus = Anope::Format(Language::Translate(source.nc, _(" but %s mysteriously dematerialized.")), target.c_str()); onlinestatus = Anope::Format(source.Translate(_(" but %s mysteriously dematerialized.")), target.c_str());
Anope::string timebuf = Anope::Duration(Anope::CurTime - info->last, source.nc); Anope::string timebuf = Anope::Duration(Anope::CurTime - info->last, source.nc);
Anope::string timebuf2 = Anope::strftime(info->last, source.nc, true); Anope::string timebuf2 = Anope::strftime(info->last, source.nc, true);
@@ -295,9 +295,9 @@ public:
{ {
u2 = User::Find(info->nick2, true); u2 = User::Find(info->nick2, true);
if (u2) if (u2)
onlinestatus = Anope::Format(Language::Translate(source.nc, _(". %s is still online.")), u2->nick.c_str()); onlinestatus = Anope::Format(source.Translate(_(". %s is still online.")), u2->nick.c_str());
else else
onlinestatus = Anope::Format(Language::Translate(source.nc, _(", but %s mysteriously dematerialized.")), info->nick2.c_str()); onlinestatus = Anope::Format(source.Translate(_(", but %s mysteriously dematerialized.")), info->nick2.c_str());
source.Reply(_("%s (%s) was last seen changing nick to %s %s ago%s"), source.Reply(_("%s (%s) was last seen changing nick to %s %s ago%s"),
target.c_str(), info->vhost.c_str(), info->nick2.c_str(), timebuf.c_str(), onlinestatus.c_str()); target.c_str(), info->vhost.c_str(), info->nick2.c_str(), timebuf.c_str(), onlinestatus.c_str());
+5 -5
View File
@@ -222,7 +222,7 @@ public:
{ {
this->SendSyntax(source); this->SendSyntax(source);
source.Reply(" "); source.Reply(" ");
source.Reply("%s", Language::Translate(source.nc, it->second.description.c_str())); source.Reply("%s", source.Translate(it->second.description.c_str()));
return true; return true;
} }
return false; return false;
@@ -237,8 +237,8 @@ public:
this->ClearSyntax(); this->ClearSyntax();
this->SetSyntax(Anope::Format( this->SetSyntax(Anope::Format(
Language::Translate(source.nc, _("\037channel\037 [\037%s\037]")), source.Translate(_("\037channel\037 [\037%s\037]")),
Language::Translate(source.nc, value) source.Translate(value)
)); ));
Command::SendSyntax(source); Command::SendSyntax(source);
@@ -268,9 +268,9 @@ public:
void OnReload(Configuration::Conf &conf) override void OnReload(Configuration::Conf &conf) override
{ {
command_data.clear(); command_data.clear();
for (int i = 0; i < conf.CountBlock("command"); ++i)
for (const auto &[_, block] : conf.GetBlocks("command"))
{ {
const auto &block = conf.GetBlock("command", i);
if (block.Get<const Anope::string>("command") != "chanserv/set/misc") if (block.Get<const Anope::string>("command") != "chanserv/set/misc")
continue; continue;
+1 -1
View File
@@ -165,7 +165,7 @@ class CommandCSUnSuspend final
public: public:
CommandCSUnSuspend(Module *creator) : Command(creator, "chanserv/unsuspend", 1, 1) CommandCSUnSuspend(Module *creator) : Command(creator, "chanserv/unsuspend", 1, 1)
{ {
this->SetDesc(_("Releases a suspended channel")); this->SetDesc(_("Release a suspended channel"));
this->SetSyntax(_("\037channel\037")); this->SetSyntax(_("\037channel\037"));
} }
+4 -3
View File
@@ -128,11 +128,12 @@ public:
"user from entering the given channel. If no channel is " "user from entering the given channel. If no channel is "
"given, all bans affecting you in channels you have access " "given, all bans affecting you in channels you have access "
"in are removed." "in are removed."
"\n\n"
"By default, limited to AOPs or those with level 5 access and above "
"on the channel."
), ),
source.service->nick.c_str()); source.service->nick.c_str());
source.Reply(" ");
AccessProvider::SendAccess(source, "UNBAN");
return true; return true;
} }
}; };
+2 -2
View File
@@ -48,7 +48,7 @@ class CommandCSUp final
public: public:
CommandCSUp(Module *creator) : Command(creator, "chanserv/up", 0, 2) CommandCSUp(Module *creator) : Command(creator, "chanserv/up", 0, 2)
{ {
this->SetDesc(_("Updates a selected nicks status on a channel")); this->SetDesc(_("Update a selected nicks status on a channel"));
this->SetSyntax(_("[\037channel\037 [\037nick\037]]")); this->SetSyntax(_("[\037channel\037 [\037nick\037]]"));
} }
@@ -152,7 +152,7 @@ class CommandCSDown final
public: public:
CommandCSDown(Module *creator) : Command(creator, "chanserv/down", 0, 2) CommandCSDown(Module *creator) : Command(creator, "chanserv/down", 0, 2)
{ {
this->SetDesc(_("Removes a selected nicks status from a channel")); this->SetDesc(_("Remove a selected nicks status from a channel"));
this->SetSyntax(_("[\037channel\037 [\037nick\037]]")); this->SetSyntax(_("[\037channel\037 [\037nick\037]]"));
} }
+16 -5
View File
@@ -100,6 +100,19 @@ public:
{ {
return new XOPChanAccess(this); return new XOPChanAccess(this);
} }
void GetAccess(CommandSource& source, const Privilege *p, Anope::map<Anope::string> &access) override
{
for (const auto& xop : order)
{
const auto &privs = permissions[xop];
if (std::find(privs.begin(), privs.end(), p->name) != privs.end())
{
access[_("XOP")] = xop;
return;
}
}
}
}; };
class CommandCSXOP final class CommandCSXOP final
@@ -543,7 +556,7 @@ public:
Anope::string GetDesc(CommandSource &source) const override Anope::string GetDesc(CommandSource &source) const override
{ {
return Anope::Format(Language::Translate(source.GetAccount(), _("Modify the list of %s users")), source.command.nobreak().c_str()); return Anope::Format(source.Translate(_("Modify the list of %s users")), source.command.nobreak().c_str());
} }
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
@@ -675,9 +688,8 @@ public:
order.clear(); order.clear();
permissions.clear(); permissions.clear();
for (int i = 0; i < conf.CountBlock("privilege"); ++i) for (const auto &[_, block] : conf.GetBlocks("privilege"))
{ {
const auto &block = conf.GetBlock("privilege", i);
const Anope::string &pname = block.Get<const Anope::string>("name"); const Anope::string &pname = block.Get<const Anope::string>("name");
Privilege *p = PrivilegeManager::FindPrivilege(pname); Privilege *p = PrivilegeManager::FindPrivilege(pname);
@@ -691,9 +703,8 @@ public:
permissions[xop].push_back(pname); permissions[xop].push_back(pname);
} }
for (int i = 0; i < conf.CountBlock("command"); ++i) for (const auto &[_, block] : conf.GetBlocks("command"))
{ {
const auto &block = conf.GetBlock("command", i);
const Anope::string &cname = block.Get<const Anope::string>("name"), const Anope::string &cname = block.Get<const Anope::string>("name"),
&cserv = block.Get<const Anope::string>("command"); &cserv = block.Get<const Anope::string>("command");
if (cname.empty() || cserv != "chanserv/xop") if (cname.empty() || cserv != "chanserv/xop")
+5 -3
View File
@@ -353,14 +353,16 @@ class MChanstats final
"(nick_, '', 'total'), (nick_, '', 'monthly')," "(nick_, '', 'total'), (nick_, '', 'monthly'),"
"(nick_, '', 'weekly'), (nick_, '', 'daily');" "(nick_, '', 'weekly'), (nick_, '', 'daily');"
"END IF;" "END IF;"
"SET @echan = chan_;"
"SET @enick = nick_;"
"SET @update_query = CONCAT('UPDATE `" + prefix + "chanstats` SET line=line+', line_, '," "SET @update_query = CONCAT('UPDATE `" + prefix + "chanstats` SET line=line+', line_, ',"
"letters=letters+', letters_, ' , words=words+', words_, ', actions=actions+', actions_, ', " "letters=letters+', letters_, ' , words=words+', words_, ', actions=actions+', actions_, ', "
"smileys_happy=smileys_happy+', sm_h_, ', smileys_sad=smileys_sad+', sm_s_, ', " "smileys_happy=smileys_happy+', sm_h_, ', smileys_sad=smileys_sad+', sm_s_, ', "
"smileys_other=smileys_other+', sm_o_, ', kicks=kicks+', kicks_, ', kicked=kicked+', kicked_, ', " "smileys_other=smileys_other+', sm_o_, ', kicks=kicks+', kicks_, ', kicked=kicked+', kicked_, ', "
"modes=modes+', modes_, ', topics=topics+', topics_, ', ', time_ , '=', time_, '+', line_ ,' " "modes=modes+', modes_, ', topics=topics+', topics_, ', ', time_ , '=', time_, '+', line_ ,' "
"WHERE (nick='''' OR nick=''', nick_, ''') AND (chan='''' OR chan=''', chan_, ''')');" "WHERE (nick='''' OR nick=?) AND (chan='''' OR chan=?)');"
"PREPARE update_query FROM @update_query;" "PREPARE update_query FROM @update_query;"
"EXECUTE update_query;" "EXECUTE update_query using @enick, @echan;"
"DEALLOCATE PREPARE update_query;" "DEALLOCATE PREPARE update_query;"
"END"; "END";
this->RunQuery(query); this->RunQuery(query);
@@ -509,7 +511,7 @@ public:
void OnReload(Configuration::Conf &conf) override void OnReload(Configuration::Conf &conf) override
{ {
const auto &block = conf.GetModule(this); const auto &block = conf.GetModule(this);
prefix = block.Get<const Anope::string>("prefix", "anope_"); prefix = block.Get<const Anope::string>("prefix", "chanstats21_");
SmileysHappy = block.Get<const Anope::string>("SmileysHappy"); SmileysHappy = block.Get<const Anope::string>("SmileysHappy");
SmileysSad = block.Get<const Anope::string>("SmileysSad"); SmileysSad = block.Get<const Anope::string>("SmileysSad");
SmileysOther = block.Get<const Anope::string>("SmileysOther"); SmileysOther = block.Get<const Anope::string>("SmileysOther");
+181 -24
View File
@@ -12,6 +12,7 @@
// //
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
#include <algorithm>
#include "module.h" #include "module.h"
#include "modules/botserv/badwords.h" #include "modules/botserv/badwords.h"
@@ -21,6 +22,7 @@
#include "modules/chanserv/mode.h" #include "modules/chanserv/mode.h"
#include "modules/hostserv/request.h" #include "modules/hostserv/request.h"
#include "modules/info.h" #include "modules/info.h"
#include "modules/nickserv/ajoin.h"
#include "modules/nickserv/cert.h" #include "modules/nickserv/cert.h"
#include "modules/operserv/forbid.h" #include "modules/operserv/forbid.h"
#include "modules/operserv/news.h" #include "modules/operserv/news.h"
@@ -73,10 +75,10 @@ public:
} }
// Retrieves the remaining data in the row. // Retrieves the remaining data in the row.
Anope::string GetRemaining() Anope::string GetRemaining(bool allow_empty = false)
{ {
auto remaining = stream.GetRemaining(); auto remaining = stream.GetRemaining();
if (remaining.empty()) if (remaining.empty() && !allow_empty)
error++; error++;
return remaining; return remaining;
} }
@@ -120,14 +122,49 @@ struct ModeLockData final
} }
}; };
struct FounderSuccessorCandidate
{
// Flags ranked from founder down, for successor candidate ranking
static const Anope::string FLAG_PRIORITY;
NickCore* nc;
size_t priority;
time_t mtime;
FounderSuccessorCandidate()
: nc(nullptr)
, priority(99) // arbitrary; for log readability
, mtime(std::numeric_limits<std::time_t>::max())
{
}
FounderSuccessorCandidate(NickCore *c, const Anope::string &flags, time_t m)
: nc(c)
, priority(FLAG_PRIORITY.find_first_of(flags))
, mtime(m)
{
}
bool operator<(const FounderSuccessorCandidate& other)
{
return std::tie(priority, mtime) < std::tie(other.priority, other.mtime);
}
FounderSuccessorCandidate& operator=(const FounderSuccessorCandidate& other) = default;
};
const Anope::string FounderSuccessorCandidate::FLAG_PRIORITY = "FSRsaOoHh";
struct ChannelData final struct ChannelData final
{ {
Anope::unordered_map<ChanServ::AutoKick *> akicks; Anope::unordered_map<ChanServ::AutoKick *> akicks;
Anope::string bot; Anope::string bot;
FounderSuccessorCandidate founder_candidate;
Anope::string info_adder; Anope::string info_adder;
Anope::string info_message; Anope::string info_message;
time_t info_ts = 0; time_t info_ts = 0;
std::vector<ModeLockData> mlocks; std::vector<ModeLockData> mlocks;
FounderSuccessorCandidate successor_candidate;
Anope::string suspend_by; Anope::string suspend_by;
Anope::string suspend_reason; Anope::string suspend_reason;
time_t suspend_ts = 0; time_t suspend_ts = 0;
@@ -135,6 +172,7 @@ struct ChannelData final
struct UserData final struct UserData final
{ {
Anope::map<Anope::string> ajoins;
Anope::string info_adder; Anope::string info_adder;
Anope::string info_message; Anope::string info_message;
time_t info_ts = 0; time_t info_ts = 0;
@@ -236,21 +274,40 @@ private:
{ "XL", &DBAtheme::HandleXL }, { "XL", &DBAtheme::HandleXL },
}; };
void ApplyAccess(Anope::string &in, char flag, Anope::string &out, std::initializer_list<const char*> privs) static void RemoveAll(Anope::string& in, const Anope::string& unwanted)
{ {
for (const auto *priv : privs) auto it = std::remove_if(in.begin(), in.end(), [&](char c){
return unwanted.find_first_of(c) != unwanted.npos;
});
in.erase(it, in.end());
}
static bool RemoveFirstOccurrence(Anope::string& in, char c)
{
auto pos = in.find(c);
if (pos != Anope::string::npos)
{ {
auto pos = in.find(flag); in.erase(pos, 1);
if (pos != Anope::string::npos) return true;
}
return false;
}
bool ApplyAccess(Anope::string &in, char flag, Anope::string &out, std::initializer_list<const char*> privs)
{
const bool flag_found = RemoveFirstOccurrence(in, flag);
if (flag_found)
{
for (const auto *priv : privs)
{ {
auto privchar = flags.find(priv); auto privchar = flags.find(priv);
if (privchar != flags.end()) if (privchar != flags.end())
{ {
out.push_back(privchar->second); out.push_back(privchar->second);
in.erase(pos, 1);
} }
} }
} }
return flag_found;
} }
void ApplyFlags(Extensible *ext, Anope::string &flags, char flag, const char *extname, bool extend = true) void ApplyFlags(Extensible *ext, Anope::string &flags, char flag, const char *extname, bool extend = true)
@@ -609,16 +666,17 @@ private:
return false; return false;
} }
auto *data = chandata.Require(ci);
auto *nc = NickCore::Find(mask); auto *nc = NickCore::Find(mask);
if (flags.find('b') != Anope::string::npos) if (flags.find('b') != Anope::string::npos)
{ {
if (ChanServ::akick_service) if (!ChanServ::akick_service)
{ {
Log(this) << "Unable to import channel akick for " << ci->name << " as cs_akick is not loaded"; Log(this) << "Unable to import channel akick for " << ci->name << " as cs_akick is not loaded";
return true; return true;
} }
auto *data = chandata.Require(ci);
if (nc) if (nc)
data->akicks[mask] = ChanServ::akick_service->AddAKick(ci, setter, nc, "", modifiedtime, modifiedtime); data->akicks[mask] = ChanServ::akick_service->AddAKick(ci, setter, nc, "", modifiedtime, modifiedtime);
else else
@@ -638,7 +696,6 @@ private:
ApplyAccess(flags, 'a', accessflags, { "AUTOPROTECT", "PROTECT", "PROTECTME" }); ApplyAccess(flags, 'a', accessflags, { "AUTOPROTECT", "PROTECT", "PROTECTME" });
ApplyAccess(flags, 'e', accessflags, { "GETKEY", "NOKICK", "UNBANME" }); ApplyAccess(flags, 'e', accessflags, { "GETKEY", "NOKICK", "UNBANME" });
ApplyAccess(flags, 'f', accessflags, { "ACCESS_CHANGE" }); ApplyAccess(flags, 'f', accessflags, { "ACCESS_CHANGE" });
ApplyAccess(flags, 'F', accessflags, { "FOUNDER" });
ApplyAccess(flags, 'H', accessflags, { "AUTOHALFOP" }); ApplyAccess(flags, 'H', accessflags, { "AUTOHALFOP" });
ApplyAccess(flags, 'h', accessflags, { "HALFOP", "HALFOPME" }); ApplyAccess(flags, 'h', accessflags, { "HALFOP", "HALFOPME" });
ApplyAccess(flags, 'i', accessflags, { "INVITE" }); ApplyAccess(flags, 'i', accessflags, { "INVITE" });
@@ -662,6 +719,35 @@ private:
ci->AddAccess(access); ci->AddAccess(access);
} }
// Atheme allows multiple founders and picks a successor based on rank if one is not explicitly assigned.
bool is_founder_candidate = RemoveFirstOccurrence(flags, 'F');
RemoveAll(flags, "SR");
FounderSuccessorCandidate current_candidate(nc, originalflags, modifiedtime);
if (nc && current_candidate < data->successor_candidate)
{
if (is_founder_candidate && current_candidate < data->founder_candidate)
{
Log(LOG_DEBUG) << ci->name << ": Demoting founder candidate ("
<< ( data->founder_candidate.nc ? data->founder_candidate.nc->display : "NONE" )
<< ", " << data->founder_candidate.priority
<< ") to successor; replacing with (" << current_candidate.nc->display
<< ", " << current_candidate.priority << ")";
data->successor_candidate = data->founder_candidate;
data->founder_candidate = current_candidate;
}
else
{
Log(LOG_DEBUG) << ci->name << ": Replacing successor candidate ("
<< ( data->successor_candidate.nc ? data->successor_candidate.nc->display : "NONE" )
<< ", " << data->successor_candidate.priority
<< ") with (" << current_candidate.nc->display
<< ", " << current_candidate.priority << ")";
data->successor_candidate = current_candidate;
}
}
if (flags != "+") if (flags != "+")
Log(this) << "Unable to convert channel access flags " << flags << " for " << mask << " on " << ci->name; Log(this) << "Unable to convert channel access flags " << flags << " for " << mask << " on " << ci->name;
@@ -788,7 +874,7 @@ private:
return true; return true;
} }
auto *xl = new XLine(user + "@" + host, setby, settime + duration, reason); auto *xl = new XLine(user + "@" + host, setby, duration ? settime + duration : 0, reason);
xl->id = id; xl->id = id;
sglinemgr->AddXLine(xl); sglinemgr->AddXLine(xl);
return true; return true;
@@ -879,6 +965,7 @@ private:
ci->last_used = used; ci->last_used = used;
// No equivalent: elnv // No equivalent: elnv
RemoveFirstOccurrence(flags, 'v'); // verbose, com
ApplyFlags(ci, flags, 'h', "CS_NO_EXPIRE"); ApplyFlags(ci, flags, 'h', "CS_NO_EXPIRE");
ApplyFlags(ci, flags, 'k', "KEEPTOPIC"); ApplyFlags(ci, flags, 'k', "KEEPTOPIC");
ApplyFlags(ci, flags, 'o', "NOAUTOOP"); ApplyFlags(ci, flags, 'o', "NOAUTOOP");
@@ -985,6 +1072,10 @@ private:
if (akick != data->akicks.end()) if (akick != data->akicks.end())
akick->second->reason = value; akick->second->reason = value;
} }
else if (key == "expires")
{
Log(this) << "Unable to set access expiration for " << mask << " on " << ci->name << ": unimplemented";
}
else else
Log(this) << "Unknown channel access metadata for " << mask << " on " << ci->name << ": " << key << " = " << value; Log(this) << "Unknown channel access metadata for " << mask << " on " << ci->name << ": " << key << " = " << value;
@@ -1146,10 +1237,7 @@ private:
// MDU <display> <key> <value> // MDU <display> <key> <value>
auto display = row.Get(); auto display = row.Get();
auto key = row.Get(); auto key = row.Get();
auto value = row.GetRemaining(); auto value = row.GetRemaining(true);
if (!row)
return row.LogError(this);
auto *nc = NickCore::Find(display); auto *nc = NickCore::Find(display);
if (!nc) if (!nc)
@@ -1160,7 +1248,17 @@ private:
auto *data = userdata.Require(nc); auto *data = userdata.Require(nc);
if (key == "private:autojoin") if (key == "private:autojoin")
return true; // TODO {
commasepstream autojoins(value, true);
for (Anope::string autojoin; autojoins.GetToken(autojoin); )
{
spacesepstream entry(autojoin);
Anope::string cname, ckey;
if (entry.GetToken(cname))
entry.GetToken(ckey);
data->ajoins[cname] = ckey;
}
}
else if (key == "private:doenforce") else if (key == "private:doenforce")
data->protect = true; data->protect = true;
else if (key == "private:enforcetime") else if (key == "private:enforcetime")
@@ -1189,6 +1287,12 @@ private:
data->info_adder = value; data->info_adder = value;
else if (key == "private:mark:timestamp") else if (key == "private:mark:timestamp")
data->info_ts = Anope::Convert<time_t>(value, 0); data->info_ts = Anope::Convert<time_t>(value, 0);
else if (key == "private:sendpass:sender")
return HandleIgnoreMetadata(nc->display, key, value);
else if (key == "private:sendpass:timestamp")
return HandleIgnoreMetadata(nc->display, key, value);
else if (key == "private:setpass:key")
return HandleIgnoreMetadata(nc->display, key, value);
else if (key == "private:swhois") else if (key == "private:swhois")
return HandleIgnoreMetadata(nc->display, key, value); return HandleIgnoreMetadata(nc->display, key, value);
else if (key == "private:usercloak") else if (key == "private:usercloak")
@@ -1410,6 +1514,7 @@ private:
ApplyPassword(nc, flags, pass); ApplyPassword(nc, flags, pass);
// No equivalent: bglmNQrS // No equivalent: bglmNQrS
RemoveFirstOccurrence(flags, 'b'); // nick b flag is ephemeral, ignore
ApplyFlags(nc, flags, 'E', "PROTECT"); ApplyFlags(nc, flags, 'E', "PROTECT");
ApplyFlags(nc, flags, 'e', "MEMO_MAIL"); ApplyFlags(nc, flags, 'e', "MEMO_MAIL");
ApplyFlags(nc, flags, 'n', "NEVEROP"); ApplyFlags(nc, flags, 'n', "NEVEROP");
@@ -1499,7 +1604,7 @@ private:
return true; return true;
} }
auto *xl = new XLine(nick, setby, settime + duration, reason); auto *xl = new XLine(nick, setby, duration ? settime + duration : 0, reason);
xl->id = id; xl->id = id;
sqlinemgr->AddXLine(xl); sqlinemgr->AddXLine(xl);
return true; return true;
@@ -1561,7 +1666,7 @@ private:
return true; return true;
} }
auto *xl = new XLine(real, setby, settime + duration, reason); auto *xl = new XLine(real, setby, duration ? settime + duration : 0, reason);
xl->id = id; xl->id = id;
snlinemgr->AddXLine(xl); snlinemgr->AddXLine(xl);
return true; return true;
@@ -1584,9 +1689,8 @@ public:
const auto &modconf = conf.GetModule(this); const auto &modconf = conf.GetModule(this);
csmiscdata.clear(); csmiscdata.clear();
for (auto idx = 0; idx < modconf.CountBlock("cs_set_misc"); ++idx) for (const auto &[_, data] : modconf.GetBlocks("cs_set_misc"))
{ {
const auto &data = modconf.GetBlock("cs_set_misc", idx);
const auto &anope = data.Get<const Anope::string>("anope"); const auto &anope = data.Get<const Anope::string>("anope");
const auto &atheme = data.Get<const Anope::string>("atheme"); const auto &atheme = data.Get<const Anope::string>("atheme");
if (!anope.empty() && !atheme.empty()) if (!anope.empty() && !atheme.empty())
@@ -1594,9 +1698,8 @@ public:
} }
nsmiscdata.clear(); nsmiscdata.clear();
for (auto idx = 0; idx < modconf.CountBlock("ns_set_misc"); ++idx) for (const auto &[_, data] : modconf.GetBlocks("ns_set_misc"))
{ {
const auto &data = modconf.GetBlock("ns_set_misc", idx);
const auto &anope = data.Get<const Anope::string>("anope"); const auto &anope = data.Get<const Anope::string>("anope");
const auto &atheme = data.Get<const Anope::string>("atheme"); const auto &atheme = data.Get<const Anope::string>("atheme");
if (!anope.empty() && !atheme.empty()) if (!anope.empty() && !atheme.empty())
@@ -1604,9 +1707,8 @@ public:
} }
flags.clear(); flags.clear();
for (int i = 0; i < Config->CountBlock("privilege"); ++i) for (const auto &[_, priv] : conf.GetBlocks("privilege"))
{ {
const auto &priv = Config->GetBlock("privilege", i);
const Anope::string &name = priv.Get<const Anope::string>("name"); const Anope::string &name = priv.Get<const Anope::string>("name");
const Anope::string &value = priv.Get<const Anope::string>("flag"); const Anope::string &value = priv.Get<const Anope::string>("flag");
if (!name.empty() && !value.empty()) if (!name.empty() && !value.empty())
@@ -1684,6 +1786,12 @@ public:
si.when = data->suspend_ts; si.when = data->suspend_ts;
ci->Extend("CS_SUSPENDED", si); ci->Extend("CS_SUSPENDED", si);
} }
if (data->founder_candidate.nc)
ci->SetFounder(data->founder_candidate.nc);
if (data->successor_candidate.nc)
ci->SetSuccessor(data->successor_candidate.nc);
} }
for (const auto &[_, nc] : *NickCoreList) for (const auto &[_, nc] : *NickCoreList)
@@ -1692,6 +1800,55 @@ public:
if (!data) if (!data)
continue; continue;
if (!data->ajoins.empty())
{
auto *channels = nc->Require<AJoinList>(NICKSERV_AJOIN_LIST_EXT);
if (channels)
{
for (const auto& ajoin : data->ajoins)
{
auto &channel = ajoin.first, &key = ajoin.second;
if (!key.empty())
{
Channel *c = Channel::Find(channel);
Anope::string k;
if (c && c->GetParam("KEY", k) && key != k)
{
Log(this) << "Skipping ajoin with incorrect key for channel " << channel
<< ", user " << nc->display;
continue;
}
}
if (!IRCD->IsChannelValid(channel))
{
Log(this) << "Invalid ajoin channel " << channel << " for " << nc->display;
}
else
{
const auto it = std::find_if((*channels)->cbegin(), (*channels)->cend(), [&](const AJoinEntry* a){
return a->channel == channel;
});
if (it != (*channels)->cend())
{
Log(this) << "Skipping duplicate ajoin channel" << channel << " for " << nc->display;
continue;
}
auto* entry = new AJoinEntry(nc);
entry->owner = nc;
entry->channel = channel;
entry->key = key;
(*channels)->push_back(entry); // ignore ajoinmax for non-disruptive migration
}
}
}
else
{
Log(this) << "Unable to convert autojoins for " << nc->display << " as ns_ajoin is not loaded";
}
}
if (!data->info_message.empty()) if (!data->info_message.empty())
{ {
auto *oil = nc->Require<OperInfoList>("operinfo"); auto *oil = nc->Require<OperInfoList>("operinfo");
+14 -1
View File
@@ -12,10 +12,14 @@
// //
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/// BEGIN CMAKE
/// target_link_libraries(${SO} PRIVATE "vendored_yyjson")
/// END CMAKE
#include <filesystem> #include <filesystem>
namespace fs = std::filesystem; namespace fs = std::filesystem;
#include "yyjson/yyjson.c" #include "yyjson/yyjson.h"
#include "module.h" #include "module.h"
@@ -412,9 +416,18 @@ public:
// Step 2: store the new data. // Step 2: store the new data.
for (auto *item : Serializable::GetItems()) for (auto *item : Serializable::GetItems())
{ {
if (!item->ShouldCommit())
{
Log(LOG_DEBUG) << "Not committing dead " << item->GetSerializableName() << " object: " << item;
continue; // Non-committable object.
}
auto *s_type = item->GetSerializableType(); auto *s_type = item->GetSerializableType();
if (!s_type) if (!s_type)
{
Log(LOG_DEBUG) << "Not committing orphaned " << item->GetSerializableName() << " object: " << item;
continue; // Provider has been unloaded. continue; // Provider has been unloaded.
}
// This should always be found because we create it in the previous step. // This should always be found because we create it in the previous step.
auto it = databases.find(s_type->GetOwner()); auto it = databases.find(s_type->GetOwner());
-648
View File
@@ -1,648 +0,0 @@
// Anope IRC Services <https://www.anope.org/>
//
// Copyright (C) 2003-2026 Anope Contributors
//
// Anope is free software. You can use, modify, and/or distribute it under the
// terms of version 2 of the GNU General Public License. See docs/LICENSE.txt
// for the complete terms of this license and docs/AUTHORS.txt for a list of
// contributors.
//
// Based on the original code of Epona by Lara
// Based on the original code of Services by Andy Church
//
// SPDX-License-Identifier: GPL-2.0-only
#include "module.h"
#include "modules/redis.h"
using namespace Redis;
class DatabaseRedis;
static DatabaseRedis *me;
class Data final
: public Serialize::Data
{
public:
Anope::unordered_map<Anope::string> data;
bool LoadInternal(const Anope::string &key, Anope::string &value) override
{
auto it = this->data.find(key);
if (it == this->data.end())
return false;
value = it->second;
return true;
}
bool StoreInternal(const Anope::string &key, const Anope::string &value) override
{
this->data[key] = value;
return true;
}
size_t Hash() const override
{
size_t hash = 0;
for (const auto &[_, value] : this->data)
if (!value.empty())
hash ^= Anope::hash_cs()(value);
return hash;
}
};
class TypeLoader final
: public Interface
{
Anope::string type;
public:
TypeLoader(Module *creator, const Anope::string &t) : Interface(creator), type(t) { }
void OnResult(const Reply &r) override;
};
class ObjectLoader final
: public Interface
{
Anope::string type;
int64_t id;
public:
ObjectLoader(Module *creator, const Anope::string &t, int64_t i) : Interface(creator), type(t), id(i) { }
void OnResult(const Reply &r) override;
};
class IDInterface final
: public Interface
{
Reference<Serializable> o;
public:
IDInterface(Module *creator, Serializable *obj) : Interface(creator), o(obj) { }
void OnResult(const Reply &r) override;
};
class Deleter final
: public Interface
{
Anope::string type;
int64_t id;
public:
Deleter(Module *creator, const Anope::string &t, int64_t i) : Interface(creator), type(t), id(i) { }
void OnResult(const Reply &r) override;
};
class Updater final
: public Interface
{
Anope::string type;
int64_t id;
public:
Updater(Module *creator, const Anope::string &t, int64_t i) : Interface(creator), type(t), id(i) { }
void OnResult(const Reply &r) override;
};
class ModifiedObject final
: public Interface
{
Anope::string type;
int64_t id;
public:
ModifiedObject(Module *creator, const Anope::string &t, int64_t i) : Interface(creator), type(t), id(i) { }
void OnResult(const Reply &r) override;
};
class SubscriptionListener final
: public Interface
{
public:
SubscriptionListener(Module *creator) : Interface(creator) { }
void OnResult(const Reply &r) override;
};
class DatabaseRedis final
: public Module
, public Pipe
{
SubscriptionListener sl;
std::set<Serializable *> updated_items;
public:
ServiceReference<Provider> redis;
DatabaseRedis(const Anope::string &modname, const Anope::string &creator)
: Module(modname, creator, DATABASE | VENDOR)
, sl(this)
, redis("Redis::Provider")
{
me = this;
}
/* Insert or update an object */
void InsertObject(Serializable *obj)
{
Serialize::Type *t = obj->GetSerializableType();
/* If there is no id yet for this object, get one */
if (!obj->object_id)
redis->SendCommand(new IDInterface(this, obj), "INCR id:" + t->GetName());
else
{
Data data;
t->Serialize(obj, data);
if (obj->IsCached(data))
return;
obj->UpdateCache(data);
std::vector<Anope::string> args;
args.emplace_back("HGETALL");
args.push_back("hash:" + t->GetName() + ":" + Anope::ToString(obj->object_id));
/* Get object attrs to clear before updating */
redis->SendCommand(new Updater(this, t->GetName(), obj->object_id), args);
}
}
void OnNotify() override
{
for (auto *obj : this->updated_items)
{
this->InsertObject(obj);
}
this->updated_items.clear();
}
void OnReload(Configuration::Conf &conf) override
{
const auto &block = conf.GetModule(this);
this->redis.SetServiceName(block.Get<const Anope::string>("engine", "redis/main"));
}
EventReturn OnLoadDatabase() override
{
if (!redis)
{
Log(this) << "Unable to load database - unable to find redis provider";
return EVENT_CONTINUE;
}
for (const auto &type_order : Serialize::Type::GetTypeOrder())
{
Serialize::Type *sb = Serialize::Type::Find(type_order);
this->OnSerializeTypeCreate(sb);
}
while (!redis->IsSocketDead() && redis->BlockAndProcess());
if (redis->IsSocketDead())
{
Log(this) << "I/O error while loading redis database - is it online?";
return EVENT_CONTINUE;
}
redis->Subscribe(&this->sl, "__keyspace@*__:hash:*");
return EVENT_STOP;
}
void OnSerializeTypeCreate(Serialize::Type *sb) override
{
if (!redis)
return;
std::vector<Anope::string> args;
args.emplace_back("SMEMBERS");
args.push_back("ids:" + sb->GetName());
redis->SendCommand(new TypeLoader(this, sb->GetName()), args);
}
void OnSerializableConstruct(Serializable *obj) override
{
this->updated_items.insert(obj);
this->Notify();
}
void OnSerializableDestruct(Serializable *obj) override
{
Serialize::Type *t = obj->GetSerializableType();
if (t == NULL)
{
/* This is probably the module providing the type unloading.
*
* The types get registered after the extensible container is
* registered so that unserialization on module load can insert
* into the extensible container. So, the type destructs prior to
* the extensible container, which then triggers this
*/
return;
}
std::vector<Anope::string> args;
args.emplace_back("HGETALL");
args.push_back("hash:" + t->GetName() + ":" + Anope::ToString(obj->object_id));
/* Get all of the attributes for this object */
redis->SendCommand(new Deleter(this, t->GetName(), obj->object_id), args);
this->updated_items.erase(obj);
t->objects.erase(obj->object_id);
this->Notify();
}
void OnSerializableUpdate(Serializable *obj) override
{
this->updated_items.insert(obj);
this->Notify();
}
};
void TypeLoader::OnResult(const Reply &r)
{
if (r.type != Reply::MULTI_BULK || !me->redis)
{
delete this;
return;
}
for (auto *reply : r.multi_bulk)
{
if (reply->type != Reply::BULK)
continue;
auto i = Anope::TryConvert<int64_t>(reply->bulk);
if (!i)
continue;
auto id = i.value();
std::vector<Anope::string> args;
args.emplace_back("HGETALL");
args.push_back("hash:" + this->type + ":" + Anope::ToString(id));
me->redis->SendCommand(new ObjectLoader(me, this->type, id), args);
}
delete this;
}
void ObjectLoader::OnResult(const Reply &r)
{
Serialize::Type *st = Serialize::Type::Find(this->type);
if (r.type != Reply::MULTI_BULK || r.multi_bulk.empty() || !me->redis || !st)
{
delete this;
return;
}
Data data;
for (unsigned i = 0; i + 1 < r.multi_bulk.size(); i += 2)
{
const Reply *key = r.multi_bulk[i],
*value = r.multi_bulk[i + 1];
data.StoreInternal(key->bulk, value->bulk);
}
Serializable *&obj = st->objects[this->id];
obj = st->Unserialize(obj, data);
if (obj)
{
obj->object_id = this->id;
obj->UpdateCache(data);
}
delete this;
}
void IDInterface::OnResult(const Reply &r)
{
if (!o || r.type != Reply::INT || !r.i)
{
delete this;
return;
}
Serializable *&obj = o->GetSerializableType()->objects[r.i];
if (obj)
/* This shouldn't be possible */
obj->object_id = 0;
o->object_id = r.i;
obj = o;
/* Now that we have the id, insert this object for real */
anope_dynamic_static_cast<DatabaseRedis *>(this->owner)->InsertObject(o);
delete this;
}
void Deleter::OnResult(const Reply &r)
{
if (r.type != Reply::MULTI_BULK || !me->redis || r.multi_bulk.empty())
{
delete this;
return;
}
/* Transaction start */
me->redis->StartTransaction();
std::vector<Anope::string> args;
args.emplace_back("DEL");
args.push_back("hash:" + this->type + ":" + Anope::ToString(this->id));
/* Delete hash object */
me->redis->SendCommand(NULL, args);
args.clear();
args.emplace_back("SREM");
args.push_back("ids:" + this->type);
args.push_back(Anope::ToString(this->id));
/* Delete id from ids set */
me->redis->SendCommand(NULL, args);
for (unsigned i = 0; i + 1 < r.multi_bulk.size(); i += 2)
{
const Reply *key = r.multi_bulk[i],
*value = r.multi_bulk[i + 1];
args.clear();
args.emplace_back("SREM");
args.push_back("value:" + this->type + ":" + key->bulk + ":" + value->bulk);
args.push_back(Anope::ToString(this->id));
/* Delete value -> object id */
me->redis->SendCommand(NULL, args);
}
/* Transaction end */
me->redis->CommitTransaction();
delete this;
}
void Updater::OnResult(const Reply &r)
{
Serialize::Type *st = Serialize::Type::Find(this->type);
if (!st)
{
delete this;
return;
}
Serializable *obj = st->objects[this->id];
if (!obj)
{
delete this;
return;
}
Data data;
st->Serialize(obj, data);
/* Transaction start */
me->redis->StartTransaction();
for (unsigned i = 0; i + 1 < r.multi_bulk.size(); i += 2)
{
const Reply *key = r.multi_bulk[i],
*value = r.multi_bulk[i + 1];
std::vector<Anope::string> args;
args.emplace_back("SREM");
args.push_back("value:" + this->type + ":" + key->bulk + ":" + value->bulk);
args.push_back(Anope::ToString(this->id));
/* Delete value -> object id */
me->redis->SendCommand(NULL, args);
}
/* Add object id to id set for this type */
std::vector<Anope::string> args;
args.emplace_back("SADD");
args.push_back("ids:" + this->type);
args.push_back(Anope::ToString(obj->object_id));
me->redis->SendCommand(NULL, args);
args.clear();
args.emplace_back("HMSET");
args.push_back("hash:" + this->type + ":" + Anope::ToString(obj->object_id));
for (const auto &[key, value] : data.data)
{
args.push_back(key);
args.emplace_back(value);
std::vector<Anope::string> args2;
args2.emplace_back("SADD");
args2.push_back("value:" + this->type + ":" + key + ":" + value);
args2.push_back(Anope::ToString(obj->object_id));
/* Add to value -> object id set */
me->redis->SendCommand(NULL, args2);
}
++obj->redis_ignore;
/* Add object */
me->redis->SendCommand(NULL, args);
/* Transaction end */
me->redis->CommitTransaction();
delete this;
}
void SubscriptionListener::OnResult(const Reply &r)
{
/*
* [May 15 13:59:35.645839 2013] Debug: pmessage
* [May 15 13:59:35.645866 2013] Debug: __keyspace@*__:anope:hash:*
* [May 15 13:59:35.645880 2013] Debug: __keyspace@0__:anope:hash:type:id
* [May 15 13:59:35.645893 2013] Debug: hset
*/
if (r.multi_bulk.size() != 4)
return;
size_t sz = r.multi_bulk[2]->bulk.find(':');
if (sz == Anope::string::npos)
return;
const Anope::string &key = r.multi_bulk[2]->bulk.substr(sz + 1),
&op = r.multi_bulk[3]->bulk;
sz = key.rfind(':');
if (sz == Anope::string::npos)
return;
const Anope::string &id = key.substr(sz + 1);
size_t sz2 = key.rfind(':', sz - 1);
if (sz2 == Anope::string::npos)
return;
const Anope::string &type = key.substr(sz2 + 1, sz - sz2 - 1);
Serialize::Type *s_type = Serialize::Type::Find(type);
if (s_type == NULL)
return;
auto oid = Anope::TryConvert<Serializable::Id>(id);
if (!oid.has_value())
return;
auto obj_id = oid.value();
if (op == "hset" || op == "hdel")
{
Serializable *s = s_type->objects[obj_id];
if (s && s->redis_ignore)
{
--s->redis_ignore;
Log(LOG_DEBUG) << "redis: notify: got modify for object id " << obj_id << " of type " << type << ", but I am ignoring it";
}
else
{
Log(LOG_DEBUG) << "redis: notify: got modify for object id " << obj_id << " of type " << type;
std::vector<Anope::string> args;
args.emplace_back("HGETALL");
args.push_back("hash:" + type + ":" + id);
me->redis->SendCommand(new ModifiedObject(me, type, obj_id), args);
}
}
else if (op == "del")
{
Serializable *&s = s_type->objects[obj_id];
if (s == NULL)
return;
Log(LOG_DEBUG) << "redis: notify: deleting object id " << obj_id << " of type " << type;
Data data;
s_type->Serialize(s, data);
/* Transaction start */
me->redis->StartTransaction();
for (const auto &[k, value] : data.data)
{
std::vector<Anope::string> args;
args.emplace_back("SREM");
args.push_back("value:" + type + ":" + k + ":" + value);
args.push_back(id);
/* Delete value -> object id */
me->redis->SendCommand(NULL, args);
}
std::vector<Anope::string> args;
args.emplace_back("SREM");
args.push_back("ids:" + type);
args.push_back(Anope::ToString(s->object_id));
/* Delete object from id set */
me->redis->SendCommand(NULL, args);
/* Transaction end */
me->redis->CommitTransaction();
delete s;
s = NULL;
}
}
void ModifiedObject::OnResult(const Reply &r)
{
Serialize::Type *st = Serialize::Type::Find(this->type);
if (!st)
{
delete this;
return;
}
Serializable *&obj = st->objects[this->id];
/* Transaction start */
me->redis->StartTransaction();
/* Erase old object values */
if (obj)
{
Data data;
st->Serialize(obj, data);
for (auto &[key, value] : data.data)
{
std::vector<Anope::string> args;
args.emplace_back("SREM");
args.push_back("value:" + st->GetName() + ":" + key + ":" + value);
args.push_back(Anope::ToString(this->id));
/* Delete value -> object id */
me->redis->SendCommand(NULL, args);
}
}
Data data;
for (unsigned i = 0; i + 1 < r.multi_bulk.size(); i += 2)
{
const Reply *key = r.multi_bulk[i],
*value = r.multi_bulk[i + 1];
data.StoreInternal(key->bulk, value->bulk);
}
obj = st->Unserialize(obj, data);
if (obj)
{
obj->object_id = this->id;
obj->UpdateCache(data);
/* Insert new object values */
for (const auto &[key, value] : data.data)
{
std::vector<Anope::string> args;
args.emplace_back("SADD");
args.push_back("value:" + st->GetName() + ":" + key + ":" + value);
args.push_back(Anope::ToString(obj->object_id));
/* Add to value -> object id set */
me->redis->SendCommand(NULL, args);
}
std::vector<Anope::string> args;
args.emplace_back("SADD");
args.push_back("ids:" + st->GetName());
args.push_back(Anope::ToString(obj->object_id));
/* Add to type -> id set */
me->redis->SendCommand(NULL, args);
}
/* Transaction end */
me->redis->CommitTransaction();
delete this;
}
MODULE_INIT(DatabaseRedis)
+7 -1
View File
@@ -120,6 +120,12 @@ public:
{ {
if (this->sql) if (this->sql)
{ {
if (!obj->ShouldCommit())
{
OnSerializableDestruct(obj);
continue; // Non-committable object.
}
Serialize::Type *s_type = obj->GetSerializableType(); Serialize::Type *s_type = obj->GetSerializableType();
if (!s_type) if (!s_type)
continue; continue;
@@ -168,7 +174,7 @@ public:
{ {
const auto &block = conf.GetModule(this); const auto &block = conf.GetModule(this);
this->sql.SetServiceName(block.Get<const Anope::string>("engine")); this->sql.SetServiceName(block.Get<const Anope::string>("engine"));
this->prefix = block.Get<const Anope::string>("prefix", "anope_db_"); this->prefix = block.Get<const Anope::string>("prefix", "anope21_");
this->import = block.Get<bool>("import"); this->import = block.Get<bool>("import");
} }
+7 -1
View File
@@ -104,6 +104,12 @@ public:
{ {
if (obj && this->SQL) if (obj && this->SQL)
{ {
if (!obj->ShouldCommit())
{
OnSerializableDestruct(obj);
continue; // Non-committable object.
}
Serialize::Type *s_type = obj->GetSerializableType(); Serialize::Type *s_type = obj->GetSerializableType();
if (!s_type) if (!s_type)
continue; continue;
@@ -152,7 +158,7 @@ public:
const auto &block = conf.GetModule(this); const auto &block = conf.GetModule(this);
this->SQL.SetServiceName(block.Get<const Anope::string>("engine")); this->SQL.SetServiceName(block.Get<const Anope::string>("engine"));
this->prefix = block.Get<const Anope::string>("prefix", "anope_db_"); this->prefix = block.Get<const Anope::string>("prefix", "anope21_");
} }
void OnSerializableConstruct(Serializable *obj) override void OnSerializableConstruct(Serializable *obj) override
+6 -5
View File
@@ -534,8 +534,9 @@ public:
} }
/* Times out after a few seconds */ /* Times out after a few seconds */
void Tick() override bool Tick() override
{ {
return false;
} }
void Reply(Packet *p) override void Reply(Packet *p) override
@@ -718,7 +719,7 @@ public:
MyManager(Module *creator) MyManager(Module *creator)
: Manager(creator) : Manager(creator)
, Timer(300, true) , Timer(300)
, serial(Anope::CurTime) , serial(Anope::CurTime)
, cur_id(Anope::RandomNumber()) , cur_id(Anope::RandomNumber())
{ {
@@ -1011,7 +1012,7 @@ public:
return serial; return serial;
} }
void Tick() override bool Tick() override
{ {
Log(LOG_DEBUG_2) << "Resolver: Purging DNS cache"; Log(LOG_DEBUG_2) << "Resolver: Purging DNS cache";
@@ -1025,6 +1026,7 @@ public:
if (req.created + static_cast<time_t>(req.ttl) < Anope::CurTime) if (req.created + static_cast<time_t>(req.ttl) < Anope::CurTime)
this->cache.erase(it); this->cache.erase(it);
} }
return true;
} }
private: private:
@@ -1093,9 +1095,8 @@ public:
refresh = block.Get<int>("refresh", "3600"); refresh = block.Get<int>("refresh", "3600");
std::vector<std::pair<Anope::string, short> > notify; std::vector<std::pair<Anope::string, short> > notify;
for (int i = 0; i < block.CountBlock("notify"); ++i) for (const auto &[_, n] : block.GetBlocks("notify"))
{ {
const auto &n = block.GetBlock("notify", i);
auto nip = n.Get<Anope::string>("ip"); auto nip = n.Get<Anope::string>("ip");
auto nport = n.Get<short>("port"); auto nport = n.Get<short>("port");
+3 -6
View File
@@ -126,9 +126,8 @@ public:
this->add_to_akill = block.Get<bool>("add_to_akill", "yes"); this->add_to_akill = block.Get<bool>("add_to_akill", "yes");
this->blacklists.clear(); this->blacklists.clear();
for (int i = 0; i < block.CountBlock("blacklist"); ++i) for (const auto &[_, bl] : block.GetBlocks("blacklist"))
{ {
const auto &bl = block.GetBlock("blacklist", i);
Blacklist blacklist; Blacklist blacklist;
blacklist.name = bl.Get<Anope::string>("name"); blacklist.name = bl.Get<Anope::string>("name");
@@ -137,9 +136,8 @@ public:
blacklist.bantime = bl.Get<time_t>("time", "4h"); blacklist.bantime = bl.Get<time_t>("time", "4h");
blacklist.reason = bl.Get<Anope::string>("reason"); blacklist.reason = bl.Get<Anope::string>("reason");
for (int j = 0; j < bl.CountBlock("reply"); ++j) for (const auto &[_, reply] : block.GetBlocks("reply"))
{ {
const auto &reply = bl.GetBlock("reply", j);
Blacklist::Reply r; Blacklist::Reply r;
r.code = reply.Get<int>("code"); r.code = reply.Get<int>("code");
@@ -153,9 +151,8 @@ public:
} }
this->exempts.clear(); this->exempts.clear();
for (int i = 0; i < block.CountBlock("exempt"); ++i) for (const auto &[_, bl] : block.GetBlocks("exempt"))
{ {
const auto &bl = block.GetBlock("exempt", i);
this->exempts.insert(bl.Get<Anope::string>("ip")); this->exempts.insert(bl.Get<Anope::string>("ip"));
} }
} }
+8 -1
View File
@@ -12,10 +12,17 @@
// //
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/// BEGIN CMAKE
/// target_link_libraries(${SO} PRIVATE "vendored_bcrypt")
/// END CMAKE
#include <climits> #include <climits>
#include <random> #include <random>
#include "bcrypt/crypt_blowfish.c" extern "C"
{
#include "bcrypt/crypt_blowfish.h"
}
#include "module.h" #include "module.h"
#include "modules/encryption.h" #include "modules/encryption.h"
+8 -1
View File
@@ -12,10 +12,17 @@
// //
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/// BEGIN CMAKE
/// target_link_libraries(${SO} PRIVATE "vendored_md5")
/// END CMAKE
#include "module.h" #include "module.h"
#include "modules/encryption.h" #include "modules/encryption.h"
#include "md5/md5.c" extern "C"
{
#include "md5/md5.h"
}
class MD5Context final class MD5Context final
: public Encryption::Context : public Encryption::Context
+5 -1
View File
@@ -12,10 +12,14 @@
// //
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/// BEGIN CMAKE
/// target_link_libraries(${SO} PRIVATE "vendored_sha1")
/// END CMAKE
#include "module.h" #include "module.h"
#include "modules/encryption.h" #include "modules/encryption.h"
#include "sha1/sha1.c" #include "sha1/sha1.h"
class SHA1Context final class SHA1Context final
: public Encryption::Context : public Encryption::Context
+5 -1
View File
@@ -12,10 +12,14 @@
// //
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/// BEGIN CMAKE
/// target_link_libraries(${SO} PRIVATE "vendored_sha2")
/// END CMAKE
#include <climits> #include <climits>
#include <random> #include <random>
#include "sha2/sha2.c" #include "sha2/sha2.h"
#include "module.h" #include "module.h"
#include "modules/encryption.h" #include "modules/encryption.h"
+76 -4
View File
@@ -405,6 +405,80 @@ public:
QueueRequest(mod); QueueRequest(mod);
} }
Anope::string EscapeDN(const Anope::string &str) const override
{
if (str.empty())
return str;
Anope::string newstr;
newstr.str().reserve(str.length());
for (size_t idx = 0; idx < str.length(); ++idx)
{
const char chr = str[idx];
if (chr == '\0')
{
newstr.append("\\00");
}
else if (chr == '"' || chr == '+' || chr == ',' || chr == ';' ||
chr == '<' || chr == '=' || chr == '>' || chr == '\\')
{
newstr.push_back('\\');
newstr.push_back(chr);
}
else if (idx == 0 && (chr == '#' || chr == ' '))
{
newstr.push_back('\\');
newstr.push_back(chr);
}
else if (idx == str.length() - 1 && chr == ' ')
{
newstr.push_back('\\');
newstr.push_back(chr);
}
else
{
newstr.push_back(chr);
}
}
return newstr;
}
Anope::string EscapeSF(const Anope::string &str) const override
{
if (str.empty())
return str;
Anope::string newstr;
newstr.str().reserve(str.length());
for (size_t idx = 0; idx < str.length(); ++idx)
{
const char chr = str[idx];
switch (chr)
{
case '\0':
newstr.append("\\00");
break;
case '(':
newstr.append("\\28");
break;
case ')':
newstr.append("\\29");
break;
case '*':
newstr.append("\\2A");
break;
case '\\':
newstr.append("\\5C");
break;
default:
newstr.push_back(chr);
break;
}
}
return newstr;
}
private: private:
void BuildReply(int res, LDAPRequest *req) void BuildReply(int res, LDAPRequest *req)
{ {
@@ -560,7 +634,7 @@ public:
{ {
const Anope::string &cname = it->first; const Anope::string &cname = it->first;
LDAPService *s = it->second; LDAPService *s = it->second;
int i; size_t i;
++it; ++it;
@@ -580,10 +654,8 @@ public:
} }
} }
for (int i = 0; i < conf.CountBlock("ldap"); ++i) for (const auto &[_, ldap] : conf.GetBlocks("ldap"))
{ {
const auto &ldap = conf.GetBlock("ldap", i);
const Anope::string &connname = ldap.Get<const Anope::string>("name", "ldap/main"); const Anope::string &connname = ldap.Get<const Anope::string>("name", "ldap/main");
if (this->LDAPServices.find(connname) == this->LDAPServices.end()) if (this->LDAPServices.find(connname) == this->LDAPServices.end())
+2 -3
View File
@@ -281,7 +281,7 @@ public:
{ {
const Anope::string &cname = it->first; const Anope::string &cname = it->first;
MySQLService *s = it->second; MySQLService *s = it->second;
int i; size_t i;
++it; ++it;
@@ -298,9 +298,8 @@ public:
} }
} }
for (int i = 0; i < config.CountBlock("mysql"); ++i) for (const auto &[_, block] : config.GetBlocks("mysql"))
{ {
const auto &block = config.GetBlock("mysql", i);
const Anope::string &connname = block.Get<const Anope::string>("name", "mysql/main"); const Anope::string &connname = block.Get<const Anope::string>("name", "mysql/main");
if (this->MySQLServices.find(connname) == this->MySQLServices.end()) if (this->MySQLServices.find(connname) == this->MySQLServices.end())
+2 -3
View File
@@ -129,7 +129,7 @@ public:
{ {
const Anope::string &cname = it->first; const Anope::string &cname = it->first;
SQLiteService *s = it->second; SQLiteService *s = it->second;
int i, num; size_t i, num;
++it; ++it;
for (i = 0, num = config.CountBlock("sqlite"); i < num; ++i) for (i = 0, num = config.CountBlock("sqlite"); i < num; ++i)
@@ -145,9 +145,8 @@ public:
} }
} }
for (int i = 0; i < config.CountBlock("sqlite"); ++i) for (const auto &[_, block] : config.GetBlocks("sqlite"))
{ {
const auto &block = config.GetBlock("sqlite", i);
Anope::string connname = block.Get<const Anope::string>("name", "sqlite/main"); Anope::string connname = block.Get<const Anope::string>("name", "sqlite/main");
if (this->SQLiteServices.find(connname) == this->SQLiteServices.end()) if (this->SQLiteServices.find(connname) == this->SQLiteServices.end())
+1 -3
View File
@@ -331,10 +331,8 @@ public:
throw ConfigException("Unable to find http reference, is httpd loaded?"); throw ConfigException("Unable to find http reference, is httpd loaded?");
xmlrpcinterface.tokens.clear(); xmlrpcinterface.tokens.clear();
for (int i = 0; i < modconf.CountBlock("token"); ++i) for (const auto &[_, block] : modconf.GetBlocks("token"))
{ {
const auto &block = modconf.GetBlock("token", i);
RPC::Token token; RPC::Token token;
token.token = block.Get<const Anope::string>("token"); token.token = block.Get<const Anope::string>("token");
if (!token.token.empty()) if (!token.token.empty())
+1 -1
View File
@@ -130,7 +130,7 @@ public:
CommandGLQueue(Module *creator) CommandGLQueue(Module *creator)
: Command(creator, "global/queue", 1, 2) : Command(creator, "global/queue", 1, 2)
{ {
this->SetDesc(_("Manages your pending message queue.")); this->SetDesc(_("Manage your pending message queue."));
this->SetSyntax(_("ADD \037message\037")); this->SetSyntax(_("ADD \037message\037"));
this->SetSyntax(_("DEL \037entry-num\037")); this->SetSyntax(_("DEL \037entry-num\037"));
this->SetSyntax("LIST"); this->SetSyntax("LIST");
+6 -1
View File
@@ -156,7 +156,12 @@ public:
if (server) if (server)
this->ServerGlobal(sender, server, false, line); this->ServerGlobal(sender, server, false, line);
else else
this->ServerGlobal(sender, Servers::GetUplink(), true, line); {
auto* uplink = Servers::GetUplink();
if (!uplink)
return false;
this->ServerGlobal(sender, uplink, true, line);
}
return true; return true;
} }
+1 -1
View File
@@ -33,7 +33,7 @@ class CommandHelp final
public: public:
CommandHelp(Module *creator) : Command(creator, "generic/help", 0) CommandHelp(Module *creator) : Command(creator, "generic/help", 0)
{ {
this->SetDesc(_("Displays this list and give information about commands")); this->SetDesc(_("Display this list and give information about commands"));
this->AllowUnregistered(true); this->AllowUnregistered(true);
} }
+1 -1
View File
@@ -60,7 +60,7 @@ class CommandHSDelAll final
public: public:
CommandHSDelAll(Module *creator) : Command(creator, "hostserv/delall", 1, 1) CommandHSDelAll(Module *creator) : Command(creator, "hostserv/delall", 1, 1)
{ {
this->SetDesc(_("Deletes the vhost for all nicks in an account")); this->SetDesc(_("Delete the vhost for all nicks in an account"));
this->SetSyntax(_("\037nick\037")); this->SetSyntax(_("\037nick\037"));
} }
+1 -1
View File
@@ -42,7 +42,7 @@ public:
CommandHSGroup(Module *creator) : Command(creator, "hostserv/group", 0, 0) CommandHSGroup(Module *creator) : Command(creator, "hostserv/group", 0, 0)
{ {
this->SetDesc(_("Syncs the vhost for all nicks in an account")); this->SetDesc(_("Sync the vhost for all nicks in an account"));
} }
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
+1 -1
View File
@@ -20,7 +20,7 @@ class CommandHSList final
public: public:
CommandHSList(Module *creator) : Command(creator, "hostserv/list", 0, 1) CommandHSList(Module *creator) : Command(creator, "hostserv/list", 0, 1)
{ {
this->SetDesc(_("Displays one or more vhost entries")); this->SetDesc(_("Display one or more vhost entries"));
this->SetSyntax(_("[\037key\037|\037#X-Y\037]")); this->SetSyntax(_("[\037key\037|\037#X-Y\037]"));
} }
+1 -1
View File
@@ -20,7 +20,7 @@ class CommandHSOff final
public: public:
CommandHSOff(Module *creator) : Command(creator, "hostserv/off", 0, 0) CommandHSOff(Module *creator) : Command(creator, "hostserv/off", 0, 0)
{ {
this->SetDesc(_("Deactivates your assigned vhost")); this->SetDesc(_("Deactivate your assigned vhost"));
this->RequireUser(true); this->RequireUser(true);
} }
+2 -2
View File
@@ -669,7 +669,7 @@ public:
{ {
if (!show_all) if (!show_all)
return; return;
mask = Anope::Format(Language::Translate(source.GetAccount(), _("%s [Invalid]")), mask.c_str()); mask = Anope::Format(source.Translate(_("%s [Invalid]")), mask.c_str());
} }
ListFormatter::ListEntry entry; ListFormatter::ListEntry entry;
@@ -835,7 +835,7 @@ private:
{ {
if (!show_all) if (!show_all)
continue; continue;
mask = Anope::Format(Language::Translate(source.GetAccount(), _("%s [Invalid]")), mask.c_str()); mask = Anope::Format(source.Translate(_("%s [Invalid]")), mask.c_str());
} }
ListFormatter::ListEntry entry; ListFormatter::ListEntry entry;
+1 -1
View File
@@ -20,7 +20,7 @@ class CommandHSOn final
public: public:
CommandHSOn(Module *creator) : Command(creator, "hostserv/on", 0, 0) CommandHSOn(Module *creator) : Command(creator, "hostserv/on", 0, 0)
{ {
this->SetDesc(_("Activates your assigned vhost")); this->SetDesc(_("Activate your assigned vhost"));
this->RequireUser(true); this->RequireUser(true);
} }
+87 -22
View File
@@ -27,6 +27,29 @@ namespace
Anope::string validation_record; Anope::string validation_record;
} }
struct SharedData final
{
// How long after a requested vhost is activated does a user have to wait before they can request a new vhost.
time_t activationcooldown = 0;
// How long after a requested vhost is rejected does a user have to wait before they can request a new vhost.
time_t rejectioncooldown = 0;
// How long should users have to wait between attempts at DNS validation.
time_t validationcooldown = 0;
// Extensible that stores the time a user had a vhost activated/rejected.
SerializableExtensibleItem<time_t> requestcooldown;
// The name of the DNS record used for validation.
Anope::string validationrecord;
SharedData(Module *mod)
: requestcooldown(mod, "HS_REQUEST_COOLDOWN")
{
}
};
struct HostRequestImpl final struct HostRequestImpl final
: HostServ::HostRequest : HostServ::HostRequest
, Serializable , Serializable
@@ -105,6 +128,7 @@ private:
Command *command; Command *command;
Reference<NickAlias> nickalias; Reference<NickAlias> nickalias;
CommandSource source; CommandSource source;
SharedData &data;
void HandleError(HostRequestImpl *hr) void HandleError(HostRequestImpl *hr)
{ {
@@ -119,11 +143,12 @@ private:
} }
public: public:
DNSHostResolver(Command *cmd, HostServ::HostRequest *hr, NickAlias *na, const CommandSource &src) DNSHostResolver(Command *cmd, HostServ::HostRequest *hr, NickAlias *na, const CommandSource &src, SharedData &sd)
: Request(dnsmanager, cmd->module, hr->host, DNS::QUERY_TXT, false) : Request(dnsmanager, cmd->module, hr->host, DNS::QUERY_TXT, false)
, command(cmd) , command(cmd)
, nickalias(na) , nickalias(na)
, source(src) , source(src)
, data(sd)
{ {
hr->last_validation = Anope::CurTime; hr->last_validation = Anope::CurTime;
Log(LOG_DEBUG) << "Checking " << hr->host << " for " << hr->validation_token; Log(LOG_DEBUG) << "Checking " << hr->host << " for " << hr->validation_token;
@@ -171,6 +196,8 @@ public:
source.Reply(_("VHost for %s has been validated using DNS."), na->nick.c_str()); source.Reply(_("VHost for %s has been validated using DNS."), na->nick.c_str());
Log(LOG_COMMAND, source, command) << "for " << na->nick << " for vhost " << hr->Mask(); Log(LOG_COMMAND, source, command) << "for " << na->nick << " for vhost " << hr->Mask();
data.requestcooldown.Set(na, Anope::CurTime + data.activationcooldown);
na->Shrink<HostRequestImpl>(HOSTSERV_HOST_REQUEST_EXT); na->Shrink<HostRequestImpl>(HOSTSERV_HOST_REQUEST_EXT);
return; // We're done. return; // We're done.
@@ -183,8 +210,13 @@ public:
class CommandHSRequest final class CommandHSRequest final
: public Command : public Command
{ {
private:
SharedData &data;
public: public:
CommandHSRequest(Module *creator) : Command(creator, "hostserv/request", 1, 1) CommandHSRequest(Module *creator, SharedData &sd)
: Command(creator, "hostserv/request", 1, 1)
, data(sd)
{ {
this->SetDesc(_("Request a vhost for your nick")); this->SetDesc(_("Request a vhost for your nick"));
this->SetSyntax(_("vhost")); this->SetSyntax(_("vhost"));
@@ -263,12 +295,25 @@ public:
return; return;
} }
time_t send_delay = Config->GetModule("memoserv").Get<time_t>("senddelay"); time_t waituntil = 0;
if (Config->GetModule(this->owner).Get<bool>("memooper") && send_delay > 0 && u && u->lastmemosend + send_delay > Anope::CurTime)
{ {
auto waitperiod = (u->lastmemosend + send_delay) - Anope::CurTime; // Check whether the user is on a request cooldown.
const auto *last_req = data.requestcooldown.Get(na);
if (last_req)
waituntil = *last_req;
}
if (Config->GetModule(this->owner).Get<bool>("memooper"))
{
// Check whether the user can send a memo to opers yet.
const auto send_delay = Config->GetModule("memoserv").Get<time_t>("senddelay");
if (send_delay > 0 && u && u->lastmemosend)
waituntil = std::max(waituntil, u->lastmemosend + send_delay);
}
if (waituntil && waituntil > Anope::CurTime)
{
const auto waitperiod = waituntil - Anope::CurTime;
source.Reply(_("Please wait %s before requesting a new vhost."), Anope::Duration(waitperiod, source.GetAccount()).c_str()); source.Reply(_("Please wait %s before requesting a new vhost."), Anope::Duration(waitperiod, source.GetAccount()).c_str());
u->lastmemosend = Anope::CurTime;
return; return;
} }
@@ -319,8 +364,13 @@ public:
class CommandHSActivate final class CommandHSActivate final
: public Command : public Command
{ {
private:
SharedData &data;
public: public:
CommandHSActivate(Module *creator) : Command(creator, "hostserv/activate", 1, 1) CommandHSActivate(Module *creator, SharedData &sd)
: Command(creator, "hostserv/activate", 1, 1)
, data(sd)
{ {
this->SetDesc(_("Approve the requested vhost of a user")); this->SetDesc(_("Approve the requested vhost of a user"));
this->SetSyntax(_("\037nick\037")); this->SetSyntax(_("\037nick\037"));
@@ -348,6 +398,8 @@ public:
source.Reply(_("VHost for %s has been activated."), na->nick.c_str()); source.Reply(_("VHost for %s has been activated."), na->nick.c_str());
Log(LOG_COMMAND, source, this) << "for " << na->nick << " for vhost " << (!req->ident.empty() ? req->ident + "@" : "") << req->host; Log(LOG_COMMAND, source, this) << "for " << na->nick << " for vhost " << (!req->ident.empty() ? req->ident + "@" : "") << req->host;
data.requestcooldown.Set(na, Anope::CurTime + data.activationcooldown);
na->Shrink<HostRequestImpl>(HOSTSERV_HOST_REQUEST_EXT); na->Shrink<HostRequestImpl>(HOSTSERV_HOST_REQUEST_EXT);
} }
else else
@@ -369,8 +421,13 @@ public:
class CommandHSReject final class CommandHSReject final
: public Command : public Command
{ {
private:
SharedData &data;
public: public:
CommandHSReject(Module *creator) : Command(creator, "hostserv/reject", 1, 2) CommandHSReject(Module *creator, SharedData &sd)
: Command(creator, "hostserv/reject", 1, 2)
, data(sd)
{ {
this->SetDesc(_("Reject the requested vhost of a user")); this->SetDesc(_("Reject the requested vhost of a user"));
this->SetSyntax(_("\037nick\037 [\037reason\037]")); this->SetSyntax(_("\037nick\037 [\037reason\037]"));
@@ -391,6 +448,7 @@ public:
auto *req = HostRequestImpl::Get(na); auto *req = HostRequestImpl::Get(na);
if (req) if (req)
{ {
data.requestcooldown.Set(na, Anope::CurTime + data.rejectioncooldown);
na->Shrink<HostRequestImpl>(HOSTSERV_HOST_REQUEST_EXT); na->Shrink<HostRequestImpl>(HOSTSERV_HOST_REQUEST_EXT);
if (Config->GetModule(this->owner).Get<bool>("memouser") && MemoServ::service) if (Config->GetModule(this->owner).Get<bool>("memouser") && MemoServ::service)
@@ -401,7 +459,7 @@ public:
else else
message = _("Your requested vhost has been rejected."); message = _("Your requested vhost has been rejected.");
MemoServ::service->Send(source.service->nick, nick, Language::Translate(source.GetAccount(), message.c_str()), true); MemoServ::service->Send(source.service->nick, nick, source.Translate(message.c_str()), true);
} }
source.Reply(_("VHost for %s has been rejected."), nick.c_str()); source.Reply(_("VHost for %s has been rejected."), nick.c_str());
@@ -429,7 +487,7 @@ class CommandHSWaiting final
public: public:
CommandHSWaiting(Module *creator) : Command(creator, "hostserv/waiting", 0, 0) CommandHSWaiting(Module *creator) : Command(creator, "hostserv/waiting", 0, 0)
{ {
this->SetDesc(_("Retrieves the vhost requests")); this->SetDesc(_("Retrieve the vhost requests"));
} }
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
@@ -481,13 +539,15 @@ public:
class CommandHSValidate final class CommandHSValidate final
: public Command : public Command
{ {
public: private:
time_t cooldown; SharedData &data;
CommandHSValidate(Module *creator) public:
CommandHSValidate(Module *creator, SharedData &sd)
: Command(creator, "hostserv/validate", 0) : Command(creator, "hostserv/validate", 0)
, data(sd)
{ {
this->SetDesc(_("Validates a previously requested vhost using DNS")); this->SetDesc(_("Validate a previously requested vhost using DNS"));
} }
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
@@ -512,7 +572,7 @@ public:
return; return;
} }
auto next_validation = req->last_validation + cooldown; auto next_validation = req->last_validation + data.validationcooldown;
if (req->last_validation && next_validation > Anope::CurTime) if (req->last_validation && next_validation > Anope::CurTime)
{ {
source.Reply(_("You must wait for %s before trying DNS validation again."), source.Reply(_("You must wait for %s before trying DNS validation again."),
@@ -526,7 +586,7 @@ public:
if (!dnsmanager) if (!dnsmanager)
throw SocketException("DNS is not available"); throw SocketException("DNS is not available");
res = new DNSHostResolver(this, req, na, source); res = new DNSHostResolver(this, req, na, source, data);
dnsmanager->Process(res); dnsmanager->Process(res);
} }
catch (const SocketException &ex) catch (const SocketException &ex)
@@ -553,8 +613,10 @@ public:
class HSRequest final class HSRequest final
: public Module : public Module
{ {
private:
SharedData data;
CommandHSRequest commandhsrequest; CommandHSRequest commandhsrequest;
CommandHSActivate commandhsactive; CommandHSActivate commandhsactivate;
CommandHSReject commandhsreject; CommandHSReject commandhsreject;
CommandHSWaiting commandhswaiting; CommandHSWaiting commandhswaiting;
CommandHSValidate commandhsvalidate; CommandHSValidate commandhsvalidate;
@@ -564,11 +626,12 @@ class HSRequest final
public: public:
HSRequest(const Anope::string &modname, const Anope::string &creator) HSRequest(const Anope::string &modname, const Anope::string &creator)
: Module(modname, creator, VENDOR) : Module(modname, creator, VENDOR)
, commandhsrequest(this) , data(this)
, commandhsactive(this) , commandhsrequest(this, data)
, commandhsreject(this) , commandhsactivate(this, data)
, commandhsreject(this, data)
, commandhswaiting(this) , commandhswaiting(this)
, commandhsvalidate(this) , commandhsvalidate(this, data)
, hostrequest(this, HOSTSERV_HOST_REQUEST_EXT) , hostrequest(this, HOSTSERV_HOST_REQUEST_EXT)
{ {
if (!IRCD || !IRCD->CanSetVHost) if (!IRCD || !IRCD->CanSetVHost)
@@ -578,7 +641,9 @@ public:
void OnReload(Configuration::Conf &conf) override void OnReload(Configuration::Conf &conf) override
{ {
const auto &block = conf.GetModule(this); const auto &block = conf.GetModule(this);
commandhsvalidate.cooldown = block.Get<time_t>("validationcooldown", "5m"); data.activationcooldown = block.Get<time_t>("activationcooldown", "24h");
data.rejectioncooldown = block.Get<time_t>("rejectioncooldown", "24h");
data.validationcooldown = block.Get<time_t>("validationcooldown", "5m");
validation_record = block.Get<const Anope::string>("validationrecord", "anope-dns-validation"); validation_record = block.Get<const Anope::string>("validationrecord", "anope-dns-validation");
} }
}; };
+4 -6
View File
@@ -298,12 +298,12 @@ public:
MyHTTPProvider(Module *c, const Anope::string &n, const Anope::string &i, const unsigned short p, const int t, bool s) MyHTTPProvider(Module *c, const Anope::string &n, const Anope::string &i, const unsigned short p, const int t, bool s)
: Socket(-1, i.find(':') == Anope::string::npos ? AF_INET : AF_INET6) : Socket(-1, i.find(':') == Anope::string::npos ? AF_INET : AF_INET6)
, HTTP::Provider(c, n, i, p, s) , HTTP::Provider(c, n, i, p, s)
, Timer(c, 10, true) , Timer(c, 10)
, timeout(t) , timeout(t)
{ {
} }
void Tick() override bool Tick() override
{ {
while (!this->clients.empty()) while (!this->clients.empty())
{ {
@@ -314,6 +314,7 @@ public:
delete c; delete c;
this->clients.pop_front(); this->clients.pop_front();
} }
return true;
} }
ClientSocket *OnAccept(int fd, const sockaddrs &addr) override ClientSocket *OnAccept(int fd, const sockaddrs &addr) override
@@ -371,11 +372,8 @@ public:
const auto &conf = config.GetModule(this); const auto &conf = config.GetModule(this);
std::set<Anope::string> existing; std::set<Anope::string> existing;
for (int i = 0; i < conf.CountBlock("httpd"); ++i) for (const auto &[_, block] : conf.GetBlocks("httpd"))
{ {
const auto &block = conf.GetBlock("httpd", i);
const Anope::string &hname = block.Get<const Anope::string>("name", "httpd/main"); const Anope::string &hname = block.Get<const Anope::string>("name", "httpd/main");
existing.insert(hname); existing.insert(hname);
+3 -3
View File
@@ -92,8 +92,8 @@ public:
if (ii->admin_bind) if (ii->admin_bind)
{ {
auto sf = Anope::Template(search_filter, { auto sf = Anope::Template(search_filter, {
{ "account", ii->req->GetAccount() }, { "account", ii->lprov->EscapeSF(ii->req->GetAccount()) },
{ "object_class", object_class }, { "object_class", object_class },
}); });
try try
{ {
@@ -310,7 +310,7 @@ public:
attributes[3].name = this->password_attribute; attributes[3].name = this->password_attribute;
attributes[3].values.push_back(pass); attributes[3].values.push_back(pass);
Anope::string new_dn = username_attribute + "=" + na->nick + "," + basedn; Anope::string new_dn = username_attribute + "=" + this->ldap->EscapeDN(na->nick) + "," + basedn;
this->ldap->Add(&this->orinterface, new_dn, attributes); this->ldap->Add(&this->orinterface, new_dn, attributes);
} }
+2 -2
View File
@@ -125,13 +125,13 @@ public:
if (!this->binddn.empty()) if (!this->binddn.empty())
{ {
auto bdn = Anope::Template(this->binddn, { auto bdn = Anope::Template(this->binddn, {
{ "account", u->Account()->display }, { "account", this->ldap->EscapeDN(u->Account()->display) },
}); });
this->ldap->Bind(NULL, bdn, this->password.c_str()); this->ldap->Bind(NULL, bdn, this->password.c_str());
} }
auto af = Anope::Template(this->filter, { auto af = Anope::Template(this->filter, {
{ "account", u->Account()->display }, { "account", this->ldap->EscapeSF(u->Account()->display) },
}); });
this->ldap->Search(new IdentifyInterface(this, u), this->basedn, af); this->ldap->Search(new IdentifyInterface(this, u), this->basedn, af);
} }
+1 -1
View File
@@ -20,7 +20,7 @@ class CommandMSCheck final
public: public:
CommandMSCheck(Module *creator) : Command(creator, "memoserv/check", 1, 1) CommandMSCheck(Module *creator) : Command(creator, "memoserv/check", 1, 1)
{ {
this->SetDesc(_("Checks if last memo to a nick was read")); this->SetDesc(_("Check if last memo to a nick was read"));
this->SetSyntax(_("\037nick\037")); this->SetSyntax(_("\037nick\037"));
} }
+1 -1
View File
@@ -20,7 +20,7 @@ class CommandMSInfo final
public: public:
CommandMSInfo(Module *creator) : Command(creator, "memoserv/info", 0, 1) CommandMSInfo(Module *creator) : Command(creator, "memoserv/info", 0, 1)
{ {
this->SetDesc(_("Displays information about your memos")); this->SetDesc(_("Display information about your memos"));
this->SetSyntax(_("[\037nick\037 | \037channel\037]")); this->SetSyntax(_("[\037nick\037 | \037channel\037]"));
} }
+1 -1
View File
@@ -21,7 +21,7 @@ class CommandMSRSend final
public: public:
CommandMSRSend(Module *creator) : Command(creator, "memoserv/rsend", 2, 2) CommandMSRSend(Module *creator) : Command(creator, "memoserv/rsend", 2, 2)
{ {
this->SetDesc(_("Sends a memo and requests a read receipt")); this->SetDesc(_("Send a memo and requests a read receipt"));
this->SetSyntax(_("{\037nick\037 | \037channel\037} \037memo-text\037")); this->SetSyntax(_("{\037nick\037 | \037channel\037} \037memo-text\037"));
} }
+8 -5
View File
@@ -61,16 +61,17 @@ public:
return na; return na;
} }
void Tick() override bool Tick() override
{ {
if (!u || !na || !NickServ::service) if (!u || !na || !NickServ::service)
return; return false;
/* If they identified or don't exist anymore, don't kill them. */ /* If they identified or don't exist anymore, don't kill them. */
if (u->Account() == na->nc || u->timestamp > ts) if (u->Account() == na->nc || u->timestamp > ts)
return; return false;
NickServ::service->Collide(u, na); NickServ::service->Collide(u, na);
return false;
} }
}; };
@@ -90,10 +91,11 @@ public:
n->Extend<bool>("HELD"); n->Extend<bool>("HELD");
} }
void Tick() override bool Tick() override
{ {
if (na) if (na)
na->Shrink<bool>("HELD"); na->Shrink<bool>("HELD");
return false;
} }
}; };
@@ -133,8 +135,9 @@ public:
NickServReleases.erase(this->nick); NickServReleases.erase(this->nick);
} }
void Tick() override bool Tick() override
{ {
return false;
} }
}; };

Some files were not shown because too many files have changed in this diff Show More