mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 10:42:52 +01:00
clean up some old getters
This commit is contained in:
parent
05459012ef
commit
4b88a60ba6
@ -908,7 +908,7 @@ func (channel *Channel) SetTopic(client *Client, topic string, rb *ResponseBuffe
|
||||
return
|
||||
}
|
||||
|
||||
topicLimit := client.server.Limits().TopicLen
|
||||
topicLimit := client.server.Config().Limits.TopicLen
|
||||
if len(topic) > topicLimit {
|
||||
topic = topic[:topicLimit]
|
||||
}
|
||||
@ -1137,7 +1137,7 @@ func (channel *Channel) Kick(client *Client, target *Client, comment string, rb
|
||||
return
|
||||
}
|
||||
|
||||
kicklimit := client.server.Limits().KickLen
|
||||
kicklimit := client.server.Config().Limits.KickLen
|
||||
if len(comment) > kicklimit {
|
||||
comment = comment[:kicklimit]
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ func (cm *ChannelManager) Get(name string) (channel *Channel) {
|
||||
func (cm *ChannelManager) Join(client *Client, name string, key string, isSajoin bool, rb *ResponseBuffer) error {
|
||||
server := client.server
|
||||
casefoldedName, err := CasefoldChannel(name)
|
||||
if err != nil || len(casefoldedName) > server.Limits().ChannelLen {
|
||||
if err != nil || len(casefoldedName) > server.Config().Limits.ChannelLen {
|
||||
return errNoSuchChannel
|
||||
}
|
||||
|
||||
|
@ -336,7 +336,7 @@ func (client *Client) run(session *Session) {
|
||||
if r := recover(); r != nil {
|
||||
client.server.logger.Error("internal",
|
||||
fmt.Sprintf("Client caused panic: %v\n%s", r, debug.Stack()))
|
||||
if client.server.RecoverFromErrors() {
|
||||
if client.server.Config().Debug.recoverFromErrors {
|
||||
client.server.logger.Error("internal", "Disconnecting client and attempting to recover")
|
||||
} else {
|
||||
panic(r)
|
||||
|
@ -335,7 +335,8 @@ type Config struct {
|
||||
Logging []logger.LoggingConfig
|
||||
|
||||
Debug struct {
|
||||
RecoverFromErrors *bool `yaml:"recover-from-errors"`
|
||||
RecoverFromErrors *bool `yaml:"recover-from-errors"`
|
||||
recoverFromErrors bool
|
||||
PprofListener *string `yaml:"pprof-listener"`
|
||||
}
|
||||
|
||||
@ -669,9 +670,10 @@ func LoadConfig(filename string) (config *Config, err error) {
|
||||
}
|
||||
|
||||
// RecoverFromErrors defaults to true
|
||||
if config.Debug.RecoverFromErrors == nil {
|
||||
config.Debug.RecoverFromErrors = new(bool)
|
||||
*config.Debug.RecoverFromErrors = true
|
||||
if config.Debug.RecoverFromErrors != nil {
|
||||
config.Debug.recoverFromErrors = *config.Debug.RecoverFromErrors
|
||||
} else {
|
||||
config.Debug.recoverFromErrors = true
|
||||
}
|
||||
|
||||
// casefold/validate server name
|
||||
|
@ -21,22 +21,6 @@ func (server *Server) SetConfig(config *Config) {
|
||||
atomic.StorePointer(&server.config, unsafe.Pointer(config))
|
||||
}
|
||||
|
||||
func (server *Server) Limits() Limits {
|
||||
return server.Config().Limits
|
||||
}
|
||||
|
||||
func (server *Server) Password() []byte {
|
||||
return server.Config().Server.passwordBytes
|
||||
}
|
||||
|
||||
func (server *Server) RecoverFromErrors() bool {
|
||||
return *server.Config().Debug.RecoverFromErrors
|
||||
}
|
||||
|
||||
func (server *Server) DefaultChannelModes() modes.Modes {
|
||||
return server.Config().Channels.defaultModes
|
||||
}
|
||||
|
||||
func (server *Server) ChannelRegistrationEnabled() bool {
|
||||
return server.Config().Channels.Registration.Enabled
|
||||
}
|
||||
|
@ -475,7 +475,7 @@ func awayHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
|
||||
if len(msg.Params) > 0 {
|
||||
isAway = true
|
||||
awayMessage = msg.Params[0]
|
||||
awayLen := server.Limits().AwayLen
|
||||
awayLen := server.Config().Limits.AwayLen
|
||||
if len(awayMessage) > awayLen {
|
||||
awayMessage = awayMessage[:awayLen]
|
||||
}
|
||||
@ -1827,7 +1827,7 @@ func monitorAddHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb
|
||||
var online []string
|
||||
var offline []string
|
||||
|
||||
limits := server.Limits()
|
||||
limits := server.Config().Limits
|
||||
|
||||
targets := strings.Split(msg.Params[1], ",")
|
||||
for _, target := range targets {
|
||||
@ -2215,7 +2215,7 @@ func passHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
|
||||
}
|
||||
|
||||
// if no password exists, skip checking
|
||||
serverPassword := server.Password()
|
||||
serverPassword := server.Config().Server.passwordBytes
|
||||
if serverPassword == nil {
|
||||
return false
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ func (channel *Channel) ApplyChannelModeChanges(client *Client, isSamode bool, c
|
||||
|
||||
switch change.Op {
|
||||
case modes.Add:
|
||||
if channel.lists[change.Mode].Length() >= client.server.Limits().ChanListModes {
|
||||
if channel.lists[change.Mode].Length() >= client.server.Config().Limits.ChanListModes {
|
||||
if !listFullWarned[change.Mode] {
|
||||
rb.Add(nil, client.server.name, ERR_BANLISTFULL, client.Nick(), channel.Name(), change.Mode.String(), client.t("Channel list is full"))
|
||||
listFullWarned[change.Mode] = true
|
||||
|
@ -35,7 +35,7 @@ func performNickChange(server *Server, client *Client, target *Client, session *
|
||||
return false
|
||||
}
|
||||
|
||||
if err != nil || len(nickname) > server.Limits().NickLen || restrictedNicknames[cfnick] {
|
||||
if err != nil || len(nickname) > server.Config().Limits.NickLen || restrictedNicknames[cfnick] {
|
||||
rb.Add(nil, server.name, ERR_ERRONEUSNICKNAME, currentNick, nickname, client.t("Erroneous nickname"))
|
||||
return false
|
||||
}
|
||||
|
@ -550,7 +550,7 @@ func (server *Server) applyConfig(config *Config, initial bool) (err error) {
|
||||
server.nameCasefolded = config.Server.nameCasefolded
|
||||
} else {
|
||||
// enforce configs that can't be changed after launch:
|
||||
currentLimits := server.Limits()
|
||||
currentLimits := server.Config().Limits
|
||||
if currentLimits.LineLen.Rest != config.Limits.LineLen.Rest {
|
||||
return fmt.Errorf("Maximum line length (linelen) cannot be changed after launching the server, rehash aborted")
|
||||
} else if server.name != config.Server.Name {
|
||||
|
Loading…
Reference in New Issue
Block a user