From 06028e0117472dc37f1b99054c339b5f35ee50e9 Mon Sep 17 00:00:00 2001 From: Daniel Oaks Date: Fri, 14 Oct 2016 21:04:04 +1000 Subject: [PATCH] modes: Remove channel.Persist mode It's broken anyways, and we'll be replacing it with our custom channel ownership stuff later. --- CHANGELOG.md | 3 ++- README.md | 1 - irc/channel.go | 35 ++--------------------------------- irc/modes.go | 5 ++--- irc/server.go | 39 +-------------------------------------- 5 files changed, 7 insertions(+), 76 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dab6d26..e451b21b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,13 +12,14 @@ Improved compatibility, more features, etc. ### Security ### Added -* Add integrated help. +* Added integrated help. * Support for IRCv3 capability [`account-notify`](http://ircv3.net/specs/extensions/account-notify-3.1.html) ### Changed * Casemapping changed from custom unicode mapping to preliminary [rfc7700](https://github.com/ircv3/ircv3-specifications/pull/272) mapping. ### Removed +* Removed channel persistence with the `+P` mode (not too useful as currently implemented, to be replaced later). ### Fixed diff --git a/README.md b/README.md index 303e0780..71dc2123 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,6 @@ This project adheres to [Semantic Versioning](http://semver.org/). For the purpo * IRC operators * ident lookups for usernames * passwords stored in [bcrypt][go-crypto] format -* channels that persist between restarts (+P) * client accounts and SASL * IRCv3 support diff --git a/irc/channel.go b/irc/channel.go index 08139ad3..ca9ef842 100644 --- a/irc/channel.go +++ b/irc/channel.go @@ -220,7 +220,7 @@ func (channel *Channel) Join(client *Client, key string) { client.channels.Add(channel) channel.members.Add(client) - if !channel.flags[Persistent] && (len(channel.members) == 1) { + if len(channel.members) == 1 { channel.createdTime = time.Now() channel.members[client][ChannelFounder] = true channel.members[client][ChannelOperator] = true @@ -284,8 +284,6 @@ func (channel *Channel) SetTopic(client *Client, topic string) { for member := range channel.members { member.Send(nil, client.nickMaskString, "TOPIC", channel.name, channel.topic) } - - channel.Persist() } func (channel *Channel) CanSpeak(client *Client) bool { @@ -424,34 +422,6 @@ func (channel *Channel) applyModeMask(client *Client, mode ChannelMode, op ModeO return false } -func (channel *Channel) Persist() (err error) { - return - - //TODO(dan): Fix persistence - /* - if channel.flags[Persistent] { - //TODO(dan): Save topicSetBy/topicSetTime and createdTime - _, err = channel.server.db.Exec(` - INSERT OR REPLACE INTO channel - (name, flags, key, topic, user_limit, ban_list, except_list, - invite_list) - VALUES (?, ?, ?, ?, ?, ?, ?, ?)`, - channel.name.String(), channel.flags.String(), channel.key, - channel.topic, channel.userLimit, channel.lists[BanMask].String(), - channel.lists[ExceptMask].String(), channel.lists[InviteMask].String()) - } else { - _, err = channel.server.db.Exec(` - DELETE FROM channel WHERE name = ?`, channel.name.String()) - } - - if err != nil { - Log.error.Println("Channel.Persist:", channel, err) - } - - return - */ -} - func (channel *Channel) Notice(client *Client, message string) { if !channel.CanSpeak(client) { client.Send(nil, client.server.name, ERR_CANNOTSENDTOCHAN, channel.name, "Cannot send to channel") @@ -469,7 +439,7 @@ func (channel *Channel) Quit(client *Client) { channel.members.Remove(client) client.channels.Remove(channel) - if !channel.flags[Persistent] && channel.IsEmpty() { + if channel.IsEmpty() { channel.server.channels.Remove(channel) } } @@ -511,7 +481,6 @@ func (channel *Channel) Invite(invitee *Client, inviter *Client) { if channel.flags[InviteOnly] { channel.lists[InviteMask].Add(invitee.UserHost()) - channel.Persist() } //TODO(dan): should inviter.server.name here be inviter.nickMaskString ? diff --git a/irc/modes.go b/irc/modes.go index 26af359e..012fae0c 100644 --- a/irc/modes.go +++ b/irc/modes.go @@ -170,7 +170,6 @@ const ( Moderated ChannelMode = 'm' // flag NoOutside ChannelMode = 'n' // flag OpOnlyTopic ChannelMode = 't' // flag - Persistent ChannelMode = 'P' // flag Secret ChannelMode = 's' // flag UserLimit ChannelMode = 'l' // flag arg ) @@ -178,7 +177,7 @@ const ( var ( SupportedChannelModes = ChannelModes{ BanMask, ExceptMask, InviteMask, InviteOnly, Key, NoOutside, - OpOnlyTopic, Persistent, Secret, UserLimit, + OpOnlyTopic, Secret, UserLimit, } // supportedChannelModesString acts as a cache for when we introduce users supportedChannelModesString = SupportedChannelModes.String() @@ -429,7 +428,7 @@ func cmodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { } applied = append(applied, change) - case InviteOnly, Moderated, NoOutside, OpOnlyTopic, Persistent, Secret: + case InviteOnly, Moderated, NoOutside, OpOnlyTopic, Secret: switch change.op { case Add: if channel.flags[change.mode] { diff --git a/irc/server.go b/irc/server.go index 20b06adf..dff57980 100644 --- a/irc/server.go +++ b/irc/server.go @@ -154,8 +154,6 @@ func NewServer(config *Config) *Server { server.password = config.Server.PasswordBytes() } - server.loadChannels() - for _, addr := range config.Server.Listen { server.listen(addr, config.TLSListeners()) } @@ -175,7 +173,7 @@ func NewServer(config *Config) *Server { server.isupport = NewISupportList() server.isupport.Add("AWAYLEN", strconv.Itoa(server.limits.AwayLen)) server.isupport.Add("CASEMAPPING", "rfc7700") - server.isupport.Add("CHANMODES", strings.Join([]string{ChannelModes{BanMask, ExceptMask, InviteMask}.String(), "", ChannelModes{UserLimit, Key}.String(), ChannelModes{InviteOnly, Moderated, NoOutside, OpOnlyTopic, Persistent, Secret}.String()}, ",")) + server.isupport.Add("CHANMODES", strings.Join([]string{ChannelModes{BanMask, ExceptMask, InviteMask}.String(), "", ChannelModes{UserLimit, Key}.String(), ChannelModes{InviteOnly, Moderated, NoOutside, OpOnlyTopic, Secret}.String()}, ",")) server.isupport.Add("CHANNELLEN", strconv.Itoa(config.Limits.ChannelLen)) server.isupport.Add("CHANTYPES", "#") server.isupport.Add("EXCEPTS", "") @@ -217,41 +215,6 @@ func loadChannelList(channel *Channel, list string, maskMode ChannelMode) { channel.lists[maskMode].AddAll(strings.Split(list, " ")) } -func (server *Server) loadChannels() { - //TODO(dan): Fix channel persistence - /* - rows, err := server.db.Query(` - SELECT name, flags, key, topic, user_limit, ban_list, except_list, - invite_list - FROM channel`) - if err != nil { - log.Fatal("error loading channels: ", err) - } - for rows.Next() { - var name, flags, key, topic string - var userLimit uint64 - var banList, exceptList, inviteList string - err = rows.Scan(&name, &flags, &key, &topic, &userLimit, &banList, - &exceptList, &inviteList) - if err != nil { - log.Println("Server.loadChannels:", err) - continue - } - - channel := NewChannel(server, NewName(name), false) - for _, flag := range flags { - channel.flags[ChannelMode(flag)] = true - } - channel.key = key - channel.topic = topic - channel.userLimit = userLimit - loadChannelList(channel, banList, BanMask) - loadChannelList(channel, exceptList, ExceptMask) - loadChannelList(channel, inviteList, InviteMask) - } - */ -} - func (server *Server) Shutdown() { //TODO(dan): Make sure we disallow new nicks for _, client := range server.clients.byNick {