- Removed servers.json and it's config code. - Load the new config.toml, using TOML instead of JSON. - Moved most of the cli flags to the config file. - Simplified creation of a new server instance (using New()). - Goroutine running updates was moved inside the lib.
37 lines
701 B
Go
37 lines
701 B
Go
package ss13
|
|
|
|
import "github.com/BurntSushi/toml"
|
|
|
|
type ServerConfig struct {
|
|
Title string
|
|
GameUrl string
|
|
SiteUrl string
|
|
}
|
|
|
|
type Config struct {
|
|
// Path to sqlite database file.
|
|
DatabasePath string
|
|
|
|
// Serve web pages on this address.
|
|
ListenAddr string
|
|
|
|
// List of "private" servers to manually poll for updates (private as
|
|
// in they do not show up on the byond hub page).
|
|
Servers []ServerConfig
|
|
|
|
// Update all servers every x minutes.
|
|
UpdateEvery int
|
|
|
|
// Timeout after x seconds, when trying to update a server.
|
|
UpdateTimeout int
|
|
}
|
|
|
|
func LoadConfig(path string) (*Config, error) {
|
|
c := Config{}
|
|
_, e := toml.DecodeFile(path, &c)
|
|
if e != nil {
|
|
return nil, e
|
|
}
|
|
return &c, nil
|
|
}
|