diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2022-05-01 17:13:09 +0200 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2022-05-01 17:13:30 +0200 |
commit | dc0a2e5516bce12f9dafd4c8f8ed82f6ec1ce837 (patch) | |
tree | 7c6412b6905c929de85dca914062c369c862d0b8 /config.go | |
parent | 08771a178415ede970eb9648bd85f528d373265d (diff) | |
parent | 34d33d51ac1f9bd6ea501aae90f8f134f4e03e84 (diff) |
Merge branch 'ev2-1-texturePools'
Diffstat (limited to 'config.go')
-rw-r--r-- | config.go | 36 |
1 files changed, 31 insertions, 5 deletions
@@ -24,10 +24,12 @@ var configMu sync.RWMutex var loadConfigOnce sync.Once type Server struct { - Name string - Addr string - Fallbacks []string - dynamic bool + Name string + Addr string + TexturePool string + Fallbacks []string + + dynamic bool } // A Config contains information from the configuration file @@ -89,6 +91,26 @@ func Conf() Config { return config } +// UniquePoolServers returns a []Server where each +// TexturePool is only represented once. +func UniquePoolServers() []Server { + var srvs []Server + conf := Conf() + +AppendLoop: + for _, srv := range conf.Servers { + for _, s := range srvs { + if srv.TexturePool == s.TexturePool { + continue AppendLoop + } + } + + srvs = append(srvs, srv) + } + + return srvs +} + // AddServer dynamically configures a new Server at runtime. // Servers added in this way are ephemeral and will be lost // when the proxy shuts down. @@ -227,13 +249,17 @@ DynLoop: } } - for _, srv := range config.Servers { + for i, srv := range config.Servers { for _, s := range config.Servers { if srv.Name == s.Name { config = oldConf return fmt.Errorf("duplicate server %s", s.Name) } } + + if srv.TexturePool == "" { + config.Servers[i].TexturePool = srv.Name + } } log.Print("load config") |