mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-26 12:42:50 +01:00
server: Add configurable NICKLEN and CHANNELLEN
This commit is contained in:
parent
d810033a02
commit
a5911ad14c
@ -66,6 +66,11 @@ type Config struct {
|
||||
Operator map[string]*PassConfig
|
||||
|
||||
Theater map[string]*PassConfig
|
||||
|
||||
Limits struct {
|
||||
NickLen int `yaml:"nicklen"`
|
||||
ChannelLen int `yaml:"channellen"`
|
||||
}
|
||||
}
|
||||
|
||||
func (conf *Config) Operators() map[Name][]byte {
|
||||
@ -131,5 +136,8 @@ func LoadConfig(filename string) (config *Config, err error) {
|
||||
if len(config.Server.Listen) == 0 {
|
||||
return nil, errors.New("Server listening addresses missing")
|
||||
}
|
||||
if config.Limits.NickLen < 1 || config.Limits.ChannelLen < 2 {
|
||||
return nil, errors.New("Limits aren't setup properly, check them and make them sane")
|
||||
}
|
||||
return config, nil
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
@ -94,6 +95,10 @@ func NewServer(config *Config) *Server {
|
||||
}
|
||||
}
|
||||
|
||||
//TODO(dan): Hot damn this is an ugly hack. Fix it properly at some point.
|
||||
ChannelNameExpr = regexp.MustCompile(fmt.Sprintf(`^[&!#+][\pL\pN]{1,%d}$`, config.Limits.ChannelLen))
|
||||
NicknameExpr = regexp.MustCompile(fmt.Sprintf("^[\\pL\\pN\\pP\\pS]{1,%d}$", config.Limits.NickLen))
|
||||
|
||||
if config.Server.Password != "" {
|
||||
server.password = config.Server.PasswordBytes()
|
||||
}
|
||||
@ -114,7 +119,7 @@ func NewServer(config *Config) *Server {
|
||||
server.isupport = NewISupportList()
|
||||
server.isupport.Add("CASEMAPPING", "ascii")
|
||||
// server.isupport.Add("CHANMODES", "") //TODO(dan): Channel mode list here
|
||||
// server.isupport.Add("CHANNELLEN", "") //TODO(dan): Support channel length
|
||||
server.isupport.Add("CHANNELLEN", strconv.Itoa(config.Limits.ChannelLen))
|
||||
server.isupport.Add("CHANTYPES", "#")
|
||||
server.isupport.Add("EXCEPTS", "")
|
||||
server.isupport.Add("INVEX", "")
|
||||
@ -122,7 +127,7 @@ func NewServer(config *Config) *Server {
|
||||
// server.isupport.Add("MAXLIST", "") //TODO(dan): Support max list length?
|
||||
// server.isupport.Add("MODES", "") //TODO(dan): Support max modes?
|
||||
server.isupport.Add("NETWORK", config.Network.Name)
|
||||
// server.isupport.Add("NICKLEN", "") //TODO(dan): Support nick length
|
||||
server.isupport.Add("NICKLEN", strconv.Itoa(config.Limits.NickLen))
|
||||
server.isupport.Add("PREFIX", "(qaohv)~&@%+")
|
||||
// server.isupport.Add("STATUSMSG", "@+") //TODO(dan): Autogenerate based on PREFIXes, support STATUSMSG
|
||||
// server.isupport.Add("TARGMAX", "") //TODO(dan): Support this
|
||||
|
@ -14,8 +14,10 @@ import (
|
||||
|
||||
var (
|
||||
// regexps
|
||||
ChannelNameExpr = regexp.MustCompile(`^[&!#+][\pL\pN]{1,63}$`)
|
||||
NicknameExpr = regexp.MustCompile("^[\\pL\\pN\\pP\\pS]{1,32}$")
|
||||
// these get replaced with real regexes at server load time
|
||||
|
||||
ChannelNameExpr = regexp.MustCompile("^$")
|
||||
NicknameExpr = regexp.MustCompile("^$")
|
||||
)
|
||||
|
||||
// Names are normalized and canonicalized to remove formatting marks
|
||||
|
@ -56,3 +56,11 @@ operator:
|
||||
# password to login with /OPER command
|
||||
# generated using "oragono genpasswd"
|
||||
password: JDJhJDA0JE1vZmwxZC9YTXBhZ3RWT2xBbkNwZnV3R2N6VFUwQUI0RUJRVXRBRHliZVVoa0VYMnlIaGsu
|
||||
|
||||
# limits - these need to be the same across the network
|
||||
limits:
|
||||
# nicklen is the max nick length allowed
|
||||
nicklen: 32
|
||||
|
||||
# channellen is the max channel length allowed
|
||||
channellen: 64
|
||||
|
Loading…
Reference in New Issue
Block a user