1
0
mirror of https://github.com/anope/anope.git synced 2026-06-12 17:24:49 +02:00

Make the hops parameter to Server optional.

This commit is contained in:
Sadie Powell
2026-03-26 12:25:09 +00:00
parent 1b2b4386c1
commit 5006993d0a
11 changed files with 25 additions and 23 deletions
+4 -4
View File
@@ -57,11 +57,11 @@ private:
/* Uplink for this server */ /* Uplink for this server */
Server *uplink; Server *uplink;
/* Server is syncing */ /* Server is syncing */
bool syncing; bool syncing = true;
/* The server is juped */ /* The server is juped */
bool juped; bool juped;
/* The server is about to quit */ /* The server is about to quit */
bool quitting; bool quitting = false;
/* Reason this server was quit */ /* Reason this server was quit */
Anope::string quit_reason; Anope::string quit_reason;
@@ -69,12 +69,12 @@ public:
/** Constructor /** Constructor
* @param uplink The uplink this server is from, is only NULL when creating Me * @param uplink The uplink this server is from, is only NULL when creating Me
* @param name The server name * @param name The server name
* @param hops Hops from services server
* @param description Server rdescription * @param description Server rdescription
* @param sid Server sid/numeric * @param sid Server sid/numeric
* @param hops Hops from services server
* @param jupe If the server is juped * @param jupe If the server is juped
*/ */
Server(Server *uplink, const Anope::string &name, unsigned hops, const Anope::string &description, const Anope::string &sid = "", bool jupe = false); Server(Server *uplink, const Anope::string &name, const Anope::string &description, const Anope::string &sid = "", unsigned hops = 0, bool jupe = false);
private: private:
/** Destructor /** Destructor
+1 -1
View File
@@ -46,7 +46,7 @@ public:
IRCD->SendSquit(server, rbuf); IRCD->SendSquit(server, rbuf);
server->Delete(rbuf); server->Delete(rbuf);
} }
auto *juped_server = new Server(Me, jserver, 1, rbuf, sid, true); auto *juped_server = new Server(Me, jserver, rbuf, sid, 1, true);
IRCD->SendServer(juped_server); IRCD->SendServer(juped_server);
Log(LOG_ADMIN, source, this) << "on " << jserver << " (" << rbuf << ")"; Log(LOG_ADMIN, source, this) << "on " << jserver << " (" << rbuf << ")";
+2 -2
View File
@@ -510,7 +510,7 @@ struct IRCDMessageServer final
if (params.size() == 5) if (params.size() == 5)
UplinkSID = params[2]; UplinkSID = params[2];
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params.back(), UplinkSID); new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], params.back(), UplinkSID, 1);
IRCD->SendPing(Me->GetName(), params[0]); IRCD->SendPing(Me->GetName(), params[0]);
} }
@@ -526,7 +526,7 @@ struct IRCDMessageSID final
void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{ {
auto hops = Anope::Convert(params[1], 0); auto hops = Anope::Convert(params[1], 0);
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, params.back(), params[2]); new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], params.back(), params[2], hops);
IRCD->SendPing(Me->GetName(), params[0]); IRCD->SendPing(Me->GetName(), params[0]);
} }
+2 -2
View File
@@ -2348,7 +2348,7 @@ struct IRCDMessageServer final
* 2: numeric * 2: numeric
* 3: desc * 3: desc
*/ */
new Server(Me, params[0], 0, params.back(), params[2]); new Server(Me, params[0], params.back(), params[2]);
} }
else if (source.GetServer()) else if (source.GetServer())
{ {
@@ -2359,7 +2359,7 @@ struct IRCDMessageServer final
* 2 to N-1: various key=value pairs. * 2 to N-1: various key=value pairs.
* N: desc * N: desc
*/ */
new Server(source.GetServer(), params[0], 1, params.back(), params[1]); new Server(source.GetServer(), params[0], params.back(), params[1]);
} }
} }
}; };
+2 -2
View File
@@ -542,13 +542,13 @@ struct IRCDMessageServer final
if (params.size() == 3) if (params.size() == 3)
{ {
// our uplink is introducing itself // our uplink is introducing itself
new Server(Me, params[0], 1, params[2], "1"); new Server(Me, params[0], params[2], "1", 1);
} }
else else
{ {
// our uplink is introducing a new server // our uplink is introducing a new server
auto hops = Anope::Convert<unsigned>(params[1], 0); auto hops = Anope::Convert<unsigned>(params[1], 0);
new Server(source.GetServer(), params[0], hops, params[3], params[2]); new Server(source.GetServer(), params[0], params[3], params[2], hops);
} }
/* /*
* ngIRCd does not send an EOB, so we send a PING immediately * ngIRCd does not send an EOB, so we send a PING immediately
+1 -1
View File
@@ -287,7 +287,7 @@ struct IRCDMessageServer final
if (params[1] != "1") if (params[1] != "1")
return; return;
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params[2], UplinkSID); new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], params[2], UplinkSID, 1);
} }
}; };
+1 -1
View File
@@ -213,7 +213,7 @@ struct IRCDMessageServer final
// Servers other then our immediate uplink are introduced via SID // Servers other then our immediate uplink are introduced via SID
if (params[1] != "1") if (params[1] != "1")
return; return;
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params[2], UplinkSID); new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], params[2], UplinkSID, 1);
IRCD->SendPing(Me->GetName(), params[0]); IRCD->SendPing(Me->GetName(), params[0]);
} }
}; };
+1 -1
View File
@@ -400,7 +400,7 @@ struct IRCDMessageServer final
// Servers other then our immediate uplink are introduced via SID // Servers other then our immediate uplink are introduced via SID
if (params[1] != "1") if (params[1] != "1")
return; return;
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params[2], UplinkSID); new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], params[2], UplinkSID, 1);
IRCD->SendPing(Me->GetName(), params[0]); IRCD->SendPing(Me->GetName(), params[0]);
} }
}; };
+3 -3
View File
@@ -1455,10 +1455,10 @@ struct IRCDMessageServer final
Anope::string desc; Anope::string desc;
spacesepstream(params[2]).GetTokenRemainder(desc, 1); spacesepstream(params[2]).GetTokenRemainder(desc, 1);
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, desc, UplinkSID); new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], desc, UplinkSID, hops);
} }
else else
new Server(source.GetServer(), params[0], hops, params[2]); new Server(source.GetServer(), params[0], params[2], hops);
IRCD->SendPing(Me->GetName(), params[0]); IRCD->SendPing(Me->GetName(), params[0]);
} }
@@ -1473,7 +1473,7 @@ struct IRCDMessageSID final
{ {
auto hops = Anope::Convert<unsigned>(params[1], 0); auto hops = Anope::Convert<unsigned>(params[1], 0);
new Server(source.GetServer(), params[0], hops, params[3], params[2]); new Server(source.GetServer(), params[0], params[3], params[2], hops);
IRCD->SendPing(Me->GetName(), params[0]); IRCD->SendPing(Me->GetName(), params[0]);
} }
+1 -1
View File
@@ -518,7 +518,7 @@ bool Anope::Init(int ac, char **av)
/* Create me */ /* Create me */
const auto &block = Config->GetBlock("serverinfo"); const auto &block = Config->GetBlock("serverinfo");
Me = new Server(NULL, block.Get<const Anope::string>("name"), 0, block.Get<const Anope::string>("description"), block.Get<const Anope::string>("id")); Me = new Server(NULL, block.Get<const Anope::string>("name"), block.Get<const Anope::string>("description"), block.Get<const Anope::string>("id"));
for (const auto &[_, bi] : *BotListByNick) for (const auto &[_, bi] : *BotListByNick)
{ {
bi->server = Me; bi->server = Me;
+7 -5
View File
@@ -30,12 +30,14 @@ Anope::map<Server *> Servers::ByID;
std::set<Anope::string> Servers::Capab; std::set<Anope::string> Servers::Capab;
Server::Server(Server *up, const Anope::string &sname, unsigned shops, const Anope::string &desc, const Anope::string &ssid, bool jupe) : name(sname), hops(shops), description(desc), sid(ssid), uplink(up) Server::Server(Server *up, const Anope::string &sname, const Anope::string &desc, const Anope::string &ssid, unsigned shops, bool jupe)
: name(sname)
, hops(shops)
, description(desc)
, sid(ssid)
, uplink(up)
, juped(jupe)
{ {
syncing = true;
juped = jupe;
quitting = false;
Servers::ByName[sname] = this; Servers::ByName[sname] = this;
if (!ssid.empty()) if (!ssid.empty())
Servers::ByID[ssid] = this; Servers::ByID[ssid] = this;