~emersion/soju-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH v2] Forward MOTD messages downstream

Details
Message ID
<20210609192515.25097-1-greg@gpanders.com>
DKIM signature
pass
Download raw message
Patch: +29 -2
The first MOTD upon connection is ignored, but subsequent MOTD messages
(requested by the "MOTD" message from the client, typically using a
/motd command) are forwarded.
---
 downstream.go |  2 +-
 upstream.go   | 29 ++++++++++++++++++++++++++++-
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/downstream.go b/downstream.go
index e263054..8e94095 100644
--- a/downstream.go
+++ b/downstream.go
@@ -1105,7 +1105,7 @@ func (dc *downstreamConn) welcome() error {
	dc.SendMessage(&irc.Message{
		Prefix:  dc.srv.prefix(),
		Command: irc.ERR_NOMOTD,
		Params:  []string{dc.nick, "No MOTD"},
		Params:  []string{dc.nick, "Use /motd to read the message of the day"},
	})

	dc.updateNick()
diff --git a/upstream.go b/upstream.go
index c812ef1..1f42a24 100644
--- a/upstream.go
+++ b/upstream.go
@@ -103,6 +103,8 @@ type upstreamConn struct {

	// set of LIST commands in progress, per downstream
	pendingLISTDownstreamSet map[uint64]struct{}

	gotMotd bool
}

func connectToUpstream(network *network) (*upstreamConn, error) {
@@ -662,6 +664,21 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
			uc.network.updateCasemapping(casemapRFC1459)
			uc.nickCM = uc.network.casemap(uc.nick)
		}

		if !uc.gotMotd {
			// Ignore the initial MOTD upon connection, but forward
			// subsequent MOTD messages downstream
			uc.gotMotd = true
			return nil
		}

		uc.forEachDownstreamByID(downstreamID, func (dc *downstreamConn) {
			dc.SendMessage(&irc.Message {
				Prefix: uc.srv.prefix(),
				Command: msg.Command,
				Params: msg.Params,
			})
		})
	case "BATCH":
		var tag string
		if err := parseMessageParams(msg, &tag); err != nil {
@@ -1421,7 +1438,17 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
	case irc.RPL_LUSERCLIENT, irc.RPL_LUSEROP, irc.RPL_LUSERUNKNOWN, irc.RPL_LUSERCHANNELS, irc.RPL_LUSERME:
		// Ignore
	case irc.RPL_MOTDSTART, irc.RPL_MOTD:
		// Ignore
		if !uc.gotMotd {
			return nil
		}

		uc.forEachDownstreamByID(downstreamID, func (dc *downstreamConn) {
			dc.SendMessage(&irc.Message {
				Prefix: uc.srv.prefix(),
				Command: msg.Command,
				Params: msg.Params,
			})
		})
	case irc.RPL_LISTSTART:
		// Ignore
	case rpl_localusers, rpl_globalusers:
-- 
2.32.0
Details
Message ID
<geqxtzB0iPK-qhon7-VqGmtSqZRd24qg7R02jkli6cVXpy3Chhw_agHHEJPP0r8yYbJhAimgKapL2lTObh7WGNb2CUxWeJfMfkobytRkSl8=@emersion.fr>
In-Reply-To
<20210609192515.25097-1-greg@gpanders.com> (view parent)
DKIM signature
pass
Download raw message
LGTM.

Pushed, thanks!
Reply to thread Export thread (mbox)