De-duplicate downstream QUIT handling

This commit is contained in:
Simon Ser 2020-02-06 22:22:14 +01:00
parent cd7556264e
commit 89f1944d30
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

View File

@ -128,6 +128,8 @@ func (c *downstreamConn) WriteMessage(msg *irc.Message) {
func (c *downstreamConn) handleMessage(msg *irc.Message) error { func (c *downstreamConn) handleMessage(msg *irc.Message) error {
switch msg.Command { switch msg.Command {
case "QUIT":
return c.Close()
case "PING": case "PING":
// TODO: handle params // TODO: handle params
c.WriteMessage(&irc.Message{ c.WriteMessage(&irc.Message{
@ -157,8 +159,6 @@ func (c *downstreamConn) handleMessageUnregistered(msg *irc.Message) error {
} }
c.username = "~" + msg.Params[0] c.username = "~" + msg.Params[0]
c.realname = msg.Params[3] c.realname = msg.Params[3]
case "QUIT":
return c.Close()
default: default:
c.logger.Printf("unhandled message: %v", msg) c.logger.Printf("unhandled message: %v", msg)
return newUnknownCommandError(msg.Command) return newUnknownCommandError(msg.Command)
@ -189,7 +189,7 @@ func (c *downstreamConn) register() error {
c.WriteMessage(&irc.Message{ c.WriteMessage(&irc.Message{
Command: irc.RPL_MYINFO, Command: irc.RPL_MYINFO,
Params: []string{c.nick, c.srv.Hostname, "unknown", "aiwroO", "OovaimnqpsrtklbeI"}, Params: []string{c.nick, c.srv.Hostname, "jounce", "aiwroO", "OovaimnqpsrtklbeI"},
}) })
c.WriteMessage(&irc.Message{ c.WriteMessage(&irc.Message{
@ -210,8 +210,6 @@ func (c *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
"You may not reregister", "You may not reregister",
}, },
}} }}
case "QUIT":
return c.Close()
default: default:
c.logger.Printf("unhandled message: %v", msg) c.logger.Printf("unhandled message: %v", msg)
return newUnknownCommandError(msg.Command) return newUnknownCommandError(msg.Command)