Add upstream CAP LS support
This commit is contained in:
parent
85f28daf2d
commit
e39948cdbd
30
upstream.go
30
upstream.go
@ -47,6 +47,7 @@ type upstreamConn struct {
|
|||||||
modes modeSet
|
modes modeSet
|
||||||
channels map[string]*upstreamChannel
|
channels map[string]*upstreamChannel
|
||||||
history map[string]uint64
|
history map[string]uint64
|
||||||
|
caps map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
func connectToUpstream(network *network) (*upstreamConn, error) {
|
func connectToUpstream(network *network) (*upstreamConn, error) {
|
||||||
@ -77,6 +78,7 @@ func connectToUpstream(network *network) (*upstreamConn, error) {
|
|||||||
ring: NewRing(network.user.srv.RingCap),
|
ring: NewRing(network.user.srv.RingCap),
|
||||||
channels: make(map[string]*upstreamChannel),
|
channels: make(map[string]*upstreamChannel),
|
||||||
history: make(map[string]uint64),
|
history: make(map[string]uint64),
|
||||||
|
caps: make(map[string]string),
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
@ -166,6 +168,29 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
|
|||||||
}
|
}
|
||||||
case "NOTICE":
|
case "NOTICE":
|
||||||
uc.logger.Print(msg)
|
uc.logger.Print(msg)
|
||||||
|
case "CAP":
|
||||||
|
if len(msg.Params) < 2 {
|
||||||
|
return newNeedMoreParamsError(msg.Command)
|
||||||
|
}
|
||||||
|
caps := strings.Fields(msg.Params[len(msg.Params) - 1])
|
||||||
|
more := msg.Params[len(msg.Params) - 2] == "*"
|
||||||
|
|
||||||
|
for _, s := range caps {
|
||||||
|
kv := strings.SplitN(s, "=", 2)
|
||||||
|
k := strings.ToLower(kv[0])
|
||||||
|
var v string
|
||||||
|
if len(kv) >= 2 {
|
||||||
|
v = kv[1]
|
||||||
|
}
|
||||||
|
uc.caps[k] = v
|
||||||
|
}
|
||||||
|
|
||||||
|
if !more {
|
||||||
|
uc.SendMessage(&irc.Message{
|
||||||
|
Command: "CAP",
|
||||||
|
Params: []string{"END"},
|
||||||
|
})
|
||||||
|
}
|
||||||
case irc.RPL_WELCOME:
|
case irc.RPL_WELCOME:
|
||||||
uc.registered = true
|
uc.registered = true
|
||||||
uc.logger.Printf("connection registered")
|
uc.logger.Printf("connection registered")
|
||||||
@ -430,6 +455,11 @@ func (uc *upstreamConn) register() {
|
|||||||
uc.realname = uc.nick
|
uc.realname = uc.nick
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uc.SendMessage(&irc.Message{
|
||||||
|
Command: "CAP",
|
||||||
|
Params: []string{"LS", "302"},
|
||||||
|
})
|
||||||
|
|
||||||
uc.SendMessage(&irc.Message{
|
uc.SendMessage(&irc.Message{
|
||||||
Command: "NICK",
|
Command: "NICK",
|
||||||
Params: []string{uc.nick},
|
Params: []string{uc.nick},
|
||||||
|
Loading…
Reference in New Issue
Block a user