1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-10 16:03:13 +02:00

Log linking attempts and errors. Also report them to IRCOps in an uniform way.

Reported by Mr_Smoke in https://bugs.unrealircd.org/view.php?id=3973
This commit is contained in:
Bram Matthys
2018-09-07 11:57:47 +02:00
parent 8d05951298
commit bd19e9c87a
5 changed files with 53 additions and 35 deletions
+20 -22
View File
@@ -271,7 +271,7 @@ int _verify_link(aClient *cptr, aClient *sptr, char *servername, ConfigItem_link
servername);
sendto_one(cptr, "ERROR :%s", xerrmsg);
sendto_umode(UMODE_OPER, "Outgoing link aborted to %s(%s@%s) (%s) %s",
sendto_ops_and_log("Outgoing link aborted to %s(%s@%s) (%s) %s",
cptr->serv->conf->servername, cptr->username, cptr->local->sockhost, xerrmsg, inpath);
return exit_client(cptr, sptr, &me, xerrmsg);
}
@@ -307,7 +307,7 @@ errlink:
"ERROR :Link denied (No link block found named '%s' or link::incoming::mask did not match your IP %s) %s",
servername, GetIP(cptr), inpath);
/* And send the "verbose" error msg only to locally connected ircops */
sendto_umode(UMODE_OPER, "Link denied for %s(%s@%s) (%s) %s",
sendto_ops_and_log("Link denied for %s(%s@%s) (%s) %s",
servername, cptr->username, cptr->local->sockhost, xerrmsg, inpath);
return exit_client(cptr, sptr, &me,
"Link denied (No link block found with your server name or link::incoming::mask did not match)");
@@ -320,7 +320,7 @@ skip_host_check:
sendto_one(cptr,
"ERROR :Link '%s' denied (Authentication failed) %s",
servername, inpath);
sendto_umode(UMODE_OPER, "Link denied for '%s' (Authentication failed [Bad password?]) %s",
sendto_ops_and_log("Link denied for '%s' (Authentication failed [Bad password?]) %s",
servername, inpath);
return exit_client(cptr, sptr, &me,
"Link denied (Authentication failed)");
@@ -336,7 +336,7 @@ skip_host_check:
sendto_one(cptr,
"ERROR :Link '%s' denied (Not using SSL/TLS) %s",
servername, inpath);
sendto_umode(UMODE_OPER, "Link denied for '%s' (Not using SSL/TLS and verify-certificate is on) %s",
sendto_ops_and_log("Link denied for '%s' (Not using SSL/TLS and verify-certificate is on) %s",
servername, inpath);
return exit_client(cptr, sptr, &me,
"Link denied (Not using SSL/TLS)");
@@ -346,9 +346,9 @@ skip_host_check:
sendto_one(cptr,
"ERROR :Link '%s' denied (Certificate verification failed) %s",
servername, inpath);
sendto_umode(UMODE_OPER, "Link denied for '%s' (Certificate verification failed) %s",
sendto_ops_and_log("Link denied for '%s' (Certificate verification failed) %s",
servername, inpath);
sendto_umode(UMODE_OPER, "Reason for certificate verification failure: %s", errstr);
sendto_ops_and_log("Reason for certificate verification failure: %s", errstr);
return exit_client(cptr, sptr, &me,
"Link denied (Certificate verification failed)");
}
@@ -364,7 +364,7 @@ skip_host_check:
if (IsMe(acptr))
{
sendto_realops("Link %s rejected, server trying to link with my name (%s)",
sendto_ops_and_log("Link %s rejected, server trying to link with my name (%s)",
get_client_name(sptr, TRUE), me.name);
sendto_one(sptr, "ERROR: Server %s exists (it's me!)", me.name);
return exit_client(sptr, sptr, sptr, "Server Exists");
@@ -379,7 +379,7 @@ skip_host_check:
"ERROR :Server %s already exists from %s",
servername,
(ocptr->from ? ocptr->from->name : "<nobody>"));
sendto_realops
sendto_ops_and_log
("Link %s cancelled, server %s already exists from %s",
get_client_name(acptr, TRUE), servername,
(ocptr->from ? ocptr->from->name : "<nobody>"));
@@ -388,7 +388,7 @@ skip_host_check:
}
if ((bconf = Find_ban(NULL, servername, CONF_BAN_SERVER)))
{
sendto_realops
sendto_ops_and_log
("Cancelling link %s, banned server",
get_client_name(cptr, TRUE));
sendto_one(cptr, "ERROR :Banned server (%s)", bconf->reason ? bconf->reason : "no reason");
@@ -396,15 +396,14 @@ skip_host_check:
}
if (link->class->clients + 1 > link->class->maxclients)
{
sendto_realops
("Cancelling link %s, full class",
sendto_ops_and_log("Cancelling link %s, full class",
get_client_name(cptr, TRUE));
return exit_client(cptr, cptr, &me, "Full class");
}
if (!IsLocal(cptr) && (iConf.plaintext_policy_server == PLAINTEXT_POLICY_DENY) && !IsSecure(cptr))
{
sendto_one(cptr, "ERROR :Servers need to use SSL/TLS (set::plaintext-policy::server is 'deny')");
sendto_realops("Rejected insecure server. See https://www.unrealircd.org/docs/FAQ#ERROR:_Servers_need_to_use_SSL.2FTLS");
sendto_ops_and_log("Rejected insecure server %s. See https://www.unrealircd.org/docs/FAQ#ERROR:_Servers_need_to_use_SSL.2FTLS", cptr->name);
return exit_client(cptr, sptr, &me, "Servers need to use SSL/TLS (set::plaintext-policy::server is 'deny')");
}
if (link_out)
@@ -556,7 +555,7 @@ CMD_FUNC(m_server)
{
if (deny->flag.type == CRULE_ALL && !match(deny->mask, servername)
&& crule_eval(deny->rule)) {
sendto_ops("Refused connection from %s.",
sendto_ops_and_log("Refused connection from %s. Rejected by deny link { } block.",
get_client_host(cptr));
return exit_client(cptr, cptr, cptr,
"Disallowed by connection rule");
@@ -600,7 +599,7 @@ CMD_FUNC(m_server_remote)
if (IsMe(acptr))
{
sendto_realops("Link %s rejected, server trying to link with my name (%s)",
sendto_ops_and_log("Link %s rejected, server trying to link with my name (%s)",
get_client_name(sptr, TRUE), me.name);
sendto_one(sptr, "ERROR: Server %s exists (it's me!)", me.name);
return exit_client(sptr, sptr, sptr, "Server Exists");
@@ -615,7 +614,7 @@ CMD_FUNC(m_server_remote)
"ERROR :Server %s already exists from %s",
servername,
(ocptr->from ? ocptr->from->name : "<nobody>"));
sendto_realops
sendto_ops_and_log
("Link %s cancelled, server %s already exists from %s",
get_client_name(acptr, TRUE), servername,
(ocptr->from ? ocptr->from->name : "<nobody>"));
@@ -633,8 +632,7 @@ CMD_FUNC(m_server_remote)
}
if ((bconf = Find_ban(NULL, servername, CONF_BAN_SERVER)))
{
sendto_realops
("Cancelling link %s, banned server %s",
sendto_ops_and_log("Cancelling link %s, banned server %s",
get_client_name(cptr, TRUE), servername);
sendto_one(cptr, "ERROR :Banned server (%s)", bconf->reason ? bconf->reason : "no reason");
return exit_client(cptr, cptr, &me, "Brought in banned server");
@@ -644,19 +642,19 @@ CMD_FUNC(m_server_remote)
strlcpy(info, parv[parc - 1], sizeof(info));
if (!cptr->serv->conf)
{
sendto_realops("Lost conf for %s!!, dropping link", cptr->name);
sendto_ops_and_log("Internal error: lost conf for %s!!, dropping link", cptr->name);
return exit_client(cptr, cptr, cptr, "Lost configuration");
}
aconf = cptr->serv->conf;
if (!aconf->hub)
{
sendto_umode(UMODE_OPER, "Link %s cancelled, is Non-Hub but introduced Leaf %s",
sendto_ops_and_log("Link %s cancelled, is Non-Hub but introduced Leaf %s",
cptr->name, servername);
return exit_client(cptr, cptr, cptr, "Non-Hub Link");
}
if (match(aconf->hub, servername))
{
sendto_umode(UMODE_OPER, "Link %s cancelled, linked in %s, which hub config disallows",
sendto_ops_and_log("Link %s cancelled, linked in %s, which hub config disallows",
cptr->name, servername);
return exit_client(cptr, cptr, cptr, "Not matching hub configuration");
}
@@ -664,14 +662,14 @@ CMD_FUNC(m_server_remote)
{
if (match(aconf->leaf, servername))
{
sendto_umode(UMODE_OPER, "Link %s(%s) cancelled, disallowed by leaf configuration",
sendto_ops_and_log("Link %s(%s) cancelled, disallowed by leaf configuration",
cptr->name, servername);
return exit_client(cptr, cptr, cptr, "Disallowed by leaf configuration");
}
}
if (aconf->leaf_depth && (hop > aconf->leaf_depth))
{
sendto_umode(UMODE_OPER, "Link %s(%s) cancelled, too deep depth",
sendto_ops_and_log("Link %s(%s) cancelled, too deep depth",
cptr->name, servername);
return exit_client(cptr, cptr, cptr, "Too deep link depth (leaf)");
}