3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-10 22:19:31 +01:00

config: Allow enabling/disabling channel reg

This commit is contained in:
Daniel Oaks 2017-03-24 12:52:38 +10:00
parent ea748a9f7b
commit 70b7606996
5 changed files with 25 additions and 0 deletions

View File

@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). For the purpo
New release of Oragono! New release of Oragono!
### Config Changes ### Config Changes
* `channels` section added to control channel registration.
* `logging` key under `server` removed, replaced with `logging` section. * `logging` key under `server` removed, replaced with `logging` section.
* `registration` and `authentication-enabled` keys moved under `accounts` section. * `registration` and `authentication-enabled` keys moved under `accounts` section.
* `sts` section added under `server`. * `sts` section added under `server`.
@ -15,6 +16,7 @@ New release of Oragono!
### Security ### Security
### Added ### Added
* Added `ChanServ` service, to allow channel registration.
* Added `USERHOST` command (thanks @vegax87). * Added `USERHOST` command (thanks @vegax87).
* Added draft IRCv3 capability [draft/sts](http://ircv3.net/specs/core/sts-3.3.html). * Added draft IRCv3 capability [draft/sts](http://ircv3.net/specs/core/sts-3.3.html).

View File

@ -49,6 +49,11 @@ func (server *Server) chanservReceivePrivmsg(client *Client, message string) {
return return
} }
if !server.channelRegistrationEnabled {
client.ChanServNotice("Channel registration is not enabled")
return
}
server.registeredChannelsMutex.Lock() server.registeredChannelsMutex.Lock()
defer server.registeredChannelsMutex.Unlock() defer server.registeredChannelsMutex.Unlock()

View File

@ -72,6 +72,10 @@ type AccountRegistrationConfig struct {
} }
} }
type ChannelRegistrationConfig struct {
Enabled bool
}
type OperClassConfig struct { type OperClassConfig struct {
Title string Title string
WhoisLine string WhoisLine string
@ -188,6 +192,10 @@ type Config struct {
AuthenticationEnabled bool `yaml:"authentication-enabled"` AuthenticationEnabled bool `yaml:"authentication-enabled"`
} }
Channels struct {
Registration ChannelRegistrationConfig
}
OperClasses map[string]*OperClassConfig `yaml:"oper-classes"` OperClasses map[string]*OperClassConfig `yaml:"oper-classes"`
Opers map[string]*OperConfig Opers map[string]*OperConfig

View File

@ -84,6 +84,7 @@ type Server struct {
accountAuthenticationEnabled bool accountAuthenticationEnabled bool
accountRegistration *AccountRegistration accountRegistration *AccountRegistration
accounts map[string]*ClientAccount accounts map[string]*ClientAccount
channelRegistrationEnabled bool
channels ChannelNameMap channels ChannelNameMap
checkIdent bool checkIdent bool
clients *ClientLookupSet clients *ClientLookupSet
@ -190,6 +191,7 @@ func NewServer(configFilename string, config *Config, logger *logger.Manager) (*
server := &Server{ server := &Server{
accountAuthenticationEnabled: config.Accounts.AuthenticationEnabled, accountAuthenticationEnabled: config.Accounts.AuthenticationEnabled,
accounts: make(map[string]*ClientAccount), accounts: make(map[string]*ClientAccount),
channelRegistrationEnabled: config.Channels.Registration.Enabled,
channels: make(ChannelNameMap), channels: make(ChannelNameMap),
checkIdent: config.Server.CheckIdent, checkIdent: config.Server.CheckIdent,
clients: NewClientLookupSet(), clients: NewClientLookupSet(),
@ -1424,6 +1426,7 @@ func (server *Server) rehash() error {
// registration // registration
accountReg := NewAccountRegistration(config.Accounts.Registration) accountReg := NewAccountRegistration(config.Accounts.Registration)
server.accountRegistration = &accountReg server.accountRegistration = &accountReg
server.channelRegistrationEnabled = config.Channels.Registration.Enabled
// set new sendqueue size // set new sendqueue size
if config.Server.MaxSendQBytes != server.MaxSendQBytes { if config.Server.MaxSendQBytes != server.MaxSendQBytes {

View File

@ -135,6 +135,13 @@ accounts:
# is account authentication enabled? # is account authentication enabled?
authentication-enabled: true authentication-enabled: true
# channel options
channels:
# channel registration - requires an account
registration:
# can users register new channels?
enabled: true
# operator classes # operator classes
oper-classes: oper-classes:
# local operator # local operator