mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
Move caps to their own package to prevent conflicts
This commit is contained in:
parent
830484feb6
commit
9bfdc4fdfb
@ -15,6 +15,7 @@ import (
|
||||
|
||||
"github.com/goshuirc/irc-go/ircfmt"
|
||||
"github.com/goshuirc/irc-go/ircmsg"
|
||||
"github.com/oragono/oragono/irc/caps"
|
||||
"github.com/oragono/oragono/irc/sno"
|
||||
"github.com/tidwall/buntdb"
|
||||
)
|
||||
@ -286,7 +287,7 @@ func (client *Client) LogoutOfAccount() {
|
||||
client.account = nil
|
||||
|
||||
// dispatch account-notify
|
||||
for friend := range client.Friends(AccountNotify) {
|
||||
for friend := range client.Friends(caps.AccountNotify) {
|
||||
friend.Send(nil, client.nickMaskString, "ACCOUNT", "*")
|
||||
}
|
||||
}
|
||||
@ -349,7 +350,7 @@ func (client *Client) successfulSaslAuth() {
|
||||
client.Send(nil, client.server.name, RPL_SASLSUCCESS, client.nick, "SASL authentication successful")
|
||||
|
||||
// dispatch account-notify
|
||||
for friend := range client.Friends(AccountNotify) {
|
||||
for friend := range client.Friends(caps.AccountNotify) {
|
||||
friend.Send(nil, client.nickMaskString, "ACCOUNT", client.account.Name)
|
||||
}
|
||||
}
|
||||
|
@ -8,76 +8,35 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/goshuirc/irc-go/ircmsg"
|
||||
)
|
||||
|
||||
// Capability represents an optional feature that a client may request from the server.
|
||||
type Capability string
|
||||
|
||||
const (
|
||||
// AccountNotify is this IRCv3 capability: http://ircv3.net/specs/extensions/account-notify-3.1.html
|
||||
AccountNotify Capability = "account-notify"
|
||||
// AccountTag is this IRCv3 capability: http://ircv3.net/specs/extensions/account-tag-3.2.html
|
||||
AccountTag Capability = "account-tag"
|
||||
// AwayNotify is this IRCv3 capability: http://ircv3.net/specs/extensions/away-notify-3.1.html
|
||||
AwayNotify Capability = "away-notify"
|
||||
// CapNotify is this IRCv3 capability: http://ircv3.net/specs/extensions/cap-notify-3.2.html
|
||||
CapNotify Capability = "cap-notify"
|
||||
// ChgHost is this IRCv3 capability: http://ircv3.net/specs/extensions/chghost-3.2.html
|
||||
ChgHost Capability = "chghost"
|
||||
// EchoMessage is this IRCv3 capability: http://ircv3.net/specs/extensions/echo-message-3.2.html
|
||||
EchoMessage Capability = "echo-message"
|
||||
// ExtendedJoin is this IRCv3 capability: http://ircv3.net/specs/extensions/extended-join-3.1.html
|
||||
ExtendedJoin Capability = "extended-join"
|
||||
// InviteNotify is this IRCv3 capability: http://ircv3.net/specs/extensions/invite-notify-3.2.html
|
||||
InviteNotify Capability = "invite-notify"
|
||||
// MaxLine is this proposed capability: https://github.com/DanielOaks/ircv3-specifications/blob/master+line-lengths/extensions/line-lengths.md
|
||||
MaxLine Capability = "draft/maxline"
|
||||
// MessageTags is this draft IRCv3 capability: http://ircv3.net/specs/core/message-tags-3.3.html
|
||||
MessageTags Capability = "draft/message-tags-0.2"
|
||||
// MultiPrefix is this IRCv3 capability: http://ircv3.net/specs/extensions/multi-prefix-3.1.html
|
||||
MultiPrefix Capability = "multi-prefix"
|
||||
// Rename is this proposed capability: https://github.com/SaberUK/ircv3-specifications/blob/rename/extensions/rename.md
|
||||
Rename Capability = "draft/rename"
|
||||
// SASL is this IRCv3 capability: http://ircv3.net/specs/extensions/sasl-3.2.html
|
||||
SASL Capability = "sasl"
|
||||
// ServerTime is this IRCv3 capability: http://ircv3.net/specs/extensions/server-time-3.2.html
|
||||
ServerTime Capability = "server-time"
|
||||
// STS is this draft IRCv3 capability: http://ircv3.net/specs/core/sts-3.3.html
|
||||
STS Capability = "draft/sts"
|
||||
// UserhostInNames is this IRCv3 capability: http://ircv3.net/specs/extensions/userhost-in-names-3.2.html
|
||||
UserhostInNames Capability = "userhost-in-names"
|
||||
"github.com/oragono/oragono/irc/caps"
|
||||
)
|
||||
|
||||
var (
|
||||
// SupportedCapabilities are the caps we advertise.
|
||||
SupportedCapabilities = CapabilitySet{
|
||||
AccountTag: true,
|
||||
AccountNotify: true,
|
||||
AwayNotify: true,
|
||||
CapNotify: true,
|
||||
ChgHost: true,
|
||||
EchoMessage: true,
|
||||
ExtendedJoin: true,
|
||||
InviteNotify: true,
|
||||
caps.AccountTag: true,
|
||||
caps.AccountNotify: true,
|
||||
caps.AwayNotify: true,
|
||||
caps.CapNotify: true,
|
||||
caps.ChgHost: true,
|
||||
caps.EchoMessage: true,
|
||||
caps.ExtendedJoin: true,
|
||||
caps.InviteNotify: true,
|
||||
// MaxLine is set during server startup
|
||||
MessageTags: true,
|
||||
MultiPrefix: true,
|
||||
Rename: true,
|
||||
caps.MessageTags: true,
|
||||
caps.MultiPrefix: true,
|
||||
caps.Rename: true,
|
||||
// SASL is set during server startup
|
||||
ServerTime: true,
|
||||
caps.ServerTime: true,
|
||||
// STS is set during server startup
|
||||
UserhostInNames: true,
|
||||
caps.UserhostInNames: true,
|
||||
}
|
||||
// CapValues are the actual values we advertise to v3.2 clients.
|
||||
CapValues = map[Capability]string{
|
||||
SASL: "PLAIN,EXTERNAL",
|
||||
CapValues = map[caps.Capability]string{
|
||||
caps.SASL: "PLAIN,EXTERNAL",
|
||||
}
|
||||
)
|
||||
|
||||
func (capability Capability) String() string {
|
||||
return string(capability)
|
||||
}
|
||||
|
||||
// CapState shows whether we're negotiating caps, finished, etc for connection registration.
|
||||
type CapState uint
|
||||
|
||||
@ -101,7 +60,7 @@ const (
|
||||
)
|
||||
|
||||
// CapabilitySet is used to track supported, enabled, and existing caps.
|
||||
type CapabilitySet map[Capability]bool
|
||||
type CapabilitySet map[caps.Capability]bool
|
||||
|
||||
func (set CapabilitySet) String(version CapVersion) string {
|
||||
strs := make([]string, len(set))
|
||||
@ -131,7 +90,7 @@ func capHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||
strs := strings.Split(capString, " ")
|
||||
for _, str := range strs {
|
||||
if len(str) > 0 {
|
||||
capabilities[Capability(str)] = true
|
||||
capabilities[caps.Capability(str)] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
50
irc/caps/constants.go
Normal file
50
irc/caps/constants.go
Normal file
@ -0,0 +1,50 @@
|
||||
// Package caps holds capabilities.
|
||||
package caps
|
||||
|
||||
// Capability represents an optional feature that a client may request from the server.
|
||||
type Capability string
|
||||
|
||||
const (
|
||||
// AccountNotify is this IRCv3 capability: http://ircv3.net/specs/extensions/account-notify-3.1.html
|
||||
AccountNotify Capability = "account-notify"
|
||||
// AccountTag is this IRCv3 capability: http://ircv3.net/specs/extensions/account-tag-3.2.html
|
||||
AccountTag Capability = "account-tag"
|
||||
// AwayNotify is this IRCv3 capability: http://ircv3.net/specs/extensions/away-notify-3.1.html
|
||||
AwayNotify Capability = "away-notify"
|
||||
// Batch is this IRCv3 capability: http://ircv3.net/specs/extensions/batch-3.2.html
|
||||
Batch Capability = "batch"
|
||||
// CapNotify is this IRCv3 capability: http://ircv3.net/specs/extensions/cap-notify-3.2.html
|
||||
CapNotify Capability = "cap-notify"
|
||||
// ChgHost is this IRCv3 capability: http://ircv3.net/specs/extensions/chghost-3.2.html
|
||||
ChgHost Capability = "chghost"
|
||||
// EchoMessage is this IRCv3 capability: http://ircv3.net/specs/extensions/echo-message-3.2.html
|
||||
EchoMessage Capability = "echo-message"
|
||||
// ExtendedJoin is this IRCv3 capability: http://ircv3.net/specs/extensions/extended-join-3.1.html
|
||||
ExtendedJoin Capability = "extended-join"
|
||||
// InviteNotify is this IRCv3 capability: http://ircv3.net/specs/extensions/invite-notify-3.2.html
|
||||
InviteNotify Capability = "invite-notify"
|
||||
// LabeledResponse is this draft IRCv3 capability: http://ircv3.net/specs/extensions/labeled-response.html
|
||||
LabeledResponse Capability = "draft/labeled-response"
|
||||
// MaxLine is this proposed capability: https://github.com/DanielOaks/ircv3-specifications/blob/master+line-lengths/extensions/line-lengths.md
|
||||
MaxLine Capability = "draft/maxline"
|
||||
// MessageIDs is this draft IRCv3 capability: http://ircv3.net/specs/extensions/message-ids.html
|
||||
MessageIDs Capability = "draft/message-ids"
|
||||
// MessageTags is this draft IRCv3 capability: http://ircv3.net/specs/core/message-tags-3.3.html
|
||||
MessageTags Capability = "draft/message-tags-0.2"
|
||||
// MultiPrefix is this IRCv3 capability: http://ircv3.net/specs/extensions/multi-prefix-3.1.html
|
||||
MultiPrefix Capability = "multi-prefix"
|
||||
// Rename is this proposed capability: https://github.com/SaberUK/ircv3-specifications/blob/rename/extensions/rename.md
|
||||
Rename Capability = "draft/rename"
|
||||
// SASL is this IRCv3 capability: http://ircv3.net/specs/extensions/sasl-3.2.html
|
||||
SASL Capability = "sasl"
|
||||
// ServerTime is this IRCv3 capability: http://ircv3.net/specs/extensions/server-time-3.2.html
|
||||
ServerTime Capability = "server-time"
|
||||
// STS is this draft IRCv3 capability: http://ircv3.net/specs/core/sts-3.3.html
|
||||
STS Capability = "draft/sts"
|
||||
// UserhostInNames is this IRCv3 capability: http://ircv3.net/specs/extensions/userhost-in-names-3.2.html
|
||||
UserhostInNames Capability = "userhost-in-names"
|
||||
)
|
||||
|
||||
func (capability Capability) String() string {
|
||||
return string(capability)
|
||||
}
|
@ -14,6 +14,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/goshuirc/irc-go/ircmsg"
|
||||
"github.com/oragono/oragono/irc/caps"
|
||||
"github.com/tidwall/buntdb"
|
||||
)
|
||||
|
||||
@ -164,8 +165,8 @@ func (modes ModeSet) Prefixes(isMultiPrefix bool) string {
|
||||
}
|
||||
|
||||
func (channel *Channel) nicksNoMutex(target *Client) []string {
|
||||
isMultiPrefix := (target != nil) && target.capabilities[MultiPrefix]
|
||||
isUserhostInNames := (target != nil) && target.capabilities[UserhostInNames]
|
||||
isMultiPrefix := (target != nil) && target.capabilities[caps.MultiPrefix]
|
||||
isUserhostInNames := (target != nil) && target.capabilities[caps.UserhostInNames]
|
||||
nicks := make([]string, len(channel.members))
|
||||
i := 0
|
||||
for client, modes := range channel.members {
|
||||
@ -261,7 +262,7 @@ func (channel *Channel) Join(client *Client, key string) {
|
||||
client.server.logger.Debug("join", fmt.Sprintf("%s joined channel %s", client.nick, channel.name))
|
||||
|
||||
for member := range channel.members {
|
||||
if member.capabilities[ExtendedJoin] {
|
||||
if member.capabilities[caps.ExtendedJoin] {
|
||||
member.Send(nil, client.nickMaskString, "JOIN", channel.name, client.account.Name, client.realname)
|
||||
} else {
|
||||
member.Send(nil, client.nickMaskString, "JOIN", channel.name)
|
||||
@ -313,7 +314,7 @@ func (channel *Channel) Join(client *Client, key string) {
|
||||
return nil
|
||||
})
|
||||
|
||||
if client.capabilities[ExtendedJoin] {
|
||||
if client.capabilities[caps.ExtendedJoin] {
|
||||
client.Send(nil, client.nickMaskString, "JOIN", channel.name, client.account.Name, client.realname)
|
||||
} else {
|
||||
client.Send(nil, client.nickMaskString, "JOIN", channel.name)
|
||||
@ -441,11 +442,11 @@ func (channel *Channel) CanSpeak(client *Client) bool {
|
||||
|
||||
// TagMsg sends a tag message to everyone in this channel who can accept them.
|
||||
func (channel *Channel) TagMsg(msgid string, minPrefix *Mode, clientOnlyTags *map[string]ircmsg.TagValue, client *Client) {
|
||||
channel.sendMessage(msgid, "TAGMSG", []Capability{MessageTags}, minPrefix, clientOnlyTags, client, nil)
|
||||
channel.sendMessage(msgid, "TAGMSG", []caps.Capability{caps.MessageTags}, minPrefix, clientOnlyTags, client, nil)
|
||||
}
|
||||
|
||||
// sendMessage sends a given message to everyone on this channel.
|
||||
func (channel *Channel) sendMessage(msgid, cmd string, requiredCaps []Capability, minPrefix *Mode, clientOnlyTags *map[string]ircmsg.TagValue, client *Client, message *string) {
|
||||
func (channel *Channel) sendMessage(msgid, cmd string, requiredCaps []caps.Capability, minPrefix *Mode, clientOnlyTags *map[string]ircmsg.TagValue, client *Client, message *string) {
|
||||
if !channel.CanSpeak(client) {
|
||||
client.Send(nil, client.server.name, ERR_CANNOTSENDTOCHAN, channel.name, "Cannot send to channel")
|
||||
return
|
||||
@ -464,7 +465,7 @@ func (channel *Channel) sendMessage(msgid, cmd string, requiredCaps []Capability
|
||||
// STATUSMSG
|
||||
continue
|
||||
}
|
||||
if member == client && !client.capabilities[EchoMessage] {
|
||||
if member == client && !client.capabilities[caps.EchoMessage] {
|
||||
continue
|
||||
}
|
||||
|
||||
@ -479,7 +480,7 @@ func (channel *Channel) sendMessage(msgid, cmd string, requiredCaps []Capability
|
||||
}
|
||||
|
||||
var messageTagsToUse *map[string]ircmsg.TagValue
|
||||
if member.capabilities[MessageTags] {
|
||||
if member.capabilities[caps.MessageTags] {
|
||||
messageTagsToUse = clientOnlyTags
|
||||
}
|
||||
|
||||
@ -520,11 +521,11 @@ func (channel *Channel) sendSplitMessage(msgid, cmd string, minPrefix *Mode, cli
|
||||
// STATUSMSG
|
||||
continue
|
||||
}
|
||||
if member == client && !client.capabilities[EchoMessage] {
|
||||
if member == client && !client.capabilities[caps.EchoMessage] {
|
||||
continue
|
||||
}
|
||||
var tagsToUse *map[string]ircmsg.TagValue
|
||||
if member.capabilities[MessageTags] {
|
||||
if member.capabilities[caps.MessageTags] {
|
||||
tagsToUse = clientOnlyTags
|
||||
}
|
||||
|
||||
@ -728,7 +729,7 @@ func (channel *Channel) Invite(invitee *Client, inviter *Client) {
|
||||
|
||||
// send invite-notify
|
||||
for member := range channel.members {
|
||||
if member.capabilities[InviteNotify] && member != inviter && member != invitee && channel.ClientIsAtLeast(member, Halfop) {
|
||||
if member.capabilities[caps.InviteNotify] && member != inviter && member != invitee && channel.ClientIsAtLeast(member, Halfop) {
|
||||
member.Send(nil, inviter.nickMaskString, "INVITE", invitee.nick, channel.name)
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ import (
|
||||
"github.com/goshuirc/irc-go/ircfmt"
|
||||
"github.com/goshuirc/irc-go/ircmsg"
|
||||
ident "github.com/oragono/go-ident"
|
||||
"github.com/oragono/oragono/irc/caps"
|
||||
"github.com/oragono/oragono/irc/sno"
|
||||
)
|
||||
|
||||
@ -177,10 +178,10 @@ func (client *Client) IPString() string {
|
||||
func (client *Client) maxlens() (int, int) {
|
||||
maxlenTags := 512
|
||||
maxlenRest := 512
|
||||
if client.capabilities[MessageTags] {
|
||||
if client.capabilities[caps.MessageTags] {
|
||||
maxlenTags = 4096
|
||||
}
|
||||
if client.capabilities[MaxLine] {
|
||||
if client.capabilities[caps.MaxLine] {
|
||||
if client.server.limits.LineLen.Tags > maxlenTags {
|
||||
maxlenTags = client.server.limits.LineLen.Tags
|
||||
}
|
||||
@ -356,7 +357,7 @@ func (client *Client) ModeString() (str string) {
|
||||
}
|
||||
|
||||
// Friends refers to clients that share a channel with this client.
|
||||
func (client *Client) Friends(Capabilities ...Capability) ClientSet {
|
||||
func (client *Client) Friends(Capabilities ...caps.Capability) ClientSet {
|
||||
friends := make(ClientSet)
|
||||
|
||||
// make sure that I have the right caps
|
||||
@ -579,7 +580,7 @@ func (client *Client) destroy() {
|
||||
// SendSplitMsgFromClient sends an IRC PRIVMSG/NOTICE coming from a specific client.
|
||||
// Adds account-tag to the line as well.
|
||||
func (client *Client) SendSplitMsgFromClient(msgid string, from *Client, tags *map[string]ircmsg.TagValue, command, target string, message SplitMessage) {
|
||||
if client.capabilities[MaxLine] {
|
||||
if client.capabilities[caps.MaxLine] {
|
||||
client.SendFromClient(msgid, from, tags, command, target, message.ForMaxLine)
|
||||
} else {
|
||||
for _, str := range message.For512 {
|
||||
@ -592,7 +593,7 @@ func (client *Client) SendSplitMsgFromClient(msgid string, from *Client, tags *m
|
||||
// Adds account-tag to the line as well.
|
||||
func (client *Client) SendFromClient(msgid string, from *Client, tags *map[string]ircmsg.TagValue, command string, params ...string) error {
|
||||
// attach account-tag
|
||||
if client.capabilities[AccountTag] && from.account != &NoAccount {
|
||||
if client.capabilities[caps.AccountTag] && from.account != &NoAccount {
|
||||
if tags == nil {
|
||||
tags = ircmsg.MakeTags("account", from.account.Name)
|
||||
} else {
|
||||
@ -600,7 +601,7 @@ func (client *Client) SendFromClient(msgid string, from *Client, tags *map[strin
|
||||
}
|
||||
}
|
||||
// attach message-id
|
||||
if len(msgid) > 0 && client.capabilities[MessageTags] {
|
||||
if len(msgid) > 0 && client.capabilities[caps.MessageTags] {
|
||||
if tags == nil {
|
||||
tags = ircmsg.MakeTags("draft/msgid", msgid)
|
||||
} else {
|
||||
@ -627,7 +628,7 @@ var (
|
||||
// Send sends an IRC line to the client.
|
||||
func (client *Client) Send(tags *map[string]ircmsg.TagValue, prefix string, command string, params ...string) error {
|
||||
// attach server-time
|
||||
if client.capabilities[ServerTime] {
|
||||
if client.capabilities[caps.ServerTime] {
|
||||
t := time.Now().UTC().Format("2006-01-02T15:04:05.999Z")
|
||||
if tags == nil {
|
||||
tags = ircmsg.MakeTags("time", t)
|
||||
@ -677,7 +678,7 @@ func (client *Client) Send(tags *map[string]ircmsg.TagValue, prefix string, comm
|
||||
// Notice sends the client a notice from the server.
|
||||
func (client *Client) Notice(text string) {
|
||||
limit := 400
|
||||
if client.capabilities[MaxLine] {
|
||||
if client.capabilities[caps.MaxLine] {
|
||||
limit = client.server.limits.LineLen.Rest - 110
|
||||
}
|
||||
lines := wordWrap(text, limit)
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/goshuirc/irc-go/ircmatch"
|
||||
"github.com/oragono/oragono/irc/caps"
|
||||
|
||||
"sync"
|
||||
)
|
||||
@ -155,7 +156,7 @@ func (clients *ClientLookupSet) Replace(oldNick, newNick string, client *Client)
|
||||
}
|
||||
|
||||
// AllWithCaps returns all clients with the given capabilities.
|
||||
func (clients *ClientLookupSet) AllWithCaps(caps ...Capability) (set ClientSet) {
|
||||
func (clients *ClientLookupSet) AllWithCaps(caps ...caps.Capability) (set ClientSet) {
|
||||
set = make(ClientSet)
|
||||
|
||||
clients.ByNickMutex.RLock()
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/goshuirc/irc-go/ircmsg"
|
||||
"github.com/oragono/oragono/irc/caps"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -89,7 +90,7 @@ func sendRoleplayMessage(server *Server, client *Client, source string, targetSt
|
||||
|
||||
channel.membersMutex.RLock()
|
||||
for member := range channel.members {
|
||||
if member == client && !client.capabilities[EchoMessage] {
|
||||
if member == client && !client.capabilities[caps.EchoMessage] {
|
||||
continue
|
||||
}
|
||||
member.Send(nil, source, "PRIVMSG", channel.name, message)
|
||||
@ -109,7 +110,7 @@ func sendRoleplayMessage(server *Server, client *Client, source string, targetSt
|
||||
}
|
||||
|
||||
user.Send(nil, source, "PRIVMSG", user.nick, message)
|
||||
if client.capabilities[EchoMessage] {
|
||||
if client.capabilities[caps.EchoMessage] {
|
||||
client.Send(nil, source, "PRIVMSG", user.nick, message)
|
||||
}
|
||||
if user.flags[Away] {
|
||||
|
@ -25,6 +25,7 @@ import (
|
||||
|
||||
"github.com/goshuirc/irc-go/ircfmt"
|
||||
"github.com/goshuirc/irc-go/ircmsg"
|
||||
"github.com/oragono/oragono/irc/caps"
|
||||
"github.com/oragono/oragono/irc/logger"
|
||||
"github.com/oragono/oragono/irc/sno"
|
||||
"github.com/tidwall/buntdb"
|
||||
@ -641,11 +642,11 @@ func renameHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||
|
||||
// send RENAME messages
|
||||
for mcl := range channel.members {
|
||||
if mcl.capabilities[Rename] {
|
||||
if mcl.capabilities[caps.Rename] {
|
||||
mcl.Send(nil, client.nickMaskString, "RENAME", oldName, newName, reason)
|
||||
} else {
|
||||
mcl.Send(nil, mcl.nickMaskString, "PART", oldName, fmt.Sprintf("Channel renamed: %s", reason))
|
||||
if mcl.capabilities[ExtendedJoin] {
|
||||
if mcl.capabilities[caps.ExtendedJoin] {
|
||||
accountName := "*"
|
||||
if mcl.account != nil {
|
||||
accountName = mcl.account.Name
|
||||
@ -824,7 +825,7 @@ func privmsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool
|
||||
message := msg.Params[1]
|
||||
|
||||
// split privmsg
|
||||
splitMsg := server.splitMessage(message, !client.capabilities[MaxLine])
|
||||
splitMsg := server.splitMessage(message, !client.capabilities[caps.MaxLine])
|
||||
|
||||
for i, targetString := range targets {
|
||||
// max of four targets per privmsg
|
||||
@ -868,7 +869,7 @@ func privmsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool
|
||||
}
|
||||
continue
|
||||
}
|
||||
if !user.capabilities[MessageTags] {
|
||||
if !user.capabilities[caps.MessageTags] {
|
||||
clientOnlyTags = nil
|
||||
}
|
||||
msgid := server.generateMessageID()
|
||||
@ -877,7 +878,7 @@ func privmsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool
|
||||
if !user.flags[RegisteredOnly] || client.registered {
|
||||
user.SendSplitMsgFromClient(msgid, client, clientOnlyTags, "PRIVMSG", user.nick, splitMsg)
|
||||
}
|
||||
if client.capabilities[EchoMessage] {
|
||||
if client.capabilities[caps.EchoMessage] {
|
||||
client.SendSplitMsgFromClient(msgid, client, clientOnlyTags, "PRIVMSG", user.nick, splitMsg)
|
||||
}
|
||||
if user.flags[Away] {
|
||||
@ -938,11 +939,11 @@ func tagmsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||
msgid := server.generateMessageID()
|
||||
|
||||
// end user can't receive tagmsgs
|
||||
if !user.capabilities[MessageTags] {
|
||||
if !user.capabilities[caps.MessageTags] {
|
||||
continue
|
||||
}
|
||||
user.SendFromClient(msgid, client, clientOnlyTags, "TAGMSG", user.nick)
|
||||
if client.capabilities[EchoMessage] {
|
||||
if client.capabilities[caps.EchoMessage] {
|
||||
client.SendFromClient(msgid, client, clientOnlyTags, "TAGMSG", user.nick)
|
||||
}
|
||||
if user.flags[Away] {
|
||||
@ -956,7 +957,7 @@ func tagmsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||
|
||||
// WhoisChannelsNames returns the common channel names between two users.
|
||||
func (client *Client) WhoisChannelsNames(target *Client) []string {
|
||||
isMultiPrefix := target.capabilities[MultiPrefix]
|
||||
isMultiPrefix := target.capabilities[caps.MultiPrefix]
|
||||
var chstrs []string
|
||||
index := 0
|
||||
for channel := range client.channels {
|
||||
@ -1061,7 +1062,7 @@ func (target *Client) RplWhoReplyNoMutex(channel *Channel, client *Client) {
|
||||
}
|
||||
|
||||
if channel != nil {
|
||||
flags += channel.members[client].Prefixes(target.capabilities[MultiPrefix])
|
||||
flags += channel.members[client].Prefixes(target.capabilities[caps.MultiPrefix])
|
||||
channelName = channel.name
|
||||
}
|
||||
target.Send(nil, target.server.name, RPL_WHOREPLY, target.nick, channelName, client.username, client.hostname, client.server.name, client.nick, flags, strconv.Itoa(client.hops)+" "+client.realname)
|
||||
@ -1151,7 +1152,7 @@ func operHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||
|
||||
// push new vhost if one is set
|
||||
if len(server.operators[name].Vhost) > 0 {
|
||||
for fClient := range client.Friends(ChgHost) {
|
||||
for fClient := range client.Friends(caps.ChgHost) {
|
||||
fClient.SendFromClient("", client, nil, "CHGHOST", client.username, server.operators[name].Vhost)
|
||||
}
|
||||
// CHGHOST requires prefix nickmask to have original hostname, so do that before updating nickmask
|
||||
@ -1294,34 +1295,34 @@ func (server *Server) applyConfig(config *Config, initial bool) error {
|
||||
// SASL
|
||||
if config.Accounts.AuthenticationEnabled && !server.accountAuthenticationEnabled {
|
||||
// enabling SASL
|
||||
SupportedCapabilities[SASL] = true
|
||||
addedCaps[SASL] = true
|
||||
SupportedCapabilities[caps.SASL] = true
|
||||
addedCaps[caps.SASL] = true
|
||||
}
|
||||
if !config.Accounts.AuthenticationEnabled && server.accountAuthenticationEnabled {
|
||||
// disabling SASL
|
||||
SupportedCapabilities[SASL] = false
|
||||
removedCaps[SASL] = true
|
||||
SupportedCapabilities[caps.SASL] = false
|
||||
removedCaps[caps.SASL] = true
|
||||
}
|
||||
server.accountAuthenticationEnabled = config.Accounts.AuthenticationEnabled
|
||||
|
||||
// STS
|
||||
stsValue := config.Server.STS.Value()
|
||||
var stsDisabled bool
|
||||
server.logger.Debug("rehash", "STS Vals", CapValues[STS], stsValue, fmt.Sprintf("server[%v] config[%v]", server.stsEnabled, config.Server.STS.Enabled))
|
||||
server.logger.Debug("rehash", "STS Vals", CapValues[caps.STS], stsValue, fmt.Sprintf("server[%v] config[%v]", server.stsEnabled, config.Server.STS.Enabled))
|
||||
if config.Server.STS.Enabled && !server.stsEnabled {
|
||||
// enabling STS
|
||||
SupportedCapabilities[STS] = true
|
||||
addedCaps[STS] = true
|
||||
CapValues[STS] = stsValue
|
||||
SupportedCapabilities[caps.STS] = true
|
||||
addedCaps[caps.STS] = true
|
||||
CapValues[caps.STS] = stsValue
|
||||
} else if !config.Server.STS.Enabled && server.stsEnabled {
|
||||
// disabling STS
|
||||
SupportedCapabilities[STS] = false
|
||||
removedCaps[STS] = true
|
||||
SupportedCapabilities[caps.STS] = false
|
||||
removedCaps[caps.STS] = true
|
||||
stsDisabled = true
|
||||
} else if config.Server.STS.Enabled && server.stsEnabled && stsValue != CapValues[STS] {
|
||||
} else if config.Server.STS.Enabled && server.stsEnabled && stsValue != CapValues[caps.STS] {
|
||||
// STS policy updated
|
||||
CapValues[STS] = stsValue
|
||||
updatedCaps[STS] = true
|
||||
CapValues[caps.STS] = stsValue
|
||||
updatedCaps[caps.STS] = true
|
||||
}
|
||||
server.stsEnabled = config.Server.STS.Enabled
|
||||
|
||||
@ -1341,7 +1342,7 @@ func (server *Server) applyConfig(config *Config, initial bool) error {
|
||||
}
|
||||
|
||||
if len(addedCaps) > 0 || len(removedCaps) > 0 {
|
||||
capBurstClients = server.clients.AllWithCaps(CapNotify)
|
||||
capBurstClients = server.clients.AllWithCaps(caps.CapNotify)
|
||||
|
||||
added[Cap301] = addedCaps.String(Cap301)
|
||||
added[Cap302] = addedCaps.String(Cap302)
|
||||
@ -1357,7 +1358,7 @@ func (server *Server) applyConfig(config *Config, initial bool) error {
|
||||
if len(addedCaps) > 0 {
|
||||
added[Cap302] = added[Cap302] + " " + stsPolicy
|
||||
} else {
|
||||
addedCaps[STS] = true
|
||||
addedCaps[caps.STS] = true
|
||||
added[Cap302] = stsPolicy
|
||||
}
|
||||
}
|
||||
@ -1655,7 +1656,7 @@ func awayHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||
client.Send(nil, server.name, "MODE", client.nick, modech.String())
|
||||
|
||||
// dispatch away-notify
|
||||
for friend := range client.Friends(AwayNotify) {
|
||||
for friend := range client.Friends(caps.AwayNotify) {
|
||||
if client.flags[Away] {
|
||||
friend.SendFromClient("", client, nil, "AWAY", client.awayMessage)
|
||||
} else {
|
||||
@ -1706,7 +1707,7 @@ func noticeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||
message := msg.Params[1]
|
||||
|
||||
// split privmsg
|
||||
splitMsg := server.splitMessage(message, !client.capabilities[MaxLine])
|
||||
splitMsg := server.splitMessage(message, !client.capabilities[caps.MaxLine])
|
||||
|
||||
for i, targetString := range targets {
|
||||
// max of four targets per privmsg
|
||||
@ -1747,7 +1748,7 @@ func noticeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||
// errors silently ignored with NOTICE as per RFC
|
||||
continue
|
||||
}
|
||||
if !user.capabilities[MessageTags] {
|
||||
if !user.capabilities[caps.MessageTags] {
|
||||
clientOnlyTags = nil
|
||||
}
|
||||
msgid := server.generateMessageID()
|
||||
@ -1756,7 +1757,7 @@ func noticeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||
if !user.flags[RegisteredOnly] || client.registered {
|
||||
user.SendSplitMsgFromClient(msgid, client, clientOnlyTags, "NOTICE", user.nick, splitMsg)
|
||||
}
|
||||
if client.capabilities[EchoMessage] {
|
||||
if client.capabilities[caps.EchoMessage] {
|
||||
client.SendSplitMsgFromClient(msgid, client, clientOnlyTags, "NOTICE", user.nick, splitMsg)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user