Update downstream nicks in single-server mode and after NICK
Previously, the downstream nick was never changed, even when the downstream sent a NICK message or was in single-server mode with a different nick. This adds support for updating the downstream nick in the following cases: - when a downstream sends NICK - additionally, in single-server mode: - when a downstream connects and its single network is connected - when an upstream connects - when an upstream sends NICK
This commit is contained in:
parent
566986fdd5
commit
b3742cc731
@ -620,6 +620,17 @@ func (dc *downstreamConn) updateSupportedCaps() {
|
||||
}
|
||||
}
|
||||
|
||||
func (dc *downstreamConn) updateNick() {
|
||||
if uc := dc.upstream(); uc != nil && uc.nick != dc.nick {
|
||||
dc.SendMessage(&irc.Message{
|
||||
Prefix: dc.prefix(),
|
||||
Command: "NICK",
|
||||
Params: []string{uc.nick},
|
||||
})
|
||||
dc.nick = uc.nick
|
||||
}
|
||||
}
|
||||
|
||||
func sanityCheckServer(addr string) error {
|
||||
dialer := net.Dialer{Timeout: 30 * time.Second}
|
||||
conn, err := tls.DialWithDialer(&dialer, "tcp", addr, nil)
|
||||
@ -777,6 +788,8 @@ func (dc *downstreamConn) welcome() error {
|
||||
Params: []string{dc.nick, "No MOTD"},
|
||||
})
|
||||
|
||||
dc.updateNick()
|
||||
|
||||
dc.forEachUpstream(func(uc *upstreamConn) {
|
||||
for _, ch := range uc.channels {
|
||||
if !ch.complete {
|
||||
@ -935,6 +948,15 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
|
||||
dc.forEachUpstream(func(uc *upstreamConn) {
|
||||
uc.SendMessage(msg)
|
||||
})
|
||||
|
||||
if dc.upstream() == nil && dc.nick != nick {
|
||||
dc.SendMessage(&irc.Message{
|
||||
Prefix: dc.prefix(),
|
||||
Command: "NICK",
|
||||
Params: []string{nick},
|
||||
})
|
||||
dc.nick = nick
|
||||
}
|
||||
case "JOIN":
|
||||
var namesStr string
|
||||
if err := parseMessageParams(msg, &namesStr); err != nil {
|
||||
|
@ -656,6 +656,10 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
|
||||
uc.forEachDownstream(func(dc *downstreamConn) {
|
||||
dc.SendMessage(dc.marshalMessage(msg, uc.network))
|
||||
})
|
||||
} else {
|
||||
uc.forEachDownstream(func(dc *downstreamConn) {
|
||||
dc.updateNick()
|
||||
})
|
||||
}
|
||||
case "JOIN":
|
||||
if msg.Prefix == nil {
|
||||
|
Loading…
Reference in New Issue
Block a user