Send any welcome error messages to the downstream
Currently, if we fail connecting to a new networking during welcome, we send no error message to the client, and the connection remains open in an undefined state. Given the input: NICK nick USER user/invalid.xyz s e r PASS pass soju will fail to connect, add a message to its own logs, but will return no message to the downstream. This fixes the issue by forwarding the error message if it is an IRC error message (which it is for connecting to new networks). We should probably also close the connection after the message is written, because it leaves the connection in an undefined state. This is TODO for now because we'd have to wait for the error message to be written out first, which is non-trivial.
This commit is contained in:
parent
9647711921
commit
f5b16dc00c
11
user.go
11
user.go
@ -632,7 +632,18 @@ func (u *user) run() {
|
||||
}
|
||||
|
||||
if err := dc.welcome(context.TODO()); err != nil {
|
||||
if ircErr, ok := err.(ircError); ok {
|
||||
msg := ircErr.Message.Copy()
|
||||
msg.Prefix = dc.srv.prefix()
|
||||
dc.SendMessage(msg)
|
||||
} else {
|
||||
dc.SendMessage(&irc.Message{
|
||||
Command: "ERROR",
|
||||
Params: []string{"Internal server error"},
|
||||
})
|
||||
}
|
||||
dc.logger.Printf("failed to handle new registered connection: %v", err)
|
||||
// TODO: close dc after the error message is sent
|
||||
break
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user