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