Patched critical bug I.
This commit is contained in:
parent
7c532f9233
commit
ead0c8e3c9
67
main.go
67
main.go
@ -485,21 +485,14 @@ func handleConn(conn net.Conn) {
|
|||||||
client.fwrite(":server 303 %s :%s\r\n", client.nick, strings.Join(online, " "))
|
client.fwrite(":server 303 %s :%s\r\n", client.nick, strings.Join(online, " "))
|
||||||
// ircv3 stuff
|
// ircv3 stuff
|
||||||
case "CHATHISTORY":
|
case "CHATHISTORY":
|
||||||
|
if len(msg.Params) < 1 {
|
||||||
|
client.fwrite(":server 461 %s CHATHISTORY :Not enough parameters\r\n", client.nick)
|
||||||
|
continue
|
||||||
|
}
|
||||||
subcmd := strings.ToUpper(msg.Params[0])
|
subcmd := strings.ToUpper(msg.Params[0])
|
||||||
|
|
||||||
if subcmd == "LATEST" {
|
switch subcmd {
|
||||||
if len(msg.Params) < 3 {
|
case "LATEST", "BEFORE", "AFTER", "AROUND":
|
||||||
client.fwrite(":server 461 %s CHATHISTORY :Not enough parameters\r\n", client.nick)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
target := historyTargetName(msg.Params[1])
|
|
||||||
count, convErr := strconv.Atoi(msg.Params[2])
|
|
||||||
if convErr != nil || count <= 0 {
|
|
||||||
client.fwrite(":server 461 %s CHATHISTORY :Invalid message count\r\n", client.nick)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
client.serveHistory(subcmd, target, count, msg.Params)
|
|
||||||
} else {
|
|
||||||
if len(msg.Params) < 4 {
|
if len(msg.Params) < 4 {
|
||||||
client.fwrite(":server 461 %s CHATHISTORY :Not enough parameters\r\n", client.nick)
|
client.fwrite(":server 461 %s CHATHISTORY :Not enough parameters\r\n", client.nick)
|
||||||
continue
|
continue
|
||||||
@ -511,9 +504,37 @@ func handleConn(conn net.Conn) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
client.serveHistory(subcmd, target, count, msg.Params)
|
client.serveHistory(subcmd, target, count, msg.Params)
|
||||||
|
|
||||||
|
case "BETWEEN":
|
||||||
|
if len(msg.Params) < 5 {
|
||||||
|
client.fwrite(":server 461 %s CHATHISTORY :Not enough parameters\r\n", client.nick)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
target := historyTargetName(msg.Params[1])
|
||||||
|
count, convErr := strconv.Atoi(msg.Params[4])
|
||||||
|
if convErr != nil || count <= 0 {
|
||||||
|
client.fwrite(":server 461 %s CHATHISTORY :Invalid message count\r\n", client.nick)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
client.serveHistory(subcmd, target, count, msg.Params)
|
||||||
|
|
||||||
|
case "TARGETS":
|
||||||
|
if len(msg.Params) < 4 {
|
||||||
|
client.fwrite(":server 461 %s CHATHISTORY :Not enough parameters\r\n", client.nick)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
count, convErr := strconv.Atoi(msg.Params[3])
|
||||||
|
if convErr != nil || count <= 0 {
|
||||||
|
client.fwrite(":server 461 %s CHATHISTORY :Invalid message count\r\n", client.nick)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
client.serveHistory(subcmd, "", count, msg.Params)
|
||||||
|
|
||||||
|
default:
|
||||||
|
client.fwrite(":server 400 %s CHATHISTORY :Unknown subcommand\r\n", client.nick)
|
||||||
}
|
}
|
||||||
|
|
||||||
case "MONITOR":
|
case "MONITOR":
|
||||||
if len(msg.Params) < 1 {
|
if len(msg.Params) < 1 {
|
||||||
client.fwrite(":server 461 %s MONITOR :Not enough parameters\r\n", client.nick)
|
client.fwrite(":server 461 %s MONITOR :Not enough parameters\r\n", client.nick)
|
||||||
continue
|
continue
|
||||||
@ -644,6 +665,24 @@ func (c *Client) serveHistory(subcmd, target string, count int, params []string)
|
|||||||
}
|
}
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
msgs = scanRows(rows, target)
|
msgs = scanRows(rows, target)
|
||||||
|
case "BETWEEN":
|
||||||
|
if len(params) < 5 {
|
||||||
|
c.fwrite(":server 461 %s CHATHISTORY :Not enough parameters\r\n", c.nick)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
start := strings.TrimPrefix(params[2], "msgid=")
|
||||||
|
end := strings.TrimPrefix(params[3], "msgid=")
|
||||||
|
rows, err := db.Query(`SELECT msgid, timestamp, prefix, command, msg
|
||||||
|
FROM messages
|
||||||
|
WHERE channel=? AND msgid BETWEEN ? AND ?
|
||||||
|
ORDER BY timestamp ASC LIMIT ?`,
|
||||||
|
target, start, end, count)
|
||||||
|
if err != nil {
|
||||||
|
c.fwrite(":server 718 %s %s :No history available\r\n", c.nick, target)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
msgs = scanRows(rows, target)
|
||||||
|
|
||||||
case "AFTER":
|
case "AFTER":
|
||||||
if len(params) < 4 {
|
if len(params) < 4 {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user