mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-12 23:14:36 +01:00
add ClientMode config option
This commit is contained in:
@@ -1,15 +1,28 @@
|
||||
package config
|
||||
package _config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
type Mode string
|
||||
|
||||
const (
|
||||
ZZ Mode = "ZZ"
|
||||
Z2 Mode = "Z2"
|
||||
Z1 Mode = "Z1"
|
||||
)
|
||||
|
||||
func (m Mode) String() string {
|
||||
return string(m)
|
||||
}
|
||||
|
||||
// Config holds the global server-wide config.
|
||||
type Config struct {
|
||||
Host string `mapstructure:"Host"`
|
||||
@@ -22,6 +35,7 @@ type Config struct {
|
||||
PatchServerFile string // File patch server override
|
||||
ScreenshotAPIURL string // Destination for screenshots uploaded to BBS
|
||||
DeleteOnSaveCorruption bool // Attempts to save corrupted data will flag the save for deletion
|
||||
ClientMode Mode
|
||||
DevMode bool
|
||||
|
||||
DevModeOptions DevModeOptions
|
||||
@@ -170,7 +184,6 @@ func init() {
|
||||
if err != nil {
|
||||
preventClose(fmt.Sprintf("Failed to load config: %s", err.Error()))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// getOutboundIP4 gets the preferred outbound ip4 of this machine
|
||||
@@ -212,6 +225,15 @@ func LoadConfig() (*Config, error) {
|
||||
c.Host = getOutboundIP4().To4().String()
|
||||
}
|
||||
|
||||
switch strings.ToUpper(c.ClientMode.String()) {
|
||||
case "Z1":
|
||||
c.ClientMode = Z1
|
||||
case "Z2":
|
||||
c.ClientMode = Z2
|
||||
default:
|
||||
c.ClientMode = ZZ
|
||||
}
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user