73 lines
1.2 KiB
Go
73 lines
1.2 KiB
Go
package config
|
|
|
|
import "maps"
|
|
|
|
type serverConfig struct {
|
|
Name string `json:"name" yaml:"name"`
|
|
Port int `json:"port" yaml:"port"`
|
|
SSUType map[string]uint8 `json:"ssutype" yaml:"ssutype"`
|
|
}
|
|
|
|
func NewServerConfig() *serverConfig {
|
|
return new(serverConfig)
|
|
}
|
|
|
|
func (conf *serverConfig) GetName() string {
|
|
if conf == nil {
|
|
panic("server config is nil")
|
|
}
|
|
|
|
return conf.Name
|
|
}
|
|
|
|
func (conf *serverConfig) SetName(name string) *serverConfig {
|
|
if conf == nil {
|
|
panic("server config is nil")
|
|
}
|
|
conf.Name = name
|
|
|
|
return conf
|
|
}
|
|
|
|
func (conf *serverConfig) GetPort() int {
|
|
if conf == nil {
|
|
panic("server config is nil")
|
|
}
|
|
|
|
return conf.Port
|
|
}
|
|
|
|
func (conf *serverConfig) SetPort(port int) *serverConfig {
|
|
if conf == nil {
|
|
panic("server config is nil")
|
|
}
|
|
conf.Port = port
|
|
|
|
return conf
|
|
}
|
|
|
|
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) *serverConfig {
|
|
if conf == nil {
|
|
panic("server config is nil")
|
|
}
|
|
if conf.SSUType == nil {
|
|
conf.SSUType = ssuType
|
|
} else {
|
|
maps.Copy(conf.SSUType, ssuType)
|
|
}
|
|
|
|
return conf
|
|
}
|
|
|
|
func serverConfigName() string {
|
|
return "server.json"
|
|
}
|