server: Support more RPL_ISUPPORT stuff

This commit is contained in:
Daniel Oaks 2016-10-24 01:01:27 +10:00
parent 78028135eb
commit f62ffe006f
2 changed files with 18 additions and 7 deletions

View File

@ -13,6 +13,7 @@ New release of Oragono!
* Added operator classes, allowing for more finely-grained permissions for operators. * Added operator classes, allowing for more finely-grained permissions for operators.
* Added automatic client connection limiting, similar to other IRCds. * Added automatic client connection limiting, similar to other IRCds.
* Length of channel mode lists (ban / ban-except / invite-except) is now restricted to the limit in config. * Length of channel mode lists (ban / ban-except / invite-except) is now restricted to the limit in config.
* Support `MAXLIST`, `MAXTARGETS`, `MODES`, `TARGMAX` in `RPL_ISUPPORT`.
* Added support for IRCv3 capability [`chghost`](http://ircv3.net/specs/extensions/chghost-3.2.html). * Added support for IRCv3 capability [`chghost`](http://ircv3.net/specs/extensions/chghost-3.2.html).
### Changed ### Changed

View File

@ -269,13 +269,14 @@ func (server *Server) setISupport() {
server.isupport.Add("INVEX", "") server.isupport.Add("INVEX", "")
server.isupport.Add("KICKLEN", strconv.Itoa(server.limits.KickLen)) server.isupport.Add("KICKLEN", strconv.Itoa(server.limits.KickLen))
server.isupport.Add("MAXLIST", fmt.Sprintf("beI:%s", strconv.Itoa(server.limits.ChanListModes))) server.isupport.Add("MAXLIST", fmt.Sprintf("beI:%s", strconv.Itoa(server.limits.ChanListModes)))
// server.isupport.Add("MODES", "") //TODO(dan): Support max modes? server.isupport.Add("MAXTARGETS", "4")
server.isupport.Add("MODES", "")
server.isupport.Add("MONITOR", strconv.Itoa(server.limits.MonitorEntries)) server.isupport.Add("MONITOR", strconv.Itoa(server.limits.MonitorEntries))
server.isupport.Add("NETWORK", server.networkName) server.isupport.Add("NETWORK", server.networkName)
server.isupport.Add("NICKLEN", strconv.Itoa(server.limits.NickLen)) server.isupport.Add("NICKLEN", strconv.Itoa(server.limits.NickLen))
server.isupport.Add("PREFIX", "(qaohv)~&@%+") server.isupport.Add("PREFIX", "(qaohv)~&@%+")
server.isupport.Add("STATUSMSG", "~&@%+") server.isupport.Add("STATUSMSG", "~&@%+")
// server.isupport.Add("TARGMAX", "") //TODO(dan): Support this server.isupport.Add("TARGMAX", "NAMES:1,LIST:1,KICK:1,WHOIS:1,PRIVMSG:4,NOTICE:4,MONITOR:")
server.isupport.Add("TOPICLEN", strconv.Itoa(server.limits.TopicLen)) server.isupport.Add("TOPICLEN", strconv.Itoa(server.limits.TopicLen))
// account registration // account registration
@ -739,7 +740,7 @@ func privmsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool
targets := strings.Split(msg.Params[0], ",") targets := strings.Split(msg.Params[0], ",")
message := msg.Params[1] message := msg.Params[1]
for _, targetString := range targets { for _, targetString := range targets[:4] {
prefixes, targetString := SplitChannelMembershipPrefixes(targetString) prefixes, targetString := SplitChannelMembershipPrefixes(targetString)
lowestPrefix := GetLowestChannelModePrefix(prefixes) lowestPrefix := GetLowestChannelModePrefix(prefixes)
@ -819,9 +820,8 @@ func whoisHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
} }
} }
} else { } else {
// specifically treat this as a single lookup rather than splitting as we do above // only get the first request
// this is by design casefoldedMask, err := Casefold(strings.Split(masksString, ",")[0])
casefoldedMask, err := Casefold(masksString)
mclient := server.clients.Get(casefoldedMask) mclient := server.clients.Get(casefoldedMask)
if err != nil || mclient == nil { if err != nil || mclient == nil {
client.Send(nil, client.server.name, ERR_NOSUCHNICK, masksString, "No such nick") client.Send(nil, client.server.name, ERR_NOSUCHNICK, masksString, "No such nick")
@ -1220,7 +1220,7 @@ func noticeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
targets := strings.Split(msg.Params[0], ",") targets := strings.Split(msg.Params[0], ",")
message := msg.Params[1] message := msg.Params[1]
for _, targetString := range targets { for _, targetString := range targets[:4] {
prefixes, targetString := SplitChannelMembershipPrefixes(targetString) prefixes, targetString := SplitChannelMembershipPrefixes(targetString)
lowestPrefix := GetLowestChannelModePrefix(prefixes) lowestPrefix := GetLowestChannelModePrefix(prefixes)
@ -1349,6 +1349,11 @@ func listHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
client.RplList(channel) client.RplList(channel)
} }
} else { } else {
// limit regular users to only listing one channel
if !client.flags[Operator] {
channels = channels[:1]
}
for _, chname := range channels { for _, chname := range channels {
casefoldedChname, err := CasefoldChannel(chname) casefoldedChname, err := CasefoldChannel(chname)
channel := server.channels.Get(casefoldedChname) channel := server.channels.Get(casefoldedChname)
@ -1397,6 +1402,11 @@ func namesHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
return false return false
} }
// limit regular users to only listing one channel
if !client.flags[Operator] {
channels = channels[:1]
}
for _, chname := range channels { for _, chname := range channels {
casefoldedChname, err := CasefoldChannel(chname) casefoldedChname, err := CasefoldChannel(chname)
channel := server.channels.Get(casefoldedChname) channel := server.channels.Get(casefoldedChname)