Use dc.nick instead of "*" for RPL_* messages

Makes it clearer what these fields are used for. The default value
for dc.nick is "*".
This commit is contained in:
Simon Ser 2021-12-07 09:42:32 +01:00
parent aae0fb9f22
commit f7e151396d

View File

@ -927,21 +927,21 @@ func (dc *downstreamConn) handleAuthenticateCommand(msg *irc.Message) (result *d
return nil, ircError{&irc.Message{ return nil, ircError{&irc.Message{
Prefix: dc.srv.prefix(), Prefix: dc.srv.prefix(),
Command: irc.ERR_SASLFAIL, Command: irc.ERR_SASLFAIL,
Params: []string{"*", "AUTHENTICATE requires the \"sasl\" capability to be enabled"}, Params: []string{dc.nick, "AUTHENTICATE requires the \"sasl\" capability to be enabled"},
}} }}
} }
if len(msg.Params) == 0 { if len(msg.Params) == 0 {
return nil, ircError{&irc.Message{ return nil, ircError{&irc.Message{
Prefix: dc.srv.prefix(), Prefix: dc.srv.prefix(),
Command: irc.ERR_SASLFAIL, Command: irc.ERR_SASLFAIL,
Params: []string{"*", "Missing AUTHENTICATE argument"}, Params: []string{dc.nick, "Missing AUTHENTICATE argument"},
}} }}
} }
if msg.Params[0] == "*" { if msg.Params[0] == "*" {
return nil, ircError{&irc.Message{ return nil, ircError{&irc.Message{
Prefix: dc.srv.prefix(), Prefix: dc.srv.prefix(),
Command: irc.ERR_SASLABORTED, Command: irc.ERR_SASLABORTED,
Params: []string{"*", "SASL authentication aborted"}, Params: []string{dc.nick, "SASL authentication aborted"},
}} }}
} }
@ -960,7 +960,7 @@ func (dc *downstreamConn) handleAuthenticateCommand(msg *irc.Message) (result *d
return nil, ircError{&irc.Message{ return nil, ircError{&irc.Message{
Prefix: dc.srv.prefix(), Prefix: dc.srv.prefix(),
Command: irc.ERR_SASLFAIL, Command: irc.ERR_SASLFAIL,
Params: []string{"*", fmt.Sprintf("Unsupported SASL mechanism %q", mech)}, Params: []string{dc.nick, fmt.Sprintf("Unsupported SASL mechanism %q", mech)},
}} }}
} }
@ -973,7 +973,7 @@ func (dc *downstreamConn) handleAuthenticateCommand(msg *irc.Message) (result *d
return nil, ircError{&irc.Message{ return nil, ircError{&irc.Message{
Prefix: dc.srv.prefix(), Prefix: dc.srv.prefix(),
Command: irc.ERR_SASLFAIL, Command: irc.ERR_SASLFAIL,
Params: []string{"*", "Invalid base64-encoded response"}, Params: []string{dc.nick, "Invalid base64-encoded response"},
}} }}
} }
} }
@ -1229,7 +1229,7 @@ func (dc *downstreamConn) register(ctx context.Context) error {
dc.endSASL(&irc.Message{ dc.endSASL(&irc.Message{
Prefix: dc.srv.prefix(), Prefix: dc.srv.prefix(),
Command: irc.ERR_SASLABORTED, Command: irc.ERR_SASLABORTED,
Params: []string{"*", "SASL authentication aborted"}, Params: []string{dc.nick, "SASL authentication aborted"},
}) })
} }
@ -1285,7 +1285,7 @@ func (dc *downstreamConn) loadNetwork(ctx context.Context) error {
dc.logger.Printf("failed to connect to %q: %v", addr, err) dc.logger.Printf("failed to connect to %q: %v", addr, err)
return ircError{&irc.Message{ return ircError{&irc.Message{
Command: irc.ERR_PASSWDMISMATCH, Command: irc.ERR_PASSWDMISMATCH,
Params: []string{"*", fmt.Sprintf("Failed to connect to %q", dc.networkName)}, Params: []string{dc.nick, fmt.Sprintf("Failed to connect to %q", dc.networkName)},
}} }}
} }