3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-23 03:02:48 +01:00

capability: Remove CAP CLEAR as per IRCv3 recommendations, allow CAP command after registration

This commit is contained in:
Daniel Oaks 2016-04-14 07:30:14 +10:00
parent c3288823af
commit 5ee0f1c205

View File

@ -12,7 +12,6 @@ const (
CAP_REQ CapSubCommand = "REQ" CAP_REQ CapSubCommand = "REQ"
CAP_ACK CapSubCommand = "ACK" CAP_ACK CapSubCommand = "ACK"
CAP_NAK CapSubCommand = "NAK" CAP_NAK CapSubCommand = "NAK"
CAP_CLEAR CapSubCommand = "CLEAR"
CAP_END CapSubCommand = "END" CAP_END CapSubCommand = "END"
) )
@ -101,11 +100,6 @@ func (msg *CapCommand) HandleRegServer(server *Server) {
} }
client.Reply(RplCap(client, CAP_ACK, msg.capabilities)) client.Reply(RplCap(client, CAP_ACK, msg.capabilities))
case CAP_CLEAR:
reply := RplCap(client, CAP_ACK, client.capabilities.DisableString())
client.capabilities = make(CapabilitySet)
client.Reply(reply)
case CAP_END: case CAP_END:
client.capState = CapNegotiated client.capState = CapNegotiated
server.tryRegister(client) server.tryRegister(client)
@ -114,3 +108,34 @@ func (msg *CapCommand) HandleRegServer(server *Server) {
client.ErrInvalidCapCmd(msg.subCommand) client.ErrInvalidCapCmd(msg.subCommand)
} }
} }
func (msg *CapCommand) HandleServer(server *Server) {
client := msg.Client()
switch msg.subCommand {
case CAP_LS:
client.Reply(RplCap(client, CAP_LS, SupportedCapabilities))
case CAP_LIST:
client.Reply(RplCap(client, CAP_LIST, client.capabilities))
case CAP_REQ:
for capability := range msg.capabilities {
if !SupportedCapabilities[capability] {
client.Reply(RplCap(client, CAP_NAK, msg.capabilities))
return
}
}
for capability := range msg.capabilities {
client.capabilities[capability] = true
}
client.Reply(RplCap(client, CAP_ACK, msg.capabilities))
case CAP_END:
// no-op after registration performed
return
default:
client.ErrInvalidCapCmd(msg.subCommand)
}
}