Forward MOTD messages downstream
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.
This commit is contained in:
parent
0081c96ec0
commit
2fe0a57e43
@ -1105,7 +1105,7 @@ func (dc *downstreamConn) welcome() error {
|
|||||||
dc.SendMessage(&irc.Message{
|
dc.SendMessage(&irc.Message{
|
||||||
Prefix: dc.srv.prefix(),
|
Prefix: dc.srv.prefix(),
|
||||||
Command: irc.ERR_NOMOTD,
|
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()
|
dc.updateNick()
|
||||||
|
29
upstream.go
29
upstream.go
@ -103,6 +103,8 @@ type upstreamConn struct {
|
|||||||
|
|
||||||
// set of LIST commands in progress, per downstream
|
// set of LIST commands in progress, per downstream
|
||||||
pendingLISTDownstreamSet map[uint64]struct{}
|
pendingLISTDownstreamSet map[uint64]struct{}
|
||||||
|
|
||||||
|
gotMotd bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func connectToUpstream(network *network) (*upstreamConn, error) {
|
func connectToUpstream(network *network) (*upstreamConn, error) {
|
||||||
@ -662,6 +664,21 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
|
|||||||
uc.network.updateCasemapping(casemapRFC1459)
|
uc.network.updateCasemapping(casemapRFC1459)
|
||||||
uc.nickCM = uc.network.casemap(uc.nick)
|
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":
|
case "BATCH":
|
||||||
var tag string
|
var tag string
|
||||||
if err := parseMessageParams(msg, &tag); err != nil {
|
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:
|
case irc.RPL_LUSERCLIENT, irc.RPL_LUSEROP, irc.RPL_LUSERUNKNOWN, irc.RPL_LUSERCHANNELS, irc.RPL_LUSERME:
|
||||||
// Ignore
|
// Ignore
|
||||||
case irc.RPL_MOTDSTART, irc.RPL_MOTD:
|
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:
|
case irc.RPL_LISTSTART:
|
||||||
// Ignore
|
// Ignore
|
||||||
case rpl_localusers, rpl_globalusers:
|
case rpl_localusers, rpl_globalusers:
|
||||||
|
Loading…
Reference in New Issue
Block a user