Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Inspircd Devel Server committed Jul 19, 2021
2 parents 43775fe + dc049f1 commit a7d7e9f
Show file tree
Hide file tree
Showing 135 changed files with 17,418 additions and 793 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
70 changes: 70 additions & 0 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Linux CI
on:
push:
paths:
- '3.0/*'
pull_request:
paths:
- '3.0/*'
jobs:
build:
runs-on: ubuntu-18.04
env:
CXXFLAGS: -std=${{ matrix.standard }} -Wno-error=deprecated-declarations
CXX: ${{ matrix.compiler }}
INSPIRCD_DEBUG: 3
INSPIRCD_VERBOSE: 1
steps:
- name: Install dependencies
run: |
sudo apt-get update --assume-yes
sudo apt-get install --assume-yes --no-install-recommends clang g++ git make libc++-dev libc++abi-dev pkg-config
- name: Checkout InspIRCd@insp3
uses: actions/checkout@v2
with:
repository: 'inspircd/inspircd'
ref: 'insp3'
path: 'inspircd'
- name: Checkout self
uses: actions/checkout@v2
with:
path: 'contrib'
- name: (Pull Request) Set the build target to only the changed modules
if: github.event_name == 'pull_request'
run: |
cd contrib
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
echo INSPIRCD_TARGET=$( \
git diff --name-only origin/${{ github.base_ref }} ${{ github.sha }} | \
for f in `cat`; do if [[ "$f" = "3.0/"*".cpp" ]]; \
then echo "$(basename $f .cpp) "; fi; done) >> $GITHUB_ENV
- name: (Push/PR Fallback) Set the build target to all of the modules
if: github.event_name == 'push' || env.INSPIRCD_TARGET == ''
run: echo INSPIRCD_TARGET=$(for f in contrib/3.0/*; do echo "$(basename $f .cpp) "; done) >> $GITHUB_ENV
- name: Symlink the modules
run: |
cd inspircd/src/modules
ln -s ../../../contrib/3.0/* .
- name: Check for additional dependencies
run: |
cd inspircd
echo PACKAGES=$( \
for f in ../contrib/3.0/*; do if [[ "$INSPIRCD_TARGET" = *"$(basename $f .cpp)"* ]]; \
then ./tools/directive $f PackageInfo; fi; done) >> $GITHUB_ENV
- name: Install additional dependencies
if: env.PACKAGES != ''
run: sudo apt-get install --assume-yes --no-install-recommends ${{ env.PACKAGES }}
- name: Build the modules
run: |
cd inspircd
./configure --development --disable-auto-extras
make --jobs $(($(getconf _NPROCESSORS_ONLN) + 1))
strategy:
fail-fast: false
matrix:
compiler:
- clang++
- g++
standard:
- gnu++98
- c++14
66 changes: 66 additions & 0 deletions .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: macOS CI
on:
push:
paths:
- '3.0/*'
pull_request:
paths:
- '3.0/*'
jobs:
build:
runs-on: macos-latest
env:
CXXFLAGS: -std=${{ matrix.standard }} -Wno-error=deprecated-declarations
INSPIRCD_DEBUG: 3
INSPIRCD_VERBOSE: 1
steps:
- name: Install dependencies
run: |
brew update || true
brew install pkg-config
- name: Checkout InspIRCd@insp3
uses: actions/checkout@v2
with:
repository: 'inspircd/inspircd'
ref: 'insp3'
path: 'inspircd'
- name: Checkout self
uses: actions/checkout@v2
with:
path: 'contrib'
- name: (Pull Request) Set the build target to only the changed modules
if: github.event_name == 'pull_request'
run: |
cd contrib
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
echo INSPIRCD_TARGET=$( \
git diff --name-only origin/${{ github.base_ref }} ${{ github.sha }} | \
for f in `cat`; do if [[ "$f" = "3.0/"*".cpp" ]]; \
then echo "$(basename $f .cpp) "; fi; done) >> $GITHUB_ENV
- name: (Push/PR Fallback) Set the build target to all of the modules
if: github.event_name == 'push' || env.INSPIRCD_TARGET == ''
run: echo INSPIRCD_TARGET=$(for f in contrib/3.0/*; do echo "$(basename $f .cpp) "; done) >> $GITHUB_ENV
- name: Symlink the modules
run: |
cd inspircd/src/modules
ln -s ../../../contrib/3.0/* .
- name: Check for additional dependencies
run: |
cd inspircd
echo PACKAGES=$( \
for f in ../contrib/3.0/*; do if [[ "$INSPIRCD_TARGET" = *"$(basename $f .cpp)"* ]]; \
then ./tools/directive $f PackageInfo; fi; done) >> $GITHUB_ENV
- name: Install additional dependencies
if: env.PACKAGES != ''
run: brew install ${{ env.PACKAGES }}
- name: Build the modules
run: |
cd inspircd
./configure --development --disable-auto-extras
make --jobs $(($(sysctl -n hw.activecpu) + 1))
strategy:
fail-fast: false
matrix:
standard:
- gnu++98
- c++14
21 changes: 21 additions & 0 deletions .github/workflows/regen-modules.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Update the module list
on:
- push
jobs:
build:
if: github.repository == 'inspircd/inspircd-contrib'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Regenerate the module list
run: ./regen-modules
- name: Commit the updated module list
run: |
git config --global user.name "InspIRCd Robot"
git config --global user.email "[email protected]"
git add modules.lst
git commit --message "Regenerate the module list." || true
- name: Push the updated module list
run: git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git ${{ github.ref }}
5 changes: 5 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Adam <[email protected]> Adam <[email protected]>
Attila Molnar <[email protected]> attilamolnar <[email protected]>
Nikos Papakonstantinou <[email protected]> Nikos-ioh <[email protected]>
Robin Burchell <[email protected]> Robin Burchell <[email protected]>
Sadie Powell <[email protected]> Peter Powell <[email protected]>
6 changes: 3 additions & 3 deletions 2.0/m_anticaps.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* InspIRCd -- Internet Relay Chat Daemon
*
* Copyright (C) 2017 Peter Powell <[email protected]>
* Copyright (C) 2017 Sadie Powell <[email protected]>
*
* This file is part of InspIRCd. InspIRCd is free software: you can
* redistribute it and/or modify it under the terms of the GNU General Public
Expand All @@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/* $ModAuthor: Peter "SaberUK" Powell */
/* $ModAuthorMail: [email protected] */
/* $ModAuthor: Sadie Powell */
/* $ModAuthorMail: [email protected] */
/* $ModDesc: Provides support for punishing users that send capitalised messages. */
/* $ModDepends: core 2.0 */

Expand Down
165 changes: 165 additions & 0 deletions 2.0/m_apacheauth.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
/*
* InspIRCd -- Internet Relay Chat Daemon
*
* Copyright (C) 2011-2016 Collabora Ltd <[email protected]>
*
* This file is part of InspIRCd. InspIRCd is free software: you can
* redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <fstream>
#include "inspircd.h"
#include "hash.h"

/* $ModAuthor: Collabora Ltd */
/* $ModAuthorMail: [email protected] */
/* $ModDepends: core 2.0 */
/* $ModDesc: Allow/Deny connections based upon an apache auth file */
/* $LinkerFlags: -lcrypt */

class ModuleApacheAuth : public Module
{
std::string authfile;
std::string killreason;
std::string allowpattern;
bool verbose;
struct HashedPassword {
std::string algorithm;
std::string salt;
std::string hash;
std::string hashed;
};
std::map<std::string, HashedPassword> logins;

public:
ModuleApacheAuth()
{
}

void init()
{
OnRehash(NULL);
Implementation eventlist[] = { I_OnRehash, I_OnUserRegister };
ServerInstance->Modules->Attach(eventlist, this, 2);
}

void OnRehash(User* user)
{
ConfigTag* conf = ServerInstance->Config->ConfValue("apacheauth");
authfile = conf->getString("authfile");
killreason = conf->getString("killreason");
allowpattern = conf->getString("allowpattern");
verbose = conf->getBool("verbose");
LoadAuthFile();
}

bool SplitRecord(const std::string &record, std::string &record_algorithm, std::string &record_salt, std::string &record_hash)
{
size_t i[3];

for (size_t pos = 0, n = 0; n < 3; ++n) {
i[n] = pos = record.find('$', pos);
if (pos == std::string::npos) return false;
++pos;
}
record_algorithm = record.substr(i[0] + 1, i[1]-i[0] - 1);
record_salt = record.substr(i[1] + 1, i[2]-i[1] - 1);
record_hash = record.substr(i[2] + 1);
return true;
}

void LoadAuthFile()
{
int line=0;
std::ifstream f;

logins.clear();
ServerInstance->SNO->WriteGlobalSno('a', "Loading auth file %s",authfile.c_str());
f.open(authfile.c_str(), std::ifstream::in);
if (!f.good()) {
ServerInstance->SNO->WriteGlobalSno('a', "Auth file failed to open, no connections will be allowed");
return;
}
std::string s;
while (std::getline(f, s)) {
++line;
size_t pos = s.find(':');
if (pos == std::string::npos) {
ServerInstance->SNO->WriteGlobalSno('a', "Syntax error at line %d", line);
continue;
}
std::string login = s.substr(0, pos);
std::string hashed = s.substr(pos + 1);
if (verbose) {
ServerInstance->SNO->WriteGlobalSno('a', "Found login %s, hash %s", login.c_str(), hashed.c_str());
}
if (logins.find(login) != logins.end()) {
ServerInstance->SNO->WriteGlobalSno ('a', "Warning: ignoring duplicate login: %s", login.c_str());
}
else {
HashedPassword p;
p.hashed = hashed;
if (!SplitRecord(hashed, p.algorithm, p.salt, p.hash)) {
ServerInstance->SNO->WriteGlobalSno ('a', "Warning: ignoring malformed line: %s", hashed.c_str());
}
else if (p.algorithm != "1") { // MD5
ServerInstance->SNO->WriteGlobalSno ('a', "Warning: ignoring unsupported algorithm: %s", p.algorithm.c_str());
}
else {
logins.insert(std::make_pair(login, p));
}
}
}
ServerInstance->SNO->WriteGlobalSno ('a', "Done C++ loading auth file, %u users", (unsigned)logins.size());
f.close();
}

ModResult OnUserRegister(LocalUser* user)
{
// Note this is their initial (unresolved) connect block
ConfigTag* tag = user->MyClass->config;
if (!tag->getBool("useapacheauth", true))
return MOD_RES_PASSTHRU;

if (!allowpattern.empty() && InspIRCd::Match(user->ident,allowpattern))
return MOD_RES_PASSTHRU;

std::map<std::string, HashedPassword>::const_iterator i = logins.find(user->ident);
if (i == logins.end()) {
ServerInstance->SNO->WriteGlobalSno('a', "Denying connection from %s!%s@%s (login not found)",
user->nick.c_str(), user->ident.c_str(), user->host.c_str());
ServerInstance->Users->QuitUser(user, killreason);
return MOD_RES_PASSTHRU;
}

const HashedPassword &p = i->second;
std::string algorithm_and_salt = std::string("$") + p.algorithm + std::string("$") + p.salt;
std::string hashed = crypt(user->password.c_str(),algorithm_and_salt.c_str());
if (hashed != p.hashed) {
ServerInstance->SNO->WriteGlobalSno('a', "Forbiding connection from %s!%s@%s (invalid password)",
user->nick.c_str(), user->ident.c_str(), user->host.c_str());
ServerInstance->Users->QuitUser(user, killreason);
return MOD_RES_PASSTHRU;
}
ServerInstance->SNO->WriteGlobalSno('a', "Granting access to connection from %s!%s@%s",
user->nick.c_str(), user->ident.c_str(), user->host.c_str());
return MOD_RES_PASSTHRU;
}

Version GetVersion()
{
return Version("Allow/Deny connections based upon an Apache auth file", VF_NONE);
}
};

MODULE_INIT(ModuleApacheAuth)

6 changes: 3 additions & 3 deletions 2.0/m_autodrop.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* InspIRCd -- Internet Relay Chat Daemon
*
* Copyright (C) 2014 Peter Powell <[email protected]>
* Copyright (C) 2014 Sadie Powell <[email protected]>
*
* This file is part of InspIRCd. InspIRCd is free software: you can
* redistribute it and/or modify it under the terms of the GNU General Public
Expand All @@ -17,8 +17,8 @@
*/


/* $ModAuthor: Peter "SaberUK" Powell */
/* $ModAuthorMail: [email protected] */
/* $ModAuthor: Sadie Powell */
/* $ModAuthorMail: [email protected] */
/* $ModDesc: Allows clients to be automatically dropped if they execute certain commands before registration. */
/* $ModDepends: core 2.0 */
/* $ModConfig: <autodrop commands="CONNECT DELETE GET HEAD OPTIONS PATCH POST PUT TRACE"> */
Expand Down
6 changes: 3 additions & 3 deletions 2.0/m_autokick.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* InspIRCd -- Internet Relay Chat Daemon
*
* Copyright (C) 2014 Peter Powell <[email protected]>
* Copyright (C) 2014 Sadie Powell <[email protected]>
*
* This file is part of InspIRCd. InspIRCd is free software: you can
* redistribute it and/or modify it under the terms of the GNU General Public
Expand All @@ -17,8 +17,8 @@
*/


/* $ModAuthor: Peter "SaberUK" Powell */
/* $ModAuthorMail: [email protected] */
/* $ModAuthor: Sadie Powell */
/* $ModAuthorMail: [email protected] */
/* $ModDesc: Automatically kicks people who match a banned mask. */
/* $ModDepends: core 2.0 */
/* $ModConfig: <autokick message="Banned"> */
Expand Down
Loading

0 comments on commit a7d7e9f

Please sign in to comment.