Remote /MOTD requests redisplay upon reconnection #98

Closed
opened 2026-10-05 03:58:55 +02:00 by adam · 2 comments
Owner

If you're connected to a server such as irc.eversible.com and check the MOTD of another server (remote request) via /motd irc.shoutcast.com the remote MOTD is displayed when you next connect to ZNC instead of the server you're actually currently connected to. I'm not sure if the MOTD in general is cached within ZNC and that is the reason for this behavior, or a new motd is actually retrieved upon reconnection of the user. I assume a new one is fetched, so motd issues a remote request. I haven't upgraded to the latest version yet, so this may be fixed already.

If you're connected to a server such as irc.eversible.com and check the MOTD of another server (remote request) via /motd irc.shoutcast.com the remote MOTD is displayed when you next connect to ZNC instead of the server you're actually currently connected to. I'm not sure if the MOTD in general is cached within ZNC and that is the reason for this behavior, or a new motd is actually retrieved upon reconnection of the user. I assume a new one is fetched, so motd issues a remote request. I haven't upgraded to the latest version yet, so this may be fixed already. <!-- github-sync-id:4126888 -->
adam closed this issue 2026-10-05 03:58:55 +02:00
Author
Owner

It is cached, yes. No new MOTD is retrieved from anywhere when user connects. So just the last MOTD we got from server is displayed to user.

It is cached, yes. No new MOTD is retrieved from anywhere when user connects. So just the last MOTD we got from server is displayed to user. <!-- github-comment-id:5144534 -->
Author
Owner

If you do MOTD <another-server>, the server will send another MOTD. Which may not be its own MOTD. The response will replace the current server's MOTD in our MOTD buffer. We could perhaps only store the MOTD if its for the current server:

diff --git a/src/IRCSock.cpp b/src/IRCSock.cpp
index 7d6b2f4..c14849a 100644
--- a/src/IRCSock.cpp
+++ b/src/IRCSock.cpp
@@ -390,10 +390,14 @@ void CIRCSock::ReadLine(const CString& sData) {
                                break;
                        case 375:  // begin motd
                        case 422:  // MOTD File is missing
-                               m_pNetwork->ClearMotdBuffer();
+                               if (m_pNetwork->GetIRCServer().Equals(sServer)) {
+                                       m_pNetwork->ClearMotdBuffer();
+                               }
                        case 372:  // motd
                        case 376:  // end motd
-                               m_pNetwork->AddMotdBuffer(":" + _NAMEDFMT(sServer) + " " + sCmd + " {target} " + _NAMEDFMT(sRest));
+                               if (m_pNetwork->GetIRCServer().Equals(sServer)) {
+                                       m_pNetwork->AddMotdBuffer(":" + _NAMEDFMT(sServer) + " " + sCmd + " {target} " + _NAMEDFMT(sRest));
+                               }
                                break;
                        case 437:
                                // :irc.server.net 437 * badnick :Nick/channel is temporarily unavailable
If you do `MOTD <another-server>`, the server will send another MOTD. Which may not be its own MOTD. The response will replace the current server's MOTD in our MOTD buffer. We could perhaps only store the MOTD if its for the current server: ``` diff --git a/src/IRCSock.cpp b/src/IRCSock.cpp index 7d6b2f4..c14849a 100644 --- a/src/IRCSock.cpp +++ b/src/IRCSock.cpp @@ -390,10 +390,14 @@ void CIRCSock::ReadLine(const CString& sData) { break; case 375: // begin motd case 422: // MOTD File is missing - m_pNetwork->ClearMotdBuffer(); + if (m_pNetwork->GetIRCServer().Equals(sServer)) { + m_pNetwork->ClearMotdBuffer(); + } case 372: // motd case 376: // end motd - m_pNetwork->AddMotdBuffer(":" + _NAMEDFMT(sServer) + " " + sCmd + " {target} " + _NAMEDFMT(sRest)); + if (m_pNetwork->GetIRCServer().Equals(sServer)) { + m_pNetwork->AddMotdBuffer(":" + _NAMEDFMT(sServer) + " " + sCmd + " {target} " + _NAMEDFMT(sRest)); + } break; case 437: // :irc.server.net 437 * badnick :Nick/channel is temporarily unavailable ``` <!-- github-comment-id:5154400 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/znc#98