From 70b7606996d5247d5ba00faa12db0be3740ee0ae Mon Sep 17 00:00:00 2001 From: Daniel Oaks Date: Fri, 24 Mar 2017 12:52:38 +1000 Subject: [PATCH] config: Allow enabling/disabling channel reg --- CHANGELOG.md | 2 ++ irc/chanserv.go | 5 +++++ irc/config.go | 8 ++++++++ irc/server.go | 3 +++ oragono.yaml | 7 +++++++ 5 files changed, 25 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17d97523..eb4259ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). For the purpo New release of Oragono! ### Config Changes +* `channels` section added to control channel registration. * `logging` key under `server` removed, replaced with `logging` section. * `registration` and `authentication-enabled` keys moved under `accounts` section. * `sts` section added under `server`. @@ -15,6 +16,7 @@ New release of Oragono! ### Security ### Added +* Added `ChanServ` service, to allow channel registration. * Added `USERHOST` command (thanks @vegax87). * Added draft IRCv3 capability [draft/sts](http://ircv3.net/specs/core/sts-3.3.html). diff --git a/irc/chanserv.go b/irc/chanserv.go index 86885a20..9153cde5 100644 --- a/irc/chanserv.go +++ b/irc/chanserv.go @@ -49,6 +49,11 @@ func (server *Server) chanservReceivePrivmsg(client *Client, message string) { return } + if !server.channelRegistrationEnabled { + client.ChanServNotice("Channel registration is not enabled") + return + } + server.registeredChannelsMutex.Lock() defer server.registeredChannelsMutex.Unlock() diff --git a/irc/config.go b/irc/config.go index ac66cb7f..a095ff9c 100644 --- a/irc/config.go +++ b/irc/config.go @@ -72,6 +72,10 @@ type AccountRegistrationConfig struct { } } +type ChannelRegistrationConfig struct { + Enabled bool +} + type OperClassConfig struct { Title string WhoisLine string @@ -188,6 +192,10 @@ type Config struct { AuthenticationEnabled bool `yaml:"authentication-enabled"` } + Channels struct { + Registration ChannelRegistrationConfig + } + OperClasses map[string]*OperClassConfig `yaml:"oper-classes"` Opers map[string]*OperConfig diff --git a/irc/server.go b/irc/server.go index 1ca7b8a6..12ca5425 100644 --- a/irc/server.go +++ b/irc/server.go @@ -84,6 +84,7 @@ type Server struct { accountAuthenticationEnabled bool accountRegistration *AccountRegistration accounts map[string]*ClientAccount + channelRegistrationEnabled bool channels ChannelNameMap checkIdent bool clients *ClientLookupSet @@ -190,6 +191,7 @@ func NewServer(configFilename string, config *Config, logger *logger.Manager) (* server := &Server{ accountAuthenticationEnabled: config.Accounts.AuthenticationEnabled, accounts: make(map[string]*ClientAccount), + channelRegistrationEnabled: config.Channels.Registration.Enabled, channels: make(ChannelNameMap), checkIdent: config.Server.CheckIdent, clients: NewClientLookupSet(), @@ -1424,6 +1426,7 @@ func (server *Server) rehash() error { // registration accountReg := NewAccountRegistration(config.Accounts.Registration) server.accountRegistration = &accountReg + server.channelRegistrationEnabled = config.Channels.Registration.Enabled // set new sendqueue size if config.Server.MaxSendQBytes != server.MaxSendQBytes { diff --git a/oragono.yaml b/oragono.yaml index f176d1e0..b3a760bf 100644 --- a/oragono.yaml +++ b/oragono.yaml @@ -135,6 +135,13 @@ accounts: # is account authentication enabled? authentication-enabled: true +# channel options +channels: + # channel registration - requires an account + registration: + # can users register new channels? + enabled: true + # operator classes oper-classes: # local operator