Currently when a user is banned from a network ZNC will try reconnect but it inevitably ends up being disconnected again because the user is still banned. If this happens enough, which is likely as network bans tend to be pretty long, ZNC can end up triggering mass-connection throttling which will then proceed to repeatedly block the user meaning that even if they get unbanned they still won't be able to connect without manually stopping the connection timer, waiting for the throttle to expire, and then reconnecting.
The Solution
Ideally the solution for this would be to listen for ERR_YOUREBANNEDCREEP (465) and disable automatic reconnection for the imminent disconnection. This numeric is from RFC 1459 and as far as I know is pretty well supported by major IRCds so it should not pose any compatibility issues.
## The Problem
Currently when a user is banned from a network ZNC will try reconnect but it inevitably ends up being disconnected again because the user is still banned. If this happens enough, which is likely as network bans tend to be pretty long, ZNC can end up triggering mass-connection throttling which will then proceed to repeatedly block the user meaning that even if they get unbanned they still won't be able to connect without manually stopping the connection timer, waiting for the throttle to expire, and then reconnecting.
## The Solution
Ideally the solution for this would be to listen for ERR_YOUREBANNEDCREEP (465) and disable automatic reconnection for the imminent disconnection. This numeric is from RFC 1459 and as far as I know is pretty well supported by major IRCds so it should not pose any compatibility issues.
<!-- github-sync-id:732826720 -->
for 1 network ppl can set up multiple servers. you can get banned on 1 server, but get in with an other. so perm dc from a network based on a ban from 1 of the servers is not a good idea.
mark the server cuz of a ban and "remove" it from pool (not rly remove, but jump over it) is okay, but idk.. sounds like a hassle.
for 1 network ppl can set up multiple servers. you can get banned on 1 server, but get in with an other. so perm dc from a network based on a ban from 1 of the servers is not a good idea.
mark the server cuz of a ban and "remove" it from pool (not rly remove, but jump over it) is okay, but idk.. sounds like a hassle.
<!-- github-comment-id:748996481 -->
I don't like this feature, but this code works after some quick testing. I think there should be a config setting to enable/disable this. Maybe IRCDisconnectOnBan = true config setting?
The code below needs the translation code for the PutStatus(); message.
$ git diff
diff --git a/src/IRCSock.cpp b/src/IRCSock.cpp
index 007c9216..ae4ace9f 100644
--- a/src/IRCSock.cpp
+++ b/src/IRCSock.cpp
@@ -1057,6 +1057,11 @@ bool CIRCSock::OnNumericMessage(CNumericMessage& Message) {
// Servers that don't support CAP will give us this error, don't send
// it to the client
if (sNick.Equals("CAP")) return true;
+ case 465:
+ // :irc.server.com 465 mynick :You are banned from this server- Temporary K-line 1 min. - Example (2024/12/29 15.39)
+ m_pNetwork->SetIRCConnectEnabled(false);
+ m_pNetwork->PutStatus("You are banned from the network. ZNC has disabled the network.");
+ break;
case 470: {
// :irc.unreal.net 470 mynick [Link] #chan1 has become full, so you are automatically being transferred to the linked channel #chan2
// :mccaffrey.freenode.net 470 mynick #electronics ##electronics :Forwarding to another channel
Testing:
[2024-12-29 15:51:31.127329] (KindOne/foobar) ZNC -> CLI [:*status!status@znc.in PRIVMSG KindOne :You are currently disconnected from IRC. Use 'connect' to reconnect.]
[2024-12-29 15:51:40.147703] (KindOne/foobar) CLI -> ZNC [PRIVMSG *status :jump]
[2024-12-29 15:51:40.148199] (KindOne/foobar) ZNC -> CLI [:*status!status@znc.in PRIVMSG KindOne :Connecting to 127.0.0.1...]
[2024-12-29 15:51:40.148495] Connecting user/network [KindOne/foobar]
[2024-12-29 15:51:40.148673] TDNS: initiating resolving of [127.0.0.1] and bindhost []
[2024-12-29 15:51:40.148885] ConnectQueueTimer done
[2024-12-29 15:51:40.149458] TDNS: IRC::KindOne::foobar, connecting to [127.0.0.1] using bindhost []
[2024-12-29 15:51:40.150055] IRC::KindOne::foobar == Connected()
[2024-12-29 15:51:40.150766] (KindOne/foobar) ZNC -> IRC [CAP LS 302]
[2024-12-29 15:51:40.151513] (KindOne/foobar) ZNC -> IRC [NICK KindOne]
[2024-12-29 15:51:40.152373] (KindOne/foobar) ZNC -> IRC [USER KindOne "KindOne" "KindOne" :...]
// Normal IRC connection stuff and CAP REQ ... <snip>
[2024-12-29 15:51:46.966189] (KindOne/foobar) ZNC -> IRC [CAP END]
// K-Lined.
[2024-12-29 15:51:47.965791] (KindOne/foobar) IRC -> ZNC [:laptop.foobar.net 465 KindOne :You are banned from this server- Temporary K-line 10 min. - asdf (2024/12/29 15.51)]
// Send Message to client and disable network for znc.
[2024-12-29 15:51:47.966570] (KindOne/foobar) ZNC -> CLI [:*status!status@znc.in PRIVMSG KindOne :You are banned from the network. ZNC has disabled the network.]
[2024-12-29 15:51:47.966995] (KindOne/foobar) ZNC -> CLI [@time=2024-12-29T20:51:47.966Z :laptop.foobar.net 465 KindOne :You are banned from this server- Temporary K-line 10 min. - asdf (2024/12/29 15.51)]
[2024-12-29 15:51:47.967650] (KindOne/foobar) ZNC -> CLI [@time=2024-12-29T20:51:47.967Z :irc.znc.in CAP KindOne DEL :account-notify]
[2024-12-29 15:51:47.967904] (KindOne/foobar) ZNC -> CLI [@time=2024-12-29T20:51:47.967Z :irc.znc.in CAP KindOne DEL :account-tag]
[2024-12-29 15:51:47.968145] (KindOne/foobar) ZNC -> CLI [@time=2024-12-29T20:51:47.967Z :irc.znc.in CAP KindOne DEL :away-notify]
[2024-12-29 15:51:47.968379] (KindOne/foobar) ZNC -> CLI [@time=2024-12-29T20:51:47.968Z :irc.znc.in CAP KindOne DEL :extended-join]
[2024-12-29 15:51:47.970486] IRC::KindOne::foobar == Disconnected()
I don't like this feature, but this code works after some quick testing. I think there should be a config setting to enable/disable this. Maybe ```IRCDisconnectOnBan = true``` config setting?
The code below needs the translation code for the ```PutStatus();``` message.
```
$ git diff
diff --git a/src/IRCSock.cpp b/src/IRCSock.cpp
index 007c9216..ae4ace9f 100644
--- a/src/IRCSock.cpp
+++ b/src/IRCSock.cpp
@@ -1057,6 +1057,11 @@ bool CIRCSock::OnNumericMessage(CNumericMessage& Message) {
// Servers that don't support CAP will give us this error, don't send
// it to the client
if (sNick.Equals("CAP")) return true;
+ case 465:
+ // :irc.server.com 465 mynick :You are banned from this server- Temporary K-line 1 min. - Example (2024/12/29 15.39)
+ m_pNetwork->SetIRCConnectEnabled(false);
+ m_pNetwork->PutStatus("You are banned from the network. ZNC has disabled the network.");
+ break;
case 470: {
// :irc.unreal.net 470 mynick [Link] #chan1 has become full, so you are automatically being transferred to the linked channel #chan2
// :mccaffrey.freenode.net 470 mynick #electronics ##electronics :Forwarding to another channel
```
Testing:
```
[2024-12-29 15:51:31.127329] (KindOne/foobar) ZNC -> CLI [:*status!status@znc.in PRIVMSG KindOne :You are currently disconnected from IRC. Use 'connect' to reconnect.]
[2024-12-29 15:51:40.147703] (KindOne/foobar) CLI -> ZNC [PRIVMSG *status :jump]
[2024-12-29 15:51:40.148199] (KindOne/foobar) ZNC -> CLI [:*status!status@znc.in PRIVMSG KindOne :Connecting to 127.0.0.1...]
[2024-12-29 15:51:40.148495] Connecting user/network [KindOne/foobar]
[2024-12-29 15:51:40.148673] TDNS: initiating resolving of [127.0.0.1] and bindhost []
[2024-12-29 15:51:40.148885] ConnectQueueTimer done
[2024-12-29 15:51:40.149458] TDNS: IRC::KindOne::foobar, connecting to [127.0.0.1] using bindhost []
[2024-12-29 15:51:40.150055] IRC::KindOne::foobar == Connected()
[2024-12-29 15:51:40.150766] (KindOne/foobar) ZNC -> IRC [CAP LS 302]
[2024-12-29 15:51:40.151513] (KindOne/foobar) ZNC -> IRC [NICK KindOne]
[2024-12-29 15:51:40.152373] (KindOne/foobar) ZNC -> IRC [USER KindOne "KindOne" "KindOne" :...]
// Normal IRC connection stuff and CAP REQ ... <snip>
[2024-12-29 15:51:46.966189] (KindOne/foobar) ZNC -> IRC [CAP END]
// K-Lined.
[2024-12-29 15:51:47.965791] (KindOne/foobar) IRC -> ZNC [:laptop.foobar.net 465 KindOne :You are banned from this server- Temporary K-line 10 min. - asdf (2024/12/29 15.51)]
// Send Message to client and disable network for znc.
[2024-12-29 15:51:47.966570] (KindOne/foobar) ZNC -> CLI [:*status!status@znc.in PRIVMSG KindOne :You are banned from the network. ZNC has disabled the network.]
[2024-12-29 15:51:47.966995] (KindOne/foobar) ZNC -> CLI [@time=2024-12-29T20:51:47.966Z :laptop.foobar.net 465 KindOne :You are banned from this server- Temporary K-line 10 min. - asdf (2024/12/29 15.51)]
[2024-12-29 15:51:47.967650] (KindOne/foobar) ZNC -> CLI [@time=2024-12-29T20:51:47.967Z :irc.znc.in CAP KindOne DEL :account-notify]
[2024-12-29 15:51:47.967904] (KindOne/foobar) ZNC -> CLI [@time=2024-12-29T20:51:47.967Z :irc.znc.in CAP KindOne DEL :account-tag]
[2024-12-29 15:51:47.968145] (KindOne/foobar) ZNC -> CLI [@time=2024-12-29T20:51:47.967Z :irc.znc.in CAP KindOne DEL :away-notify]
[2024-12-29 15:51:47.968379] (KindOne/foobar) ZNC -> CLI [@time=2024-12-29T20:51:47.968Z :irc.znc.in CAP KindOne DEL :extended-join]
[2024-12-29 15:51:47.970486] IRC::KindOne::foobar == Disconnected()
```
<!-- github-comment-id:2564837832 -->
I think there should be a config setting to enable/disable this. Maybe IRCDisconnectOnBan = true config setting?
What you've done here can easily be in a module, which naturally allows enabling/disabling
> I think there should be a config setting to enable/disable this. Maybe IRCDisconnectOnBan = true config setting?
What you've done here can easily be in a module, which naturally allows enabling/disabling
<!-- github-comment-id:2564838499 -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
The Problem
Currently when a user is banned from a network ZNC will try reconnect but it inevitably ends up being disconnected again because the user is still banned. If this happens enough, which is likely as network bans tend to be pretty long, ZNC can end up triggering mass-connection throttling which will then proceed to repeatedly block the user meaning that even if they get unbanned they still won't be able to connect without manually stopping the connection timer, waiting for the throttle to expire, and then reconnecting.
The Solution
Ideally the solution for this would be to listen for ERR_YOUREBANNEDCREEP (465) and disable automatic reconnection for the imminent disconnection. This numeric is from RFC 1459 and as far as I know is pretty well supported by major IRCds so it should not pose any compatibility issues.
for 1 network ppl can set up multiple servers. you can get banned on 1 server, but get in with an other. so perm dc from a network based on a ban from 1 of the servers is not a good idea.
mark the server cuz of a ban and "remove" it from pool (not rly remove, but jump over it) is okay, but idk.. sounds like a hassle.
I don't like this feature, but this code works after some quick testing. I think there should be a config setting to enable/disable this. Maybe
IRCDisconnectOnBan = trueconfig setting?The code below needs the translation code for the
PutStatus();message.Testing:
What you've done here can easily be in a module, which naturally allows enabling/disabling
Done: https://github.com/RealKindOne/znc-modules/blob/master/disconnectonban.cpp