mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-26 05:49:25 +01:00
commit
de31430fdc
2
go.mod
2
go.mod
@ -10,7 +10,7 @@ require (
|
|||||||
github.com/go-sql-driver/mysql v1.5.0
|
github.com/go-sql-driver/mysql v1.5.0
|
||||||
github.com/go-test/deep v1.0.6 // indirect
|
github.com/go-test/deep v1.0.6 // indirect
|
||||||
github.com/gorilla/websocket v1.4.2
|
github.com/gorilla/websocket v1.4.2
|
||||||
github.com/goshuirc/irc-go v0.0.0-20210304031553-cf78e9176f96
|
github.com/goshuirc/irc-go v0.0.0-20210311004346-ea7a188a73fe
|
||||||
github.com/onsi/ginkgo v1.12.0 // indirect
|
github.com/onsi/ginkgo v1.12.0 // indirect
|
||||||
github.com/onsi/gomega v1.9.0 // indirect
|
github.com/onsi/gomega v1.9.0 // indirect
|
||||||
github.com/oragono/confusables v0.0.0-20201108231250-4ab98ab61fb1
|
github.com/oragono/confusables v0.0.0-20201108231250-4ab98ab61fb1
|
||||||
|
2
go.sum
2
go.sum
@ -42,6 +42,8 @@ github.com/goshuirc/irc-go v0.0.0-20210301225436-2c4b83d64847 h1:MmsZRpAsMxyw0P5
|
|||||||
github.com/goshuirc/irc-go v0.0.0-20210301225436-2c4b83d64847/go.mod h1:q/JhvvKLmif3y9q8MDQM+gRCnjEKnu5ClF298TTXJug=
|
github.com/goshuirc/irc-go v0.0.0-20210301225436-2c4b83d64847/go.mod h1:q/JhvvKLmif3y9q8MDQM+gRCnjEKnu5ClF298TTXJug=
|
||||||
github.com/goshuirc/irc-go v0.0.0-20210304031553-cf78e9176f96 h1:sihI3HsrJWyS4MtBmxh5W4gDZD34SWodkWyUvJltswY=
|
github.com/goshuirc/irc-go v0.0.0-20210304031553-cf78e9176f96 h1:sihI3HsrJWyS4MtBmxh5W4gDZD34SWodkWyUvJltswY=
|
||||||
github.com/goshuirc/irc-go v0.0.0-20210304031553-cf78e9176f96/go.mod h1:q/JhvvKLmif3y9q8MDQM+gRCnjEKnu5ClF298TTXJug=
|
github.com/goshuirc/irc-go v0.0.0-20210304031553-cf78e9176f96/go.mod h1:q/JhvvKLmif3y9q8MDQM+gRCnjEKnu5ClF298TTXJug=
|
||||||
|
github.com/goshuirc/irc-go v0.0.0-20210311004346-ea7a188a73fe h1:5UsPgeXJBkFgJK3Ml0nj6ljasjd26xiUxALnDJHmipE=
|
||||||
|
github.com/goshuirc/irc-go v0.0.0-20210311004346-ea7a188a73fe/go.mod h1:q/JhvvKLmif3y9q8MDQM+gRCnjEKnu5ClF298TTXJug=
|
||||||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
|
@ -1667,7 +1667,7 @@ func (session *Session) sendFromClientInternal(blocking bool, serverTime time.Ti
|
|||||||
return session.SendRawMessage(msg, blocking)
|
return session.SendRawMessage(msg, blocking)
|
||||||
}
|
}
|
||||||
|
|
||||||
func composeMultilineBatch(batchID, fromNickMask, fromAccount string, tags map[string]string, command, target string, message utils.SplitMessage) (result []ircmsg.IRCMessage) {
|
func composeMultilineBatch(batchID, fromNickMask, fromAccount string, tags map[string]string, command, target string, message utils.SplitMessage) (result []ircmsg.Message) {
|
||||||
batchStart := ircmsg.MakeMessage(tags, fromNickMask, "BATCH", "+"+batchID, caps.MultilineBatchType, target)
|
batchStart := ircmsg.MakeMessage(tags, fromNickMask, "BATCH", "+"+batchID, caps.MultilineBatchType, target)
|
||||||
batchStart.SetTag("time", message.Time.Format(IRCv3TimestampFormat))
|
batchStart.SetTag("time", message.Time.Format(IRCv3TimestampFormat))
|
||||||
batchStart.SetTag("msgid", message.Msgid)
|
batchStart.SetTag("msgid", message.Msgid)
|
||||||
@ -1707,7 +1707,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// SendRawMessage sends a raw message to the client.
|
// SendRawMessage sends a raw message to the client.
|
||||||
func (session *Session) SendRawMessage(message ircmsg.IRCMessage, blocking bool) error {
|
func (session *Session) SendRawMessage(message ircmsg.Message, blocking bool) error {
|
||||||
// use dumb hack to force the last param to be a trailing param if required
|
// use dumb hack to force the last param to be a trailing param if required
|
||||||
config := session.client.server.Config()
|
config := session.client.server.Config()
|
||||||
if config.Server.Compatibility.forceTrailing && commandsThatMustUseTrailing[message.Command] {
|
if config.Server.Compatibility.forceTrailing && commandsThatMustUseTrailing[message.Command] {
|
||||||
@ -1769,7 +1769,7 @@ func (session *Session) Send(tags map[string]string, prefix string, command stri
|
|||||||
return session.SendRawMessage(msg, false)
|
return session.SendRawMessage(msg, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (session *Session) setTimeTag(msg *ircmsg.IRCMessage, serverTime time.Time) {
|
func (session *Session) setTimeTag(msg *ircmsg.Message, serverTime time.Time) {
|
||||||
if session.capabilities.Has(caps.ServerTime) && !msg.HasTag("time") {
|
if session.capabilities.Has(caps.ServerTime) && !msg.HasTag("time") {
|
||||||
if serverTime.IsZero() {
|
if serverTime.IsZero() {
|
||||||
serverTime = time.Now()
|
serverTime = time.Now()
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
// Command represents a command accepted from a client.
|
// Command represents a command accepted from a client.
|
||||||
type Command struct {
|
type Command struct {
|
||||||
handler func(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool
|
handler func(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool
|
||||||
usablePreReg bool
|
usablePreReg bool
|
||||||
allowedInBatch bool // allowed in client-to-server batches
|
allowedInBatch bool // allowed in client-to-server batches
|
||||||
minParams int
|
minParams int
|
||||||
@ -19,7 +19,7 @@ type Command struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run runs this command with the given client/message.
|
// Run runs this command with the given client/message.
|
||||||
func (cmd *Command) Run(server *Server, client *Client, session *Session, msg ircmsg.IRCMessage) (exiting bool) {
|
func (cmd *Command) Run(server *Server, client *Client, session *Session, msg ircmsg.Message) (exiting bool) {
|
||||||
rb := NewResponseBuffer(session)
|
rb := NewResponseBuffer(session)
|
||||||
rb.Label = GetLabel(msg)
|
rb.Label = GetLabel(msg)
|
||||||
|
|
||||||
|
142
irc/handlers.go
142
irc/handlers.go
@ -138,7 +138,7 @@ func (server *Server) sendLoginSnomask(nickMask, accountName string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AUTHENTICATE [<mechanism>|<data>|*]
|
// AUTHENTICATE [<mechanism>|<data>|*]
|
||||||
func authenticateHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func authenticateHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
session := rb.session
|
session := rb.session
|
||||||
config := server.Config()
|
config := server.Config()
|
||||||
details := client.Details()
|
details := client.Details()
|
||||||
@ -340,7 +340,7 @@ func authExternalHandler(server *Server, client *Client, mechanism string, value
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AWAY [<message>]
|
// AWAY [<message>]
|
||||||
func awayHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func awayHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
var isAway bool
|
var isAway bool
|
||||||
var awayMessage string
|
var awayMessage string
|
||||||
if len(msg.Params) > 0 {
|
if len(msg.Params) > 0 {
|
||||||
@ -377,7 +377,7 @@ func dispatchAwayNotify(client *Client, isAway bool, awayMessage string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// BATCH {+,-}reference-tag type [params...]
|
// BATCH {+,-}reference-tag type [params...]
|
||||||
func batchHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func batchHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
tag := msg.Params[0]
|
tag := msg.Params[0]
|
||||||
fail := false
|
fail := false
|
||||||
sendErrors := rb.session.batch.command != "NOTICE"
|
sendErrors := rb.session.batch.command != "NOTICE"
|
||||||
@ -421,7 +421,7 @@ func batchHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Res
|
|||||||
}
|
}
|
||||||
|
|
||||||
// BRB [message]
|
// BRB [message]
|
||||||
func brbHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func brbHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
success, duration := client.brbTimer.Enable()
|
success, duration := client.brbTimer.Enable()
|
||||||
if !success {
|
if !success {
|
||||||
rb.Add(nil, server.name, "FAIL", "BRB", "CANNOT_BRB", client.t("Your client does not support BRB"))
|
rb.Add(nil, server.name, "FAIL", "BRB", "CANNOT_BRB", client.t("Your client does not support BRB"))
|
||||||
@ -446,7 +446,7 @@ func brbHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Respo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CAP <subcmd> [<caps>]
|
// CAP <subcmd> [<caps>]
|
||||||
func capHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func capHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
details := client.Details()
|
details := client.Details()
|
||||||
subCommand := strings.ToUpper(msg.Params[0])
|
subCommand := strings.ToUpper(msg.Params[0])
|
||||||
toAdd := caps.NewSet()
|
toAdd := caps.NewSet()
|
||||||
@ -564,7 +564,7 @@ func capHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Respo
|
|||||||
// e.g., CHATHISTORY #ircv3 AFTER id=ytNBbt565yt4r3err3 10
|
// e.g., CHATHISTORY #ircv3 AFTER id=ytNBbt565yt4r3err3 10
|
||||||
// CHATHISTORY <target> BETWEEN <query> <query> <direction> [<limit>]
|
// CHATHISTORY <target> BETWEEN <query> <query> <direction> [<limit>]
|
||||||
// e.g., CHATHISTORY #ircv3 BETWEEN timestamp=YYYY-MM-DDThh:mm:ss.sssZ timestamp=YYYY-MM-DDThh:mm:ss.sssZ + 100
|
// e.g., CHATHISTORY #ircv3 BETWEEN timestamp=YYYY-MM-DDThh:mm:ss.sssZ timestamp=YYYY-MM-DDThh:mm:ss.sssZ + 100
|
||||||
func chathistoryHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) (exiting bool) {
|
func chathistoryHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) (exiting bool) {
|
||||||
var items []history.Item
|
var items []history.Item
|
||||||
unknown_command := false
|
unknown_command := false
|
||||||
var target string
|
var target string
|
||||||
@ -702,7 +702,7 @@ func chathistoryHandler(server *Server, client *Client, msg ircmsg.IRCMessage, r
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DEBUG <subcmd>
|
// DEBUG <subcmd>
|
||||||
func debugHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func debugHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
param := strings.ToUpper(msg.Params[0])
|
param := strings.ToUpper(msg.Params[0])
|
||||||
|
|
||||||
switch param {
|
switch param {
|
||||||
@ -775,7 +775,7 @@ func debugHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Res
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func defconHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func defconHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
if len(msg.Params) > 0 {
|
if len(msg.Params) > 0 {
|
||||||
level, err := strconv.Atoi(msg.Params[0])
|
level, err := strconv.Atoi(msg.Params[0])
|
||||||
if err == nil && 1 <= level && level <= 5 {
|
if err == nil && 1 <= level && level <= 5 {
|
||||||
@ -823,7 +823,7 @@ func formatBanForListing(client *Client, key string, info IPBanInfo) string {
|
|||||||
|
|
||||||
// DLINE [ANDKILL] [MYSELF] [duration] <ip>/<net> [ON <server>] [reason [| oper reason]]
|
// DLINE [ANDKILL] [MYSELF] [duration] <ip>/<net> [ON <server>] [reason [| oper reason]]
|
||||||
// DLINE LIST
|
// DLINE LIST
|
||||||
func dlineHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func dlineHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
// check oper permissions
|
// check oper permissions
|
||||||
oper := client.Oper()
|
oper := client.Oper()
|
||||||
if !oper.HasRoleCapab("ban") {
|
if !oper.HasRoleCapab("ban") {
|
||||||
@ -962,7 +962,7 @@ func dlineHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Res
|
|||||||
}
|
}
|
||||||
|
|
||||||
// EXTJWT <target> [service_name]
|
// EXTJWT <target> [service_name]
|
||||||
func extjwtHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func extjwtHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
accountName := client.AccountName()
|
accountName := client.AccountName()
|
||||||
if accountName == "*" {
|
if accountName == "*" {
|
||||||
accountName = ""
|
accountName = ""
|
||||||
@ -1030,7 +1030,7 @@ func extjwtHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Re
|
|||||||
|
|
||||||
// HELP [<query>]
|
// HELP [<query>]
|
||||||
// HELPOP [<query>]
|
// HELPOP [<query>]
|
||||||
func helpHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func helpHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
if len(msg.Params) == 0 {
|
if len(msg.Params) == 0 {
|
||||||
client.sendHelp("HELPOP", client.t(`HELPOP <argument>
|
client.sendHelp("HELPOP", client.t(`HELPOP <argument>
|
||||||
|
|
||||||
@ -1065,7 +1065,7 @@ Get an explanation of <argument>, or "index" for a list of help topics.`), rb)
|
|||||||
// e.g., HISTORY #ubuntu 10
|
// e.g., HISTORY #ubuntu 10
|
||||||
// HISTORY me 15
|
// HISTORY me 15
|
||||||
// HISTORY #darwin 1h
|
// HISTORY #darwin 1h
|
||||||
func historyHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func historyHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
config := server.Config()
|
config := server.Config()
|
||||||
if !config.History.Enabled {
|
if !config.History.Enabled {
|
||||||
rb.Notice(client.t("This command has been disabled by the server administrators"))
|
rb.Notice(client.t("This command has been disabled by the server administrators"))
|
||||||
@ -1093,7 +1093,7 @@ func historyHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *R
|
|||||||
}
|
}
|
||||||
|
|
||||||
// INFO
|
// INFO
|
||||||
func infoHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func infoHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
nick := client.Nick()
|
nick := client.Nick()
|
||||||
// we do the below so that the human-readable lines in info can be translated.
|
// we do the below so that the human-readable lines in info can be translated.
|
||||||
for _, line := range infoString1 {
|
for _, line := range infoString1 {
|
||||||
@ -1133,7 +1133,7 @@ func infoHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Resp
|
|||||||
|
|
||||||
// INVITE <nickname> <channel>
|
// INVITE <nickname> <channel>
|
||||||
// UNINVITE <nickname> <channel>
|
// UNINVITE <nickname> <channel>
|
||||||
func inviteHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func inviteHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
invite := msg.Command == "INVITE"
|
invite := msg.Command == "INVITE"
|
||||||
nickname := msg.Params[0]
|
nickname := msg.Params[0]
|
||||||
channelName := msg.Params[1]
|
channelName := msg.Params[1]
|
||||||
@ -1160,7 +1160,7 @@ func inviteHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ISON <nick>{ <nick>}
|
// ISON <nick>{ <nick>}
|
||||||
func isonHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func isonHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
var nicks = msg.Params
|
var nicks = msg.Params
|
||||||
|
|
||||||
ison := make([]string, 0, len(msg.Params))
|
ison := make([]string, 0, len(msg.Params))
|
||||||
@ -1176,7 +1176,7 @@ func isonHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Resp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// JOIN <channel>{,<channel>} [<key>{,<key>}]
|
// JOIN <channel>{,<channel>} [<key>{,<key>}]
|
||||||
func joinHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func joinHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
// #1417: allow `JOIN 0` with a confirmation code
|
// #1417: allow `JOIN 0` with a confirmation code
|
||||||
if msg.Params[0] == "0" {
|
if msg.Params[0] == "0" {
|
||||||
expectedCode := utils.ConfirmationCode("", rb.session.ctime)
|
expectedCode := utils.ConfirmationCode("", rb.session.ctime)
|
||||||
@ -1253,7 +1253,7 @@ func sendJoinError(client *Client, name string, rb *ResponseBuffer, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SAJOIN [nick] #channel{,#channel}
|
// SAJOIN [nick] #channel{,#channel}
|
||||||
func sajoinHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func sajoinHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
var target *Client
|
var target *Client
|
||||||
var channelString string
|
var channelString string
|
||||||
if strings.HasPrefix(msg.Params[0], "#") {
|
if strings.HasPrefix(msg.Params[0], "#") {
|
||||||
@ -1288,7 +1288,7 @@ func sajoinHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
// KICK <channel>{,<channel>} <user>{,<user>} [<comment>]
|
// KICK <channel>{,<channel>} <user>{,<user>} [<comment>]
|
||||||
func kickHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func kickHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
hasPrivs := client.HasRoleCapabs("samode")
|
hasPrivs := client.HasRoleCapabs("samode")
|
||||||
channels := strings.Split(msg.Params[0], ",")
|
channels := strings.Split(msg.Params[0], ",")
|
||||||
users := strings.Split(msg.Params[1], ",")
|
users := strings.Split(msg.Params[1], ",")
|
||||||
@ -1339,7 +1339,7 @@ func kickHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Resp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// KILL <nickname> <comment>
|
// KILL <nickname> <comment>
|
||||||
func killHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func killHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
nickname := msg.Params[0]
|
nickname := msg.Params[0]
|
||||||
comment := "<no reason supplied>"
|
comment := "<no reason supplied>"
|
||||||
if len(msg.Params) > 1 {
|
if len(msg.Params) > 1 {
|
||||||
@ -1365,7 +1365,7 @@ func killHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Resp
|
|||||||
|
|
||||||
// KLINE [ANDKILL] [MYSELF] [duration] <mask> [ON <server>] [reason [| oper reason]]
|
// KLINE [ANDKILL] [MYSELF] [duration] <mask> [ON <server>] [reason [| oper reason]]
|
||||||
// KLINE LIST
|
// KLINE LIST
|
||||||
func klineHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func klineHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
details := client.Details()
|
details := client.Details()
|
||||||
// check oper permissions
|
// check oper permissions
|
||||||
oper := client.Oper()
|
oper := client.Oper()
|
||||||
@ -1507,7 +1507,7 @@ func klineHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Res
|
|||||||
}
|
}
|
||||||
|
|
||||||
// LANGUAGE <code>{ <code>}
|
// LANGUAGE <code>{ <code>}
|
||||||
func languageHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func languageHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
nick := client.Nick()
|
nick := client.Nick()
|
||||||
alreadyDoneLanguages := make(map[string]bool)
|
alreadyDoneLanguages := make(map[string]bool)
|
||||||
var appliedLanguages []string
|
var appliedLanguages []string
|
||||||
@ -1561,7 +1561,7 @@ func languageHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *
|
|||||||
}
|
}
|
||||||
|
|
||||||
// LIST [<channel>{,<channel>}] [<elistcond>{,<elistcond>}]
|
// LIST [<channel>{,<channel>}] [<elistcond>{,<elistcond>}]
|
||||||
func listHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func listHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
config := server.Config()
|
config := server.Config()
|
||||||
if time.Since(client.ctime) < config.Channels.ListDelay && client.Account() == "" && !client.HasMode(modes.Operator) {
|
if time.Since(client.ctime) < config.Channels.ListDelay && client.Account() == "" && !client.HasMode(modes.Operator) {
|
||||||
remaining := time.Until(client.ctime.Add(config.Channels.ListDelay))
|
remaining := time.Until(client.ctime.Add(config.Channels.ListDelay))
|
||||||
@ -1649,13 +1649,13 @@ func listHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Resp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// LUSERS [<mask> [<server>]]
|
// LUSERS [<mask> [<server>]]
|
||||||
func lusersHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func lusersHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
server.Lusers(client, rb)
|
server.Lusers(client, rb)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// MODE <target> [<modestring> [<mode arguments>...]]
|
// MODE <target> [<modestring> [<mode arguments>...]]
|
||||||
func modeHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func modeHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
if 0 < len(msg.Params[0]) && msg.Params[0][0] == '#' {
|
if 0 < len(msg.Params[0]) && msg.Params[0][0] == '#' {
|
||||||
return cmodeHandler(server, client, msg, rb)
|
return cmodeHandler(server, client, msg, rb)
|
||||||
}
|
}
|
||||||
@ -1663,7 +1663,7 @@ func modeHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Resp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MODE <channel> [<modestring> [<mode arguments>...]]
|
// MODE <channel> [<modestring> [<mode arguments>...]]
|
||||||
func cmodeHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func cmodeHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
channel := server.channels.Get(msg.Params[0])
|
channel := server.channels.Get(msg.Params[0])
|
||||||
|
|
||||||
if channel == nil {
|
if channel == nil {
|
||||||
@ -1721,7 +1721,7 @@ func announceCmodeChanges(channel *Channel, applied modes.ModeChanges, source, a
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MODE <client> [<modestring> [<mode arguments>...]]
|
// MODE <client> [<modestring> [<mode arguments>...]]
|
||||||
func umodeHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func umodeHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
cDetails := client.Details()
|
cDetails := client.Details()
|
||||||
target := server.clients.Get(msg.Params[0])
|
target := server.clients.Get(msg.Params[0])
|
||||||
if target == nil {
|
if target == nil {
|
||||||
@ -1793,7 +1793,7 @@ func (server *Server) getCurrentNick(nick string) (result string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MONITOR <subcmd> [params...]
|
// MONITOR <subcmd> [params...]
|
||||||
func monitorHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func monitorHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
handler, exists := monitorSubcommands[strings.ToLower(msg.Params[0])]
|
handler, exists := monitorSubcommands[strings.ToLower(msg.Params[0])]
|
||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
@ -1805,7 +1805,7 @@ func monitorHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *R
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MONITOR - <target>{,<target>}
|
// MONITOR - <target>{,<target>}
|
||||||
func monitorRemoveHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func monitorRemoveHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
if len(msg.Params) < 2 {
|
if len(msg.Params) < 2 {
|
||||||
rb.Add(nil, server.name, ERR_NEEDMOREPARAMS, client.Nick(), msg.Command, client.t("Not enough parameters"))
|
rb.Add(nil, server.name, ERR_NEEDMOREPARAMS, client.Nick(), msg.Command, client.t("Not enough parameters"))
|
||||||
return false
|
return false
|
||||||
@ -1820,7 +1820,7 @@ func monitorRemoveHandler(server *Server, client *Client, msg ircmsg.IRCMessage,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MONITOR + <target>{,<target>}
|
// MONITOR + <target>{,<target>}
|
||||||
func monitorAddHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func monitorAddHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
if len(msg.Params) < 2 {
|
if len(msg.Params) < 2 {
|
||||||
rb.Add(nil, server.name, ERR_NEEDMOREPARAMS, client.Nick(), msg.Command, client.t("Not enough parameters"))
|
rb.Add(nil, server.name, ERR_NEEDMOREPARAMS, client.Nick(), msg.Command, client.t("Not enough parameters"))
|
||||||
return false
|
return false
|
||||||
@ -1867,13 +1867,13 @@ func monitorAddHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MONITOR C
|
// MONITOR C
|
||||||
func monitorClearHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func monitorClearHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
server.monitorManager.RemoveAll(rb.session)
|
server.monitorManager.RemoveAll(rb.session)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// MONITOR L
|
// MONITOR L
|
||||||
func monitorListHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func monitorListHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
nick := client.Nick()
|
nick := client.Nick()
|
||||||
monitorList := server.monitorManager.List(rb.session)
|
monitorList := server.monitorManager.List(rb.session)
|
||||||
|
|
||||||
@ -1898,7 +1898,7 @@ func monitorListHandler(server *Server, client *Client, msg ircmsg.IRCMessage, r
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MONITOR S
|
// MONITOR S
|
||||||
func monitorStatusHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func monitorStatusHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
var online []string
|
var online []string
|
||||||
var offline []string
|
var offline []string
|
||||||
|
|
||||||
@ -1928,13 +1928,13 @@ func monitorStatusHandler(server *Server, client *Client, msg ircmsg.IRCMessage,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MOTD
|
// MOTD
|
||||||
func motdHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func motdHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
server.MOTD(client, rb)
|
server.MOTD(client, rb)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// NAMES [<channel>{,<channel>} [target]]
|
// NAMES [<channel>{,<channel>} [target]]
|
||||||
func namesHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func namesHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
var channels []string
|
var channels []string
|
||||||
if len(msg.Params) > 0 {
|
if len(msg.Params) > 0 {
|
||||||
channels = strings.Split(msg.Params[0], ",")
|
channels = strings.Split(msg.Params[0], ",")
|
||||||
@ -1968,7 +1968,7 @@ func namesHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Res
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NICK <nickname>
|
// NICK <nickname>
|
||||||
func nickHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func nickHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
if client.registered {
|
if client.registered {
|
||||||
if client.account == "" && server.Config().Accounts.NickReservation.ForbidAnonNickChanges {
|
if client.account == "" && server.Config().Accounts.NickReservation.ForbidAnonNickChanges {
|
||||||
rb.Add(nil, server.name, ERR_UNKNOWNERROR, client.Nick(), client.t("You may not change your nickname"))
|
rb.Add(nil, server.name, ERR_UNKNOWNERROR, client.Nick(), client.t("You may not change your nickname"))
|
||||||
@ -2019,7 +2019,7 @@ func validateSplitMessageLen(msgType history.ItemType, source, target string, me
|
|||||||
}
|
}
|
||||||
|
|
||||||
// helper to store a batched PRIVMSG in the session object
|
// helper to store a batched PRIVMSG in the session object
|
||||||
func absorbBatchedMessage(server *Server, client *Client, msg ircmsg.IRCMessage, batchTag string, histType history.ItemType, rb *ResponseBuffer) {
|
func absorbBatchedMessage(server *Server, client *Client, msg ircmsg.Message, batchTag string, histType history.ItemType, rb *ResponseBuffer) {
|
||||||
var errorCode, errorMessage string
|
var errorCode, errorMessage string
|
||||||
defer func() {
|
defer func() {
|
||||||
if errorCode != "" {
|
if errorCode != "" {
|
||||||
@ -2059,7 +2059,7 @@ func absorbBatchedMessage(server *Server, client *Client, msg ircmsg.IRCMessage,
|
|||||||
// NOTICE <target>{,<target>} <message>
|
// NOTICE <target>{,<target>} <message>
|
||||||
// PRIVMSG <target>{,<target>} <message>
|
// PRIVMSG <target>{,<target>} <message>
|
||||||
// TAGMSG <target>{,<target>}
|
// TAGMSG <target>{,<target>}
|
||||||
func messageHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func messageHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
histType, err := msgCommandToHistType(msg.Command)
|
histType, err := msgCommandToHistType(msg.Command)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
@ -2267,7 +2267,7 @@ func itemIsStorable(item *history.Item, config *Config) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NPC <target> <sourcenick> <message>
|
// NPC <target> <sourcenick> <message>
|
||||||
func npcHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func npcHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
target := msg.Params[0]
|
target := msg.Params[0]
|
||||||
fakeSource := msg.Params[1]
|
fakeSource := msg.Params[1]
|
||||||
message := msg.Params[2:]
|
message := msg.Params[2:]
|
||||||
@ -2278,7 +2278,7 @@ func npcHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Respo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NPCA <target> <sourcenick> <message>
|
// NPCA <target> <sourcenick> <message>
|
||||||
func npcaHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func npcaHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
target := msg.Params[0]
|
target := msg.Params[0]
|
||||||
fakeSource := msg.Params[1]
|
fakeSource := msg.Params[1]
|
||||||
message := msg.Params[2:]
|
message := msg.Params[2:]
|
||||||
@ -2289,7 +2289,7 @@ func npcaHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Resp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OPER <name> [password]
|
// OPER <name> [password]
|
||||||
func operHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func operHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
if client.HasMode(modes.Operator) {
|
if client.HasMode(modes.Operator) {
|
||||||
rb.Add(nil, server.name, ERR_UNKNOWNERROR, client.Nick(), "OPER", client.t("You're already opered-up!"))
|
rb.Add(nil, server.name, ERR_UNKNOWNERROR, client.Nick(), "OPER", client.t("You're already opered-up!"))
|
||||||
return false
|
return false
|
||||||
@ -2374,7 +2374,7 @@ func applyOper(client *Client, oper *Oper, rb *ResponseBuffer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DEOPER
|
// DEOPER
|
||||||
func deoperHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func deoperHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
if client.Oper() == nil {
|
if client.Oper() == nil {
|
||||||
rb.Notice(client.t("Insufficient oper privs"))
|
rb.Notice(client.t("Insufficient oper privs"))
|
||||||
return false
|
return false
|
||||||
@ -2385,7 +2385,7 @@ func deoperHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PART <channel>{,<channel>} [<reason>]
|
// PART <channel>{,<channel>} [<reason>]
|
||||||
func partHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func partHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
channels := strings.Split(msg.Params[0], ",")
|
channels := strings.Split(msg.Params[0], ",")
|
||||||
var reason string
|
var reason string
|
||||||
if len(msg.Params) > 1 {
|
if len(msg.Params) > 1 {
|
||||||
@ -2405,7 +2405,7 @@ func partHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Resp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PASS <password>
|
// PASS <password>
|
||||||
func passHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func passHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
if client.registered {
|
if client.registered {
|
||||||
rb.Add(nil, server.name, ERR_ALREADYREGISTRED, client.nick, client.t("You may not reregister"))
|
rb.Add(nil, server.name, ERR_ALREADYREGISTRED, client.nick, client.t("You may not reregister"))
|
||||||
return false
|
return false
|
||||||
@ -2460,19 +2460,19 @@ func passHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Resp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PING [params...]
|
// PING [params...]
|
||||||
func pingHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func pingHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
rb.Add(nil, server.name, "PONG", server.name, msg.Params[0])
|
rb.Add(nil, server.name, "PONG", server.name, msg.Params[0])
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// PONG [params...]
|
// PONG [params...]
|
||||||
func pongHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func pongHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
// client gets touched when they send this command, so we don't need to do anything
|
// client gets touched when they send this command, so we don't need to do anything
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// QUIT [<reason>]
|
// QUIT [<reason>]
|
||||||
func quitHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func quitHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
reason := "Quit"
|
reason := "Quit"
|
||||||
if len(msg.Params) > 0 {
|
if len(msg.Params) > 0 {
|
||||||
reason += ": " + msg.Params[0]
|
reason += ": " + msg.Params[0]
|
||||||
@ -2482,7 +2482,7 @@ func quitHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Resp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// REGISTER < email | * > <password>
|
// REGISTER < email | * > <password>
|
||||||
func registerHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) (exiting bool) {
|
func registerHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) (exiting bool) {
|
||||||
accountName := client.Nick()
|
accountName := client.Nick()
|
||||||
if accountName == "*" {
|
if accountName == "*" {
|
||||||
accountName = client.preregNick
|
accountName = client.preregNick
|
||||||
@ -2551,7 +2551,7 @@ func registerHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *
|
|||||||
}
|
}
|
||||||
|
|
||||||
// VERIFY <account> <code>
|
// VERIFY <account> <code>
|
||||||
func verifyHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) (exiting bool) {
|
func verifyHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) (exiting bool) {
|
||||||
config := server.Config()
|
config := server.Config()
|
||||||
if !config.Accounts.Registration.Enabled {
|
if !config.Accounts.Registration.Enabled {
|
||||||
rb.Add(nil, server.name, "FAIL", "VERIFY", "DISALLOWED", client.t("Account registration is disabled"))
|
rb.Add(nil, server.name, "FAIL", "VERIFY", "DISALLOWED", client.t("Account registration is disabled"))
|
||||||
@ -2593,7 +2593,7 @@ func verifyHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
// REHASH
|
// REHASH
|
||||||
func rehashHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func rehashHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
nick := client.Nick()
|
nick := client.Nick()
|
||||||
server.logger.Info("server", "REHASH command used by", nick)
|
server.logger.Info("server", "REHASH command used by", nick)
|
||||||
err := server.rehash()
|
err := server.rehash()
|
||||||
@ -2611,7 +2611,7 @@ func rehashHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RELAYMSG <channel> <spoofed nick> :<message>
|
// RELAYMSG <channel> <spoofed nick> :<message>
|
||||||
func relaymsgHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) (result bool) {
|
func relaymsgHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) (result bool) {
|
||||||
config := server.Config()
|
config := server.Config()
|
||||||
if !config.Server.Relaymsg.Enabled {
|
if !config.Server.Relaymsg.Enabled {
|
||||||
rb.Add(nil, server.name, "FAIL", "RELAYMSG", "NOT_ENABLED", client.t("RELAYMSG has been disabled"))
|
rb.Add(nil, server.name, "FAIL", "RELAYMSG", "NOT_ENABLED", client.t("RELAYMSG has been disabled"))
|
||||||
@ -2680,7 +2680,7 @@ func relaymsgHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RENAME <oldchan> <newchan> [<reason>]
|
// RENAME <oldchan> <newchan> [<reason>]
|
||||||
func renameHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func renameHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
oldName, newName := msg.Params[0], msg.Params[1]
|
oldName, newName := msg.Params[0], msg.Params[1]
|
||||||
var reason string
|
var reason string
|
||||||
if 2 < len(msg.Params) {
|
if 2 < len(msg.Params) {
|
||||||
@ -2766,7 +2766,7 @@ func renameHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RESUME <token> [timestamp]
|
// RESUME <token> [timestamp]
|
||||||
func resumeHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func resumeHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
details := ResumeDetails{
|
details := ResumeDetails{
|
||||||
PresentedToken: msg.Params[0],
|
PresentedToken: msg.Params[0],
|
||||||
}
|
}
|
||||||
@ -2790,7 +2790,7 @@ func resumeHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SANICK <oldnick> <nickname>
|
// SANICK <oldnick> <nickname>
|
||||||
func sanickHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func sanickHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
targetNick := msg.Params[0]
|
targetNick := msg.Params[0]
|
||||||
target := server.clients.Get(targetNick)
|
target := server.clients.Get(targetNick)
|
||||||
if target == nil {
|
if target == nil {
|
||||||
@ -2802,7 +2802,7 @@ func sanickHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SCENE <target> <message>
|
// SCENE <target> <message>
|
||||||
func sceneHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func sceneHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
target := msg.Params[0]
|
target := msg.Params[0]
|
||||||
message := msg.Params[1:]
|
message := msg.Params[1:]
|
||||||
|
|
||||||
@ -2812,7 +2812,7 @@ func sceneHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Res
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SETNAME <realname>
|
// SETNAME <realname>
|
||||||
func setnameHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func setnameHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
realname := msg.Params[0]
|
realname := msg.Params[0]
|
||||||
if len(msg.Params) != 1 {
|
if len(msg.Params) != 1 {
|
||||||
// workaround for clients that turn unknown commands into raw IRC lines,
|
// workaround for clients that turn unknown commands into raw IRC lines,
|
||||||
@ -2840,19 +2840,19 @@ func setnameHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *R
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SUMMON [parameters]
|
// SUMMON [parameters]
|
||||||
func summonHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func summonHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
rb.Add(nil, server.name, ERR_SUMMONDISABLED, client.Nick(), client.t("SUMMON has been disabled"))
|
rb.Add(nil, server.name, ERR_SUMMONDISABLED, client.Nick(), client.t("SUMMON has been disabled"))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// TIME
|
// TIME
|
||||||
func timeHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func timeHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
rb.Add(nil, server.name, RPL_TIME, client.nick, server.name, time.Now().UTC().Format(time.RFC1123))
|
rb.Add(nil, server.name, RPL_TIME, client.nick, server.name, time.Now().UTC().Format(time.RFC1123))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// TOPIC <channel> [<topic>]
|
// TOPIC <channel> [<topic>]
|
||||||
func topicHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func topicHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
channel := server.channels.Get(msg.Params[0])
|
channel := server.channels.Get(msg.Params[0])
|
||||||
if channel == nil {
|
if channel == nil {
|
||||||
rb.Add(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, utils.SafeErrorParam(msg.Params[0]), client.t("No such channel"))
|
rb.Add(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, utils.SafeErrorParam(msg.Params[0]), client.t("No such channel"))
|
||||||
@ -2868,7 +2868,7 @@ func topicHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Res
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UNDLINE <ip>|<net>
|
// UNDLINE <ip>|<net>
|
||||||
func unDLineHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func unDLineHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
// check oper permissions
|
// check oper permissions
|
||||||
oper := client.Oper()
|
oper := client.Oper()
|
||||||
if !oper.HasRoleCapab("ban") {
|
if !oper.HasRoleCapab("ban") {
|
||||||
@ -2901,7 +2901,7 @@ func unDLineHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *R
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UNKLINE <mask>
|
// UNKLINE <mask>
|
||||||
func unKLineHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func unKLineHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
details := client.Details()
|
details := client.Details()
|
||||||
// check oper permissions
|
// check oper permissions
|
||||||
oper := client.Oper()
|
oper := client.Oper()
|
||||||
@ -2931,7 +2931,7 @@ func unKLineHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *R
|
|||||||
}
|
}
|
||||||
|
|
||||||
// USER <username> * 0 <realname>
|
// USER <username> * 0 <realname>
|
||||||
func userHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func userHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
if client.registered {
|
if client.registered {
|
||||||
rb.Add(nil, server.name, ERR_ALREADYREGISTRED, client.Nick(), client.t("You may not reregister"))
|
rb.Add(nil, server.name, ERR_ALREADYREGISTRED, client.Nick(), client.t("You may not reregister"))
|
||||||
return false
|
return false
|
||||||
@ -2986,7 +2986,7 @@ func operStatusVisible(client, target *Client, hasPrivs bool) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// USERHOST <nickname>{ <nickname>}
|
// USERHOST <nickname>{ <nickname>}
|
||||||
func userhostHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func userhostHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
hasPrivs := client.HasMode(modes.Operator)
|
hasPrivs := client.HasMode(modes.Operator)
|
||||||
returnedClients := make(ClientSet)
|
returnedClients := make(ClientSet)
|
||||||
|
|
||||||
@ -3034,20 +3034,20 @@ func userhostHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *
|
|||||||
}
|
}
|
||||||
|
|
||||||
// USERS [parameters]
|
// USERS [parameters]
|
||||||
func usersHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func usersHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
rb.Add(nil, server.name, ERR_USERSDISABLED, client.Nick(), client.t("USERS has been disabled"))
|
rb.Add(nil, server.name, ERR_USERSDISABLED, client.Nick(), client.t("USERS has been disabled"))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// VERSION
|
// VERSION
|
||||||
func versionHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func versionHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
rb.Add(nil, server.name, RPL_VERSION, client.nick, Ver, server.name)
|
rb.Add(nil, server.name, RPL_VERSION, client.nick, Ver, server.name)
|
||||||
server.RplISupport(client, rb)
|
server.RplISupport(client, rb)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// WEBIRC <password> <gateway> <hostname> <ip> [:flag1 flag2=x flag3]
|
// WEBIRC <password> <gateway> <hostname> <ip> [:flag1 flag2=x flag3]
|
||||||
func webircHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func webircHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
// only allow unregistered clients to use this command
|
// only allow unregistered clients to use this command
|
||||||
if client.registered || client.proxiedIP != nil {
|
if client.registered || client.proxiedIP != nil {
|
||||||
return false
|
return false
|
||||||
@ -3221,7 +3221,7 @@ func (client *Client) rplWhoReply(channel *Channel, target *Client, rb *Response
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WHO <mask> [<filter>%<fields>,<type>]
|
// WHO <mask> [<filter>%<fields>,<type>]
|
||||||
func whoHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func whoHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
mask := msg.Params[0]
|
mask := msg.Params[0]
|
||||||
var err error
|
var err error
|
||||||
if mask == "" {
|
if mask == "" {
|
||||||
@ -3329,7 +3329,7 @@ func whoHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Respo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WHOIS [<target>] <mask>{,<mask>}
|
// WHOIS [<target>] <mask>{,<mask>}
|
||||||
func whoisHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func whoisHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
var masksString string
|
var masksString string
|
||||||
//var target string
|
//var target string
|
||||||
|
|
||||||
@ -3390,7 +3390,7 @@ func whoisHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Res
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WHOWAS <nickname> [<count> [<server>]]
|
// WHOWAS <nickname> [<count> [<server>]]
|
||||||
func whowasHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func whowasHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
nicknames := strings.Split(msg.Params[0], ",")
|
nicknames := strings.Split(msg.Params[0], ",")
|
||||||
|
|
||||||
// 0 means "all the entries", as does a negative number
|
// 0 means "all the entries", as does a negative number
|
||||||
@ -3424,7 +3424,7 @@ func whowasHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ZNC <module> [params]
|
// ZNC <module> [params]
|
||||||
func zncHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func zncHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
params := msg.Params[1:]
|
params := msg.Params[1:]
|
||||||
// #1205: compatibility with Palaver, which sends `ZNC *playback :play ...`
|
// #1205: compatibility with Palaver, which sends `ZNC *playback :play ...`
|
||||||
if len(params) == 1 && strings.IndexByte(params[0], ' ') != -1 {
|
if len(params) == 1 && strings.IndexByte(params[0], ' ') != -1 {
|
||||||
@ -3435,13 +3435,13 @@ func zncHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Respo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fake handler for unknown commands
|
// fake handler for unknown commands
|
||||||
func unknownCommandHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func unknownCommandHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
rb.Add(nil, server.name, ERR_UNKNOWNCOMMAND, client.Nick(), utils.SafeErrorParam(msg.Command), client.t("Unknown command"))
|
rb.Add(nil, server.name, ERR_UNKNOWNCOMMAND, client.Nick(), utils.SafeErrorParam(msg.Command), client.t("Unknown command"))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// fake handler for invalid utf8
|
// fake handler for invalid utf8
|
||||||
func invalidUtf8Handler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func invalidUtf8Handler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
rb.Add(nil, server.name, "FAIL", utils.SafeErrorParam(msg.Command), "INVALID_UTF8", client.t("Message rejected for containing invalid UTF-8"))
|
rb.Add(nil, server.name, "FAIL", utils.SafeErrorParam(msg.Command), "INVALID_UTF8", client.t("Message rejected for containing invalid UTF-8"))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ type IRCConn interface {
|
|||||||
type IRCStreamConn struct {
|
type IRCStreamConn struct {
|
||||||
conn *utils.WrappedConn
|
conn *utils.WrappedConn
|
||||||
|
|
||||||
reader ircreader.IRCReader
|
reader ircreader.Reader
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewIRCStreamConn(conn *utils.WrappedConn) *IRCStreamConn {
|
func NewIRCStreamConn(conn *utils.WrappedConn) *IRCStreamConn {
|
||||||
|
@ -42,7 +42,7 @@ type MessageCache struct {
|
|||||||
splitMessage utils.SplitMessage
|
splitMessage utils.SplitMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
func addAllTags(msg *ircmsg.IRCMessage, tags map[string]string, serverTime time.Time, msgid, accountName string) {
|
func addAllTags(msg *ircmsg.Message, tags map[string]string, serverTime time.Time, msgid, accountName string) {
|
||||||
msg.UpdateTags(tags)
|
msg.UpdateTags(tags)
|
||||||
msg.SetTag("time", serverTime.Format(IRCv3TimestampFormat))
|
msg.SetTag("time", serverTime.Format(IRCv3TimestampFormat))
|
||||||
if accountName != "*" {
|
if accountName != "*" {
|
||||||
@ -73,7 +73,7 @@ func (m *MessageCache) Initialize(server *Server, serverTime time.Time, msgid st
|
|||||||
m.command = command
|
m.command = command
|
||||||
m.params = params
|
m.params = params
|
||||||
|
|
||||||
var msg ircmsg.IRCMessage
|
var msg ircmsg.Message
|
||||||
config := server.Config()
|
config := server.Config()
|
||||||
if config.Server.Compatibility.forceTrailing && commandsThatMustUseTrailing[command] {
|
if config.Server.Compatibility.forceTrailing && commandsThatMustUseTrailing[command] {
|
||||||
msg.ForceTrailing()
|
msg.ForceTrailing()
|
||||||
@ -110,7 +110,7 @@ func (m *MessageCache) InitializeSplitMessage(server *Server, nickmask, accountN
|
|||||||
|
|
||||||
if message.Is512() {
|
if message.Is512() {
|
||||||
isTagmsg := command == "TAGMSG"
|
isTagmsg := command == "TAGMSG"
|
||||||
var msg ircmsg.IRCMessage
|
var msg ircmsg.Message
|
||||||
if forceTrailing {
|
if forceTrailing {
|
||||||
msg.ForceTrailing()
|
msg.ForceTrailing()
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ func (m *MessageCache) InitializeSplitMessage(server *Server, nickmask, accountN
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var msg ircmsg.IRCMessage
|
var msg ircmsg.Message
|
||||||
if forceTrailing {
|
if forceTrailing {
|
||||||
msg.ForceTrailing()
|
msg.ForceTrailing()
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ func (manager *MonitorManager) List(session *Session) (nicks []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
monitorSubcommands = map[string]func(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool{
|
monitorSubcommands = map[string]func(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool{
|
||||||
"-": monitorRemoveHandler,
|
"-": monitorRemoveHandler,
|
||||||
"+": monitorAddHandler,
|
"+": monitorAddHandler,
|
||||||
"c": monitorClearHandler,
|
"c": monitorClearHandler,
|
||||||
|
@ -36,14 +36,14 @@ type ResponseBuffer struct {
|
|||||||
// nested batch.)
|
// nested batch.)
|
||||||
nestedBatches []string
|
nestedBatches []string
|
||||||
|
|
||||||
messages []ircmsg.IRCMessage
|
messages []ircmsg.Message
|
||||||
finalized bool
|
finalized bool
|
||||||
target *Client
|
target *Client
|
||||||
session *Session
|
session *Session
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetLabel returns the label from the given message.
|
// GetLabel returns the label from the given message.
|
||||||
func GetLabel(msg ircmsg.IRCMessage) string {
|
func GetLabel(msg ircmsg.Message) string {
|
||||||
_, value := msg.GetTag(caps.LabelTagName)
|
_, value := msg.GetTag(caps.LabelTagName)
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ func NewResponseBuffer(session *Session) *ResponseBuffer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rb *ResponseBuffer) AddMessage(msg ircmsg.IRCMessage) {
|
func (rb *ResponseBuffer) AddMessage(msg ircmsg.Message) {
|
||||||
if rb.finalized {
|
if rb.finalized {
|
||||||
rb.target.server.logger.Error("internal", "message added to finalized ResponseBuffer, undefined behavior")
|
rb.target.server.logger.Error("internal", "message added to finalized ResponseBuffer, undefined behavior")
|
||||||
debug.PrintStack()
|
debug.PrintStack()
|
||||||
@ -72,7 +72,7 @@ func (rb *ResponseBuffer) AddMessage(msg ircmsg.IRCMessage) {
|
|||||||
rb.messages = append(rb.messages, msg)
|
rb.messages = append(rb.messages, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rb *ResponseBuffer) setNestedBatchTag(msg *ircmsg.IRCMessage) {
|
func (rb *ResponseBuffer) setNestedBatchTag(msg *ircmsg.Message) {
|
||||||
if 0 < len(rb.nestedBatches) {
|
if 0 < len(rb.nestedBatches) {
|
||||||
msg.SetTag("batch", rb.nestedBatches[len(rb.nestedBatches)-1])
|
msg.SetTag("batch", rb.nestedBatches[len(rb.nestedBatches)-1])
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ func (rb *ResponseBuffer) Add(tags map[string]string, prefix string, command str
|
|||||||
// Broadcast adds a standard new message to our queue, then sends an unlabeled copy
|
// Broadcast adds a standard new message to our queue, then sends an unlabeled copy
|
||||||
// to all other sessions.
|
// to all other sessions.
|
||||||
func (rb *ResponseBuffer) Broadcast(tags map[string]string, prefix string, command string, params ...string) {
|
func (rb *ResponseBuffer) Broadcast(tags map[string]string, prefix string, command string, params ...string) {
|
||||||
// can't reuse the IRCMessage object because of tag pollution :-\
|
// can't reuse the Message object because of tag pollution :-\
|
||||||
rb.Add(tags, prefix, command, params...)
|
rb.Add(tags, prefix, command, params...)
|
||||||
for _, session := range rb.session.client.Sessions() {
|
for _, session := range rb.session.client.Sessions() {
|
||||||
if session != rb.session {
|
if session != rb.session {
|
||||||
|
@ -116,7 +116,7 @@ HELP returns information on the given command.`,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// generic handler for IRC commands like `/NICKSERV INFO`
|
// generic handler for IRC commands like `/NICKSERV INFO`
|
||||||
func serviceCmdHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func serviceCmdHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
service, ok := oragonoServicesByCommandAlias[msg.Command]
|
service, ok := oragonoServicesByCommandAlias[msg.Command]
|
||||||
if !ok {
|
if !ok {
|
||||||
server.logger.Warning("internal", "can't handle unrecognized service", msg.Command)
|
server.logger.Warning("internal", "can't handle unrecognized service", msg.Command)
|
||||||
|
@ -98,7 +98,7 @@ func parseUbanTarget(param string) (target ubanTarget, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UBAN <subcommand> [target] [DURATION <duration>] [reason...]
|
// UBAN <subcommand> [target] [DURATION <duration>] [reason...]
|
||||||
func ubanHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) bool {
|
func ubanHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||||
subcommand := strings.ToLower(msg.Params[0])
|
subcommand := strings.ToLower(msg.Params[0])
|
||||||
params := msg.Params[1:]
|
params := msg.Params[1:]
|
||||||
var target ubanTarget
|
var target ubanTarget
|
||||||
|
52
vendor/github.com/goshuirc/irc-go/ircmsg/message.go
generated
vendored
52
vendor/github.com/goshuirc/irc-go/ircmsg/message.go
generated
vendored
@ -61,10 +61,10 @@ var (
|
|||||||
ErrorBadParam = errors.New("Cannot have an empty param, a param with spaces, or a param that starts with ':' before the last parameter")
|
ErrorBadParam = errors.New("Cannot have an empty param, a param with spaces, or a param that starts with ':' before the last parameter")
|
||||||
)
|
)
|
||||||
|
|
||||||
// IRCMessage represents an IRC message, as defined by the RFCs and as
|
// Message represents an IRC message, as defined by the RFCs and as
|
||||||
// extended by the IRCv3 Message Tags specification with the introduction
|
// extended by the IRCv3 Message Tags specification with the introduction
|
||||||
// of message tags.
|
// of message tags.
|
||||||
type IRCMessage struct {
|
type Message struct {
|
||||||
Prefix string
|
Prefix string
|
||||||
Command string
|
Command string
|
||||||
Params []string
|
Params []string
|
||||||
@ -77,12 +77,12 @@ type IRCMessage struct {
|
|||||||
// will be encoded as a "trailing parameter" (preceded by a colon). This is
|
// will be encoded as a "trailing parameter" (preceded by a colon). This is
|
||||||
// almost never necessary and should not be used except when having to interact
|
// almost never necessary and should not be used except when having to interact
|
||||||
// with broken implementations that don't correctly interpret IRC messages.
|
// with broken implementations that don't correctly interpret IRC messages.
|
||||||
func (msg *IRCMessage) ForceTrailing() {
|
func (msg *Message) ForceTrailing() {
|
||||||
msg.forceTrailing = true
|
msg.forceTrailing = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTag returns whether a tag is present, and if so, what its value is.
|
// GetTag returns whether a tag is present, and if so, what its value is.
|
||||||
func (msg *IRCMessage) GetTag(tagName string) (present bool, value string) {
|
func (msg *Message) GetTag(tagName string) (present bool, value string) {
|
||||||
if len(tagName) == 0 {
|
if len(tagName) == 0 {
|
||||||
return
|
return
|
||||||
} else if tagName[0] == '+' {
|
} else if tagName[0] == '+' {
|
||||||
@ -95,13 +95,13 @@ func (msg *IRCMessage) GetTag(tagName string) (present bool, value string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HasTag returns whether a tag is present.
|
// HasTag returns whether a tag is present.
|
||||||
func (msg *IRCMessage) HasTag(tagName string) (present bool) {
|
func (msg *Message) HasTag(tagName string) (present bool) {
|
||||||
present, _ = msg.GetTag(tagName)
|
present, _ = msg.GetTag(tagName)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetTag sets a tag.
|
// SetTag sets a tag.
|
||||||
func (msg *IRCMessage) SetTag(tagName, tagValue string) {
|
func (msg *Message) SetTag(tagName, tagValue string) {
|
||||||
if len(tagName) == 0 {
|
if len(tagName) == 0 {
|
||||||
return
|
return
|
||||||
} else if tagName[0] == '+' {
|
} else if tagName[0] == '+' {
|
||||||
@ -118,7 +118,7 @@ func (msg *IRCMessage) SetTag(tagName, tagValue string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DeleteTag deletes a tag.
|
// DeleteTag deletes a tag.
|
||||||
func (msg *IRCMessage) DeleteTag(tagName string) {
|
func (msg *Message) DeleteTag(tagName string) {
|
||||||
if len(tagName) == 0 {
|
if len(tagName) == 0 {
|
||||||
return
|
return
|
||||||
} else if tagName[0] == '+' {
|
} else if tagName[0] == '+' {
|
||||||
@ -129,14 +129,14 @@ func (msg *IRCMessage) DeleteTag(tagName string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateTags is a convenience to set multiple tags at once.
|
// UpdateTags is a convenience to set multiple tags at once.
|
||||||
func (msg *IRCMessage) UpdateTags(tags map[string]string) {
|
func (msg *Message) UpdateTags(tags map[string]string) {
|
||||||
for name, value := range tags {
|
for name, value := range tags {
|
||||||
msg.SetTag(name, value)
|
msg.SetTag(name, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// AllTags returns all tags as a single map.
|
// AllTags returns all tags as a single map.
|
||||||
func (msg *IRCMessage) AllTags() (result map[string]string) {
|
func (msg *Message) AllTags() (result map[string]string) {
|
||||||
result = make(map[string]string, len(msg.tags)+len(msg.clientOnlyTags))
|
result = make(map[string]string, len(msg.tags)+len(msg.clientOnlyTags))
|
||||||
for name, value := range msg.tags {
|
for name, value := range msg.tags {
|
||||||
result[name] = value
|
result[name] = value
|
||||||
@ -148,23 +148,23 @@ func (msg *IRCMessage) AllTags() (result map[string]string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ClientOnlyTags returns the client-only tags (the tags with the + prefix).
|
// ClientOnlyTags returns the client-only tags (the tags with the + prefix).
|
||||||
// The returned map may be internal storage of the IRCMessage object and
|
// The returned map may be internal storage of the Message object and
|
||||||
// should not be modified.
|
// should not be modified.
|
||||||
func (msg *IRCMessage) ClientOnlyTags() map[string]string {
|
func (msg *Message) ClientOnlyTags() map[string]string {
|
||||||
return msg.clientOnlyTags
|
return msg.clientOnlyTags
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseLine creates and returns a message from the given IRC line.
|
// ParseLine creates and returns a message from the given IRC line.
|
||||||
func ParseLine(line string) (ircmsg IRCMessage, err error) {
|
func ParseLine(line string) (ircmsg Message, err error) {
|
||||||
return parseLine(line, 0, 0)
|
return parseLine(line, 0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseLineStrict creates and returns an IRCMessage from the given IRC line,
|
// ParseLineStrict creates and returns an Message from the given IRC line,
|
||||||
// taking the maximum length into account and truncating the message as appropriate.
|
// taking the maximum length into account and truncating the message as appropriate.
|
||||||
// If fromClient is true, it enforces the client limit on tag data length (4094 bytes),
|
// If fromClient is true, it enforces the client limit on tag data length (4094 bytes),
|
||||||
// allowing the server to return ERR_INPUTTOOLONG as appropriate. If truncateLen is
|
// allowing the server to return ERR_INPUTTOOLONG as appropriate. If truncateLen is
|
||||||
// nonzero, it is the length at which the non-tag portion of the message is truncated.
|
// nonzero, it is the length at which the non-tag portion of the message is truncated.
|
||||||
func ParseLineStrict(line string, fromClient bool, truncateLen int) (ircmsg IRCMessage, err error) {
|
func ParseLineStrict(line string, fromClient bool, truncateLen int) (ircmsg Message, err error) {
|
||||||
maxTagDataLength := MaxlenTagData
|
maxTagDataLength := MaxlenTagData
|
||||||
if fromClient {
|
if fromClient {
|
||||||
maxTagDataLength = MaxlenClientTagData
|
maxTagDataLength = MaxlenClientTagData
|
||||||
@ -180,7 +180,7 @@ func trimInitialSpaces(str string) string {
|
|||||||
return str[i:]
|
return str[i:]
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseLine(line string, maxTagDataLength int, truncateLen int) (ircmsg IRCMessage, err error) {
|
func parseLine(line string, maxTagDataLength int, truncateLen int) (ircmsg Message, err error) {
|
||||||
// remove either \n or \r\n from the end of the line:
|
// remove either \n or \r\n from the end of the line:
|
||||||
line = strings.TrimSuffix(line, "\n")
|
line = strings.TrimSuffix(line, "\n")
|
||||||
line = strings.TrimSuffix(line, "\r")
|
line = strings.TrimSuffix(line, "\r")
|
||||||
@ -279,7 +279,7 @@ func parseLine(line string, maxTagDataLength int, truncateLen int) (ircmsg IRCMe
|
|||||||
}
|
}
|
||||||
|
|
||||||
// helper to parse tags
|
// helper to parse tags
|
||||||
func (ircmsg *IRCMessage) parseTags(tags string) (err error) {
|
func (ircmsg *Message) parseTags(tags string) (err error) {
|
||||||
for 0 < len(tags) {
|
for 0 < len(tags) {
|
||||||
tagEnd := strings.IndexByte(tags, ';')
|
tagEnd := strings.IndexByte(tags, ';')
|
||||||
endPos := tagEnd
|
endPos := tagEnd
|
||||||
@ -311,8 +311,8 @@ func (ircmsg *IRCMessage) parseTags(tags string) (err error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MakeMessage provides a simple way to create a new IRCMessage.
|
// MakeMessage provides a simple way to create a new Message.
|
||||||
func MakeMessage(tags map[string]string, prefix string, command string, params ...string) (ircmsg IRCMessage) {
|
func MakeMessage(tags map[string]string, prefix string, command string, params ...string) (ircmsg Message) {
|
||||||
ircmsg.Prefix = prefix
|
ircmsg.Prefix = prefix
|
||||||
ircmsg.Command = command
|
ircmsg.Command = command
|
||||||
ircmsg.Params = params
|
ircmsg.Params = params
|
||||||
@ -320,8 +320,8 @@ func MakeMessage(tags map[string]string, prefix string, command string, params .
|
|||||||
return ircmsg
|
return ircmsg
|
||||||
}
|
}
|
||||||
|
|
||||||
// Line returns a sendable line created from an IRCMessage.
|
// Line returns a sendable line created from an Message.
|
||||||
func (ircmsg *IRCMessage) Line() (result string, err error) {
|
func (ircmsg *Message) Line() (result string, err error) {
|
||||||
bytes, err := ircmsg.line(0, 0, 0, 0)
|
bytes, err := ircmsg.line(0, 0, 0, 0)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
result = string(bytes)
|
result = string(bytes)
|
||||||
@ -329,17 +329,17 @@ func (ircmsg *IRCMessage) Line() (result string, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// LineBytes returns a sendable line created from an IRCMessage.
|
// LineBytes returns a sendable line created from an Message.
|
||||||
func (ircmsg *IRCMessage) LineBytes() (result []byte, err error) {
|
func (ircmsg *Message) LineBytes() (result []byte, err error) {
|
||||||
result, err = ircmsg.line(0, 0, 0, 0)
|
result, err = ircmsg.line(0, 0, 0, 0)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// LineBytesStrict returns a sendable line, as a []byte, created from an IRCMessage.
|
// LineBytesStrict returns a sendable line, as a []byte, created from an Message.
|
||||||
// fromClient controls whether the server-side or client-side tag length limit
|
// fromClient controls whether the server-side or client-side tag length limit
|
||||||
// is enforced. If truncateLen is nonzero, it is the length at which the
|
// is enforced. If truncateLen is nonzero, it is the length at which the
|
||||||
// non-tag portion of the message is truncated.
|
// non-tag portion of the message is truncated.
|
||||||
func (ircmsg *IRCMessage) LineBytesStrict(fromClient bool, truncateLen int) ([]byte, error) {
|
func (ircmsg *Message) LineBytesStrict(fromClient bool, truncateLen int) ([]byte, error) {
|
||||||
var tagLimit, clientOnlyTagDataLimit, serverAddedTagDataLimit int
|
var tagLimit, clientOnlyTagDataLimit, serverAddedTagDataLimit int
|
||||||
if fromClient {
|
if fromClient {
|
||||||
// enforce client max tags:
|
// enforce client max tags:
|
||||||
@ -359,8 +359,8 @@ func paramRequiresTrailing(param string) bool {
|
|||||||
return len(param) == 0 || strings.IndexByte(param, ' ') != -1 || param[0] == ':'
|
return len(param) == 0 || strings.IndexByte(param, ' ') != -1 || param[0] == ':'
|
||||||
}
|
}
|
||||||
|
|
||||||
// line returns a sendable line created from an IRCMessage.
|
// line returns a sendable line created from an Message.
|
||||||
func (ircmsg *IRCMessage) line(tagLimit, clientOnlyTagDataLimit, serverAddedTagDataLimit, truncateLen int) (result []byte, err error) {
|
func (ircmsg *Message) line(tagLimit, clientOnlyTagDataLimit, serverAddedTagDataLimit, truncateLen int) (result []byte, err error) {
|
||||||
if len(ircmsg.Command) == 0 {
|
if len(ircmsg.Command) == 0 {
|
||||||
return nil, ErrorCommandMissing
|
return nil, ErrorCommandMissing
|
||||||
}
|
}
|
||||||
|
2
vendor/github.com/goshuirc/irc-go/ircmsg/tags.go
generated
vendored
2
vendor/github.com/goshuirc/irc-go/ircmsg/tags.go
generated
vendored
@ -30,7 +30,7 @@ func init() {
|
|||||||
// EscapeTagValue takes a value, and returns an escaped message tag value.
|
// EscapeTagValue takes a value, and returns an escaped message tag value.
|
||||||
//
|
//
|
||||||
// This function is automatically used when lines are created from an
|
// This function is automatically used when lines are created from an
|
||||||
// IRCMessage, so you don't need to call it yourself before creating a line.
|
// Message, so you don't need to call it yourself before creating a line.
|
||||||
func EscapeTagValue(inString string) string {
|
func EscapeTagValue(inString string) string {
|
||||||
return valtoescape.Replace(inString)
|
return valtoescape.Replace(inString)
|
||||||
}
|
}
|
||||||
|
18
vendor/github.com/goshuirc/irc-go/ircreader/ircreader.go
generated
vendored
18
vendor/github.com/goshuirc/irc-go/ircreader/ircreader.go
generated
vendored
@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
IRCReader is an optimized line reader for IRC lines containing tags;
|
Reader is an optimized line reader for IRC lines containing tags;
|
||||||
most IRC lines will not approach the maximum line length (8191 bytes
|
most IRC lines will not approach the maximum line length (8191 bytes
|
||||||
of tag data, plus 512 bytes of message data), so we want a buffered
|
of tag data, plus 512 bytes of message data), so we want a buffered
|
||||||
reader that can start with a smaller buffer and expand if necessary,
|
reader that can start with a smaller buffer and expand if necessary,
|
||||||
@ -21,7 +21,7 @@ var (
|
|||||||
ErrReadQ = errors.New("readQ exceeded (read too many bytes without terminating newline)")
|
ErrReadQ = errors.New("readQ exceeded (read too many bytes without terminating newline)")
|
||||||
)
|
)
|
||||||
|
|
||||||
type IRCReader struct {
|
type Reader struct {
|
||||||
conn io.Reader
|
conn io.Reader
|
||||||
|
|
||||||
initialSize int
|
initialSize int
|
||||||
@ -34,17 +34,17 @@ type IRCReader struct {
|
|||||||
eof bool
|
eof bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a new *IRCReader with sane buffer size limits.
|
// Returns a new *Reader with sane buffer size limits.
|
||||||
func NewIRCReader(conn io.Reader) *IRCReader {
|
func NewIRCReader(conn io.Reader) *Reader {
|
||||||
var reader IRCReader
|
var reader Reader
|
||||||
reader.Initialize(conn, 512, 8192+1024)
|
reader.Initialize(conn, 512, 8192+1024)
|
||||||
return &reader
|
return &reader
|
||||||
}
|
}
|
||||||
|
|
||||||
// "Placement new" for an IRCReader; initializes it with custom buffer size
|
// "Placement new" for a Reader; initializes it with custom buffer size
|
||||||
// limits.
|
// limits.
|
||||||
func (cc *IRCReader) Initialize(conn io.Reader, initialSize, maxSize int) {
|
func (cc *Reader) Initialize(conn io.Reader, initialSize, maxSize int) {
|
||||||
*cc = IRCReader{}
|
*cc = Reader{}
|
||||||
cc.conn = conn
|
cc.conn = conn
|
||||||
cc.initialSize = initialSize
|
cc.initialSize = initialSize
|
||||||
cc.maxSize = maxSize
|
cc.maxSize = maxSize
|
||||||
@ -54,7 +54,7 @@ func (cc *IRCReader) Initialize(conn io.Reader, initialSize, maxSize int) {
|
|||||||
// or \r\n as the line terminator (but not \r in isolation). Passes through
|
// or \r\n as the line terminator (but not \r in isolation). Passes through
|
||||||
// errors from the underlying connection. Returns ErrReadQ if the buffer limit
|
// errors from the underlying connection. Returns ErrReadQ if the buffer limit
|
||||||
// was exceeded without a terminating \n.
|
// was exceeded without a terminating \n.
|
||||||
func (cc *IRCReader) ReadLine() ([]byte, error) {
|
func (cc *Reader) ReadLine() ([]byte, error) {
|
||||||
for {
|
for {
|
||||||
// try to find a terminated line in the buffered data already read
|
// try to find a terminated line in the buffered data already read
|
||||||
nlidx := bytes.IndexByte(cc.buf[cc.searchFrom:cc.end], '\n')
|
nlidx := bytes.IndexByte(cc.buf[cc.searchFrom:cc.end], '\n')
|
||||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -21,7 +21,7 @@ github.com/go-sql-driver/mysql
|
|||||||
# github.com/gorilla/websocket v1.4.2 => github.com/oragono/websocket v1.4.2-oragono1
|
# github.com/gorilla/websocket v1.4.2 => github.com/oragono/websocket v1.4.2-oragono1
|
||||||
## explicit
|
## explicit
|
||||||
github.com/gorilla/websocket
|
github.com/gorilla/websocket
|
||||||
# github.com/goshuirc/irc-go v0.0.0-20210304031553-cf78e9176f96
|
# github.com/goshuirc/irc-go v0.0.0-20210311004346-ea7a188a73fe
|
||||||
## explicit
|
## explicit
|
||||||
github.com/goshuirc/irc-go/ircfmt
|
github.com/goshuirc/irc-go/ircfmt
|
||||||
github.com/goshuirc/irc-go/ircmsg
|
github.com/goshuirc/irc-go/ircmsg
|
||||||
|
Loading…
Reference in New Issue
Block a user