Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/2.0' into 2.0-techtronix
Browse files Browse the repository at this point in the history
  • Loading branch information
Techman committed Jul 19, 2024
2 parents d6cf9c6 + bfca74f commit 4ca87a3
Show file tree
Hide file tree
Showing 24 changed files with 224 additions and 93 deletions.
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ updates:
directory: /
schedule:
interval: monthly
target-branch: "2.1"
5 changes: 2 additions & 3 deletions data/chanserv.example.conf
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,9 @@ module
/*
* The length of time before a channel registration expires.
*
* This directive is optional, but recommended.
* If not set, the default is 14 days.
* This directive is optional. If not set, the default is never.
*/
expire = 14d
#expire = 90d

/*
* The maximum number of entries on a channel's access list.
Expand Down
7 changes: 1 addition & 6 deletions data/example.conf
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ serverinfo
* - hybrid
* - inspircd12
* - inspircd20
* - inspircd3
* - inspircd3 (for 3.x and 4.x)
* - ngircd
* - plexus
* - ratbox
Expand Down Expand Up @@ -1153,11 +1153,6 @@ module
* This is only useful with very large databases, with hundreds
* of thousands of objects, that have a noticeable delay from
* writing databases.
*
* If your database is large enough cause a noticeable delay when
* saving you should consider a more powerful alternative such
* as db_sql or db_redis, which incrementally update their
* databases asynchronously in real time.
*/
fork = no
}
Expand Down
2 changes: 1 addition & 1 deletion data/stats.standalone.example.conf
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ serverinfo
* - hybrid
* - inspircd12
* - inspircd20
* - inspircd3
* - inspircd3 (for 3.x and 4.x)
* - ngircd
* - plexus
* - ratbox
Expand Down
27 changes: 26 additions & 1 deletion docs/Changes
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
Anope Version 2.0.16-git
Anope Version 2.0.17-git
------------------------
No significant changes.

Anope Version 2.0.16-git
------------------------
Added a workaround for users matching expired sqlines.
Fixed a copy/paste error in webcpanel.
Fixed a crash in db_flatfile caused by trying to serialize data without a type.
Fixed duplicate messages when synconset/syncongroup is set.
Fixed expiring channel suspensions.
Fixed expiring forbids.
Fixed expiring nick suspensions.
Fixed feature detection on InspIRCd.
Fixed InspIRCd account cloaks causing CHGHOST spam when a user also has a services vhost.
Fixed joining users to channels with a key set on InspIRCd.
Fixed logging users out fully when their nick gets suspended.
Fixed marking boolean columns in SQL as TEXT instead of INT.
Fixed matching extbans on InspIRCd and implement missing matchers.
Fixed operserv/sqline expiry on UnrealIRCd
Fixed respecting --noexpire in cs_suspend and ns_suspend.
Fixed sending emails to nicks ending with a backslash.
Fixed sending SVSTOPIC when topiclock is loaded on InspIRCd.
Fixed some SQL tables taking up too much space on disk.
Fixed the default config for channel suspensions.
Fixed the TIME message on InspIRCd.
Fixed trying to escape SQL data when not connected to MySQL.
Fixed {ldap,sql}_authentication creating zombie accounts on expiry.

Anope Version 2.0.15
--------------------
Fixed a race condition in changing the nick of a user.
Expand Down
6 changes: 5 additions & 1 deletion docs/Changes.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
Anope Version 2.0.16-git
Anope Version 2.0.17-git
------------------------
No significant changes.

Anope Version 2.0.16
--------------------
No significant changes.

Anope Version 2.0.15
--------------------
No significant changes.
Expand Down
1 change: 1 addition & 0 deletions include/extensible.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ class SerializableExtensibleItem<bool> : public PrimitiveExtensibleItem<bool>

void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const anope_override
{
data.SetType(this->name, Serialize::Data::DT_INT);
data[this->name] << true;
}

Expand Down
21 changes: 10 additions & 11 deletions modules/commands/bs_kick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,16 @@ struct KickerDataImpl : KickerData
if (kd == NULL)
return;

data["kickerdata:amsgs"] << kd->amsgs;
data["kickerdata:badwords"] << kd->badwords;
data["kickerdata:bolds"] << kd->bolds;
data["kickerdata:caps"] << kd->caps;
data["kickerdata:colors"] << kd->colors;
data["kickerdata:flood"] << kd->flood;
data["kickerdata:italics"] << kd->italics;
data["kickerdata:repeat"] << kd->repeat;
data["kickerdata:reverses"] << kd->reverses;
data["kickerdata:underlines"] << kd->underlines;

data.SetType("kickerdata:amsgs", Serialize::Data::DT_INT); data["kickerdata:amsgs"] << kd->amsgs;
data.SetType("kickerdata:badwords", Serialize::Data::DT_INT); data["kickerdata:badwords"] << kd->badwords;
data.SetType("kickerdata:bolds", Serialize::Data::DT_INT); data["kickerdata:bolds"] << kd->bolds;
data.SetType("kickerdata:caps", Serialize::Data::DT_INT); data["kickerdata:caps"] << kd->caps;
data.SetType("kickerdata:colors", Serialize::Data::DT_INT); data["kickerdata:colors"] << kd->colors;
data.SetType("kickerdata:flood", Serialize::Data::DT_INT); data["kickerdata:flood"] << kd->flood;
data.SetType("kickerdata:italics", Serialize::Data::DT_INT); data["kickerdata:italics"] << kd->italics;
data.SetType("kickerdata:repeat", Serialize::Data::DT_INT); data["kickerdata:repeat"] << kd->repeat;
data.SetType("kickerdata:reverses", Serialize::Data::DT_INT); data["kickerdata:reverses"] << kd->reverses;
data.SetType("kickerdata:underlines", Serialize::Data::DT_INT); data["kickerdata:underlines"] << kd->underlines;
data.SetType("capsmin", Serialize::Data::DT_INT); data["capsmin"] << kd->capsmin;
data.SetType("capspercent", Serialize::Data::DT_INT); data["capspercent"] << kd->capspercent;
data.SetType("floodlines", Serialize::Data::DT_INT); data["floodlines"] << kd->floodlines;
Expand Down
28 changes: 20 additions & 8 deletions modules/commands/cs_suspend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@ class CSSuspend : public Module
}
};

void Expire(ChannelInfo *ci)
{
suspend.Unset(ci);
Log(this) << "Expiring suspend for " << ci->name;
}


bool Show(CommandSource &source, const Anope::string &what) const
{
return source.IsOper() || std::find(show.begin(), show.end(), what) != show.end();
Expand Down Expand Up @@ -255,23 +262,28 @@ class CSSuspend : public Module

expire = false;

if (!si->expires)
return;

if (si->expires < Anope::CurTime)
if (!Anope::NoExpire && si->expires && si->expires < Anope::CurTime)
{
ci->last_used = Anope::CurTime;
suspend.Unset(ci);

Log(this) << "Expiring suspend for " << ci->name;
Expire(ci);
}
}

EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) anope_override
{
if (u->HasMode("OPER") || !c->ci || !suspend.HasExt(c->ci))
if (u->HasMode("OPER") || !c->ci)
return EVENT_CONTINUE;

CSSuspendInfo *si = suspend.Get(c->ci);
if (!si)
return EVENT_CONTINUE;

if (!Anope::NoExpire && si->expires && si->expires < Anope::CurTime)
{
Expire(c->ci);
return EVENT_CONTINUE;
}

reason = Language::Translate(u, _("This channel may not be used."));
return EVENT_STOP;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/commands/hs_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CommandHSGroup : public Command
for (unsigned i = 0; i < na->nc->aliases->size(); ++i)
{
NickAlias *nick = na->nc->aliases->at(i);
if (nick)
if (nick && nick != na)
{
nick->SetVhost(na->GetVhostIdent(), na->GetVhostHost(), na->GetVhostCreator());
FOREACH_MOD(OnSetVhost, (nick));
Expand Down
2 changes: 1 addition & 1 deletion modules/commands/hs_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class CommandHSSetAll : public Command
for (unsigned i = 0; i < na->nc->aliases->size(); ++i)
{
NickAlias *nick = na->nc->aliases->at(i);
if (nick)
if (nick && nick != na)
nick->SetVhost(na->GetVhostIdent(), na->GetVhostHost(), na->GetVhostCreator());
}
}
Expand Down
23 changes: 16 additions & 7 deletions modules/commands/ns_suspend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ class CommandNSSuspend : public Command
User *u2 = User::Find(na2->nick, true);
if (u2)
{
IRCD->SendLogout(u2);
u2->RemoveMode(source.service, "REGISTERED");
u2->Logout();
if (nickserv)
nickserv->Collide(u2, na2);
Expand Down Expand Up @@ -222,6 +224,12 @@ class NSSuspend : public Module
return source.IsOper() || std::find(show.begin(), show.end(), what) != show.end();
}

void Expire(NickAlias *na)
{
suspend.Unset(na->nc);
Log(LOG_NORMAL, "nickserv/expire", Config->GetClient("NickServ")) << "Expiring suspend for " << na->nick;
}

public:
NSSuspend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
commandnssuspend(this), commandnsunsuspend(this), suspend(this, "NS_SUSPENDED"),
Expand Down Expand Up @@ -262,15 +270,10 @@ class NSSuspend : public Module

expire = false;

if (!s->expires)
return;

if (s->expires < Anope::CurTime)
if (!Anope::NoExpire && s->expires && s->expires < Anope::CurTime)
{
na->last_seen = Anope::CurTime;
suspend.Unset(na->nc);

Log(LOG_NORMAL, "nickserv/expire", Config->GetClient("NickServ")) << "Expiring suspend for " << na->nick;
Expire(na);
}
}

Expand All @@ -280,6 +283,12 @@ class NSSuspend : public Module
if (!s)
return EVENT_CONTINUE;

if (!Anope::NoExpire && s->expires && s->expires < Anope::CurTime)
{
Expire(na);
return EVENT_CONTINUE;
}

u->SendMessage(Config->GetClient("NickServ"), NICK_X_SUSPENDED, u->nick.c_str());
return EVENT_STOP;
}
Expand Down
53 changes: 40 additions & 13 deletions modules/commands/os_forbid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,33 @@ class MyForbidService : public ForbidService

inline std::vector<ForbidData *>& forbids(unsigned t) { return (*this->forbid_data)[t - 1]; }

void Expire(ForbidData *fd, unsigned ft, size_t idx)
{
Anope::string typestr;
switch (ft)
{
case FT_NICK:
typestr = "nick";
break;
case FT_CHAN:
typestr = "chan";
break;
case FT_EMAIL:
typestr = "email";
break;
case FT_REGISTER:
typestr = "register";
break;
default:
typestr = "unknown";
break;
}

Log(LOG_NORMAL, "expire/forbid", Config->GetClient("OperServ")) << "Expiring forbid for " << fd->mask << " type " << typestr;
this->forbids(ft).erase(this->forbids(ft).begin() + idx);
delete fd;
}

public:
MyForbidService(Module *m) : ForbidService(m), forbid_data("ForbidData") { }

Expand Down Expand Up @@ -99,6 +126,12 @@ class MyForbidService : public ForbidService
{
ForbidData *d = this->forbids(ftype)[i - 1];

if (!Anope::NoExpire && d->expires && Anope::CurTime >= d->expires)
{
Expire(d, ftype, i - 1);
continue;
}

if (Anope::Match(mask, d->mask, false, true))
return d;
}
Expand All @@ -111,6 +144,12 @@ class MyForbidService : public ForbidService
{
ForbidData *d = this->forbids(ftype)[i - 1];

if (!Anope::NoExpire && d->expires && Anope::CurTime >= d->expires)
{
Expire(d, ftype, i - 1);
continue;
}

if (d->mask.equals_ci(mask))
return d;
}
Expand All @@ -126,19 +165,7 @@ class MyForbidService : public ForbidService
ForbidData *d = this->forbids(j).at(i - 1);

if (d->expires && !Anope::NoExpire && Anope::CurTime >= d->expires)
{
Anope::string ftype = "none";
if (d->type == FT_NICK)
ftype = "nick";
else if (d->type == FT_CHAN)
ftype = "chan";
else if (d->type == FT_EMAIL)
ftype = "email";

Log(LOG_NORMAL, "expire/forbid", Config->GetClient("OperServ")) << "Expiring forbid for " << d->mask << " type " << ftype;
this->forbids(j).erase(this->forbids(j).begin() + i - 1);
delete d;
}
Expire(d, j, i - 1);
else
f.push_back(d);
}
Expand Down
2 changes: 2 additions & 0 deletions modules/database/db_flatfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ class DBFlatFile : public Module, public Pipe
{
Serializable *base = *it;
Serialize::Type *s_type = base->GetSerializableType();
if (!s_type)
continue;

data.fs = databases[s_type->GetOwner()];
if (!data.fs || !data.fs->is_open())
Expand Down
9 changes: 9 additions & 0 deletions modules/extra/m_ldap_authentication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,15 @@ class ModuleLDAPAuthentication : public Module
Anope::string new_dn = username_attribute + "=" + na->nick + "," + basedn;
this->ldap->Add(&this->orinterface, new_dn, attributes);
}

void OnPreNickExpire(NickAlias *na, bool &expire) anope_override
{
// We can't let nicks expire if they still have a group or
// there will be a zombie account left over that can't be
// authenticated to.
if (na->nick == na->nc->display && na->nc->aliases->size() > 1)
expire = false;
}
};

MODULE_INIT(ModuleLDAPAuthentication)
15 changes: 10 additions & 5 deletions modules/extra/m_mysql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,14 @@ Result MySQLService::RunQuery(const Query &query)
{
this->Lock.Lock();

Anope::string real_query = this->BuildQuery(query);
if (!this->CheckConnection())
{
this->Lock.Unlock();
return MySQLResult(query, query.query, mysql_error(this->sql));
}

if (this->CheckConnection() && !mysql_real_query(this->sql, real_query.c_str(), real_query.length()))
Anope::string real_query = this->BuildQuery(query);
if (!mysql_real_query(this->sql, real_query.c_str(), real_query.length()))
{
MYSQL_RES *res = mysql_store_result(this->sql);
unsigned int id = mysql_insert_id(this->sql);
Expand Down Expand Up @@ -395,11 +400,11 @@ std::vector<Query> MySQLService::CreateTable(const Anope::string &table, const D

query_text += ", `" + it->first + "` ";
if (data.GetType(it->first) == Serialize::Data::DT_INT)
query_text += "int(11)";
query_text += "int";
else
query_text += "text";
}
query_text += ", PRIMARY KEY (`id`), KEY `timestamp_idx` (`timestamp`))";
query_text += ", PRIMARY KEY (`id`), KEY `timestamp_idx` (`timestamp`)) ROW_FORMAT=DYNAMIC";
queries.push_back(query_text);
}
else
Expand All @@ -412,7 +417,7 @@ std::vector<Query> MySQLService::CreateTable(const Anope::string &table, const D

Anope::string query_text = "ALTER TABLE `" + table + "` ADD `" + it->first + "` ";
if (data.GetType(it->first) == Serialize::Data::DT_INT)
query_text += "int(11)";
query_text += "int";
else
query_text += "text";

Expand Down
Loading

0 comments on commit 4ca87a3

Please sign in to comment.