From d807f1252febc6d91c5104e94b6acc44545ec80f Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Tue, 14 Jan 2020 01:21:47 -0500 Subject: [PATCH] move generateISupport to config.go --- irc/config.go | 40 ++++++++++++++++++++++++++++++++++++++++ irc/server.go | 40 ---------------------------------------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/irc/config.go b/irc/config.go index 93e31836..25acb5cc 100644 --- a/irc/config.go +++ b/irc/config.go @@ -911,6 +911,46 @@ func LoadConfig(filename string) (config *Config, err error) { return config, nil } +// setISupport sets up our RPL_ISUPPORT reply. +func (config *Config) generateISupport() (err error) { + maxTargetsString := strconv.Itoa(maxTargets) + + // add RPL_ISUPPORT tokens + isupport := &config.Server.isupport + isupport.Initialize() + isupport.Add("AWAYLEN", strconv.Itoa(config.Limits.AwayLen)) + isupport.Add("CASEMAPPING", "ascii") + isupport.Add("CHANLIMIT", fmt.Sprintf("%s:%d", chanTypes, config.Channels.MaxChannelsPerClient)) + isupport.Add("CHANMODES", strings.Join([]string{modes.Modes{modes.BanMask, modes.ExceptMask, modes.InviteMask}.String(), "", modes.Modes{modes.UserLimit, modes.Key}.String(), modes.Modes{modes.InviteOnly, modes.Moderated, modes.NoOutside, modes.OpOnlyTopic, modes.ChanRoleplaying, modes.Secret}.String()}, ",")) + if config.History.Enabled && config.History.ChathistoryMax > 0 { + isupport.Add("draft/CHATHISTORY", strconv.Itoa(config.History.ChathistoryMax)) + } + isupport.Add("CHANNELLEN", strconv.Itoa(config.Limits.ChannelLen)) + isupport.Add("CHANTYPES", chanTypes) + isupport.Add("ELIST", "U") + isupport.Add("EXCEPTS", "") + isupport.Add("INVEX", "") + isupport.Add("KICKLEN", strconv.Itoa(config.Limits.KickLen)) + isupport.Add("MAXLIST", fmt.Sprintf("beI:%s", strconv.Itoa(config.Limits.ChanListModes))) + isupport.Add("MAXTARGETS", maxTargetsString) + isupport.Add("MODES", "") + isupport.Add("MONITOR", strconv.Itoa(config.Limits.MonitorEntries)) + isupport.Add("NETWORK", config.Network.Name) + isupport.Add("NICKLEN", strconv.Itoa(config.Limits.NickLen)) + isupport.Add("PREFIX", "(qaohv)~&@%+") + isupport.Add("RPCHAN", "E") + isupport.Add("RPUSER", "E") + isupport.Add("STATUSMSG", "~&@%+") + isupport.Add("TARGMAX", fmt.Sprintf("NAMES:1,LIST:1,KICK:1,WHOIS:1,USERHOST:10,PRIVMSG:%s,TAGMSG:%s,NOTICE:%s,MONITOR:", maxTargetsString, maxTargetsString, maxTargetsString)) + isupport.Add("TOPICLEN", strconv.Itoa(config.Limits.TopicLen)) + if config.Server.Casemapping == CasemappingPRECIS { + isupport.Add("UTF8MAPPING", precisUTF8MappingToken) + } + + err = isupport.RegenerateCachedReply() + return +} + // Diff returns changes in supported caps across a rehash. func (config *Config) Diff(oldConfig *Config) (addedCaps, removedCaps *caps.Set) { addedCaps = caps.NewSet() diff --git a/irc/server.go b/irc/server.go index 68a808cb..a61c83e0 100644 --- a/irc/server.go +++ b/irc/server.go @@ -133,46 +133,6 @@ func NewServer(config *Config, logger *logger.Manager) (*Server, error) { return server, nil } -// setISupport sets up our RPL_ISUPPORT reply. -func (config *Config) generateISupport() (err error) { - maxTargetsString := strconv.Itoa(maxTargets) - - // add RPL_ISUPPORT tokens - isupport := &config.Server.isupport - isupport.Initialize() - isupport.Add("AWAYLEN", strconv.Itoa(config.Limits.AwayLen)) - isupport.Add("CASEMAPPING", "ascii") - isupport.Add("CHANLIMIT", fmt.Sprintf("%s:%d", chanTypes, config.Channels.MaxChannelsPerClient)) - isupport.Add("CHANMODES", strings.Join([]string{modes.Modes{modes.BanMask, modes.ExceptMask, modes.InviteMask}.String(), "", modes.Modes{modes.UserLimit, modes.Key}.String(), modes.Modes{modes.InviteOnly, modes.Moderated, modes.NoOutside, modes.OpOnlyTopic, modes.ChanRoleplaying, modes.Secret}.String()}, ",")) - if config.History.Enabled && config.History.ChathistoryMax > 0 { - isupport.Add("draft/CHATHISTORY", strconv.Itoa(config.History.ChathistoryMax)) - } - isupport.Add("CHANNELLEN", strconv.Itoa(config.Limits.ChannelLen)) - isupport.Add("CHANTYPES", chanTypes) - isupport.Add("ELIST", "U") - isupport.Add("EXCEPTS", "") - isupport.Add("INVEX", "") - isupport.Add("KICKLEN", strconv.Itoa(config.Limits.KickLen)) - isupport.Add("MAXLIST", fmt.Sprintf("beI:%s", strconv.Itoa(config.Limits.ChanListModes))) - isupport.Add("MAXTARGETS", maxTargetsString) - isupport.Add("MODES", "") - isupport.Add("MONITOR", strconv.Itoa(config.Limits.MonitorEntries)) - isupport.Add("NETWORK", config.Network.Name) - isupport.Add("NICKLEN", strconv.Itoa(config.Limits.NickLen)) - isupport.Add("PREFIX", "(qaohv)~&@%+") - isupport.Add("RPCHAN", "E") - isupport.Add("RPUSER", "E") - isupport.Add("STATUSMSG", "~&@%+") - isupport.Add("TARGMAX", fmt.Sprintf("NAMES:1,LIST:1,KICK:1,WHOIS:1,USERHOST:10,PRIVMSG:%s,TAGMSG:%s,NOTICE:%s,MONITOR:", maxTargetsString, maxTargetsString, maxTargetsString)) - isupport.Add("TOPICLEN", strconv.Itoa(config.Limits.TopicLen)) - if config.Server.Casemapping == CasemappingPRECIS { - isupport.Add("UTF8MAPPING", precisUTF8MappingToken) - } - - err = isupport.RegenerateCachedReply() - return -} - // Shutdown shuts down the server. func (server *Server) Shutdown() { //TODO(dan): Make sure we disallow new nicks