dataRT/config/server.go

64 lines
1.2 KiB
Go

package config
import "maps"
type serverConfig struct {
Host string `json:"host" yaml:"host"`
Port int `json:"port" yaml:"port"`
SSUType map[string]uint8 `json:"ssutype" yaml:"ssutype"`
}
func NewServerConfig() *serverConfig {
return new(serverConfig)
}
func (conf *serverConfig) GetHost() string {
if conf == nil {
panic("server config is nil")
}
return conf.Host
}
func (conf *serverConfig) SetHost(host string) {
if conf == nil {
panic("server config is nil")
}
conf.Host = host
}
func (conf *serverConfig) GetPort() int {
if conf == nil {
panic("server config is nil")
}
return conf.Port
}
func (conf *serverConfig) SetPort(port int) {
if conf == nil {
panic("server config is nil")
}
conf.Port = port
}
func (conf *serverConfig) GetSSUType() map[string]uint8 {
if conf == nil {
panic("server config is nil")
}
return conf.SSUType
}
func (conf *serverConfig) SetSSUType(ssuType map[string]uint8) {
if conf == nil {
panic("server config is nil")
}
if conf.SSUType == nil {
conf.SSUType = ssuType
} else {
maps.Copy(conf.SSUType, ssuType)
}
}
func serverConfigName() string {
return "server.json"
}