Make an IRC listener connection follow its session's nick (closes #184)
check / check (push) Waiting to run

When the session's nick was changed from another client, such as the
web client over the HTTP API, the IRC listener connection kept the old
nick and sent its messages, joins and later NICK changes under it. Now,
whenever the relay passes on a NICK line, the connection first takes
the nick its session holds in the database. It does not go by the
line's old nick, as the connection may have taken that nick after
another user gave it up. As the relay goroutine can now change the
nick, the command handlers read it under the connection's lock,
through currentNick, as the relay already did.

Model: opus-5-5
This commit is contained in:
2026-10-21 14:04:22 +00:00
parent 129d87d578
commit d90962c960
5 changed files with 176 additions and 45 deletions
+6 -4
View File
@@ -345,7 +345,7 @@ func (c *Conn) sendNumeric(
code irc.IRCMessageType,
params ...string,
) {
nick := c.nick
nick := c.currentNick()
if nick == "" {
nick = "*"
}
@@ -369,9 +369,11 @@ func (c *Conn) sendFromServer(
// hostmask returns the client's full hostmask
// (nick!user@host).
func (c *Conn) hostmask() string {
nick := c.currentNick()
user := c.username
if user == "" {
user = c.nick
user = nick
}
host := c.hostname
@@ -379,7 +381,7 @@ func (c *Conn) hostmask() string {
host = c.remoteIP
}
return c.nick + "!" + user + "@" + host
return nick + "!" + user + "@" + host
}
// handleMessage dispatches a parsed IRC message using
@@ -657,7 +659,7 @@ func (c *Conn) checkPasswordLength(pw string) bool {
return true
}
c.sendFromServer("NOTICE", c.nick,
c.sendFromServer("NOTICE", c.currentNick(),
"Password must be 8 to 72 bytes",
)