aboutsummaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'config.go')
-rw-r--r--config.go33
1 files changed, 30 insertions, 3 deletions
diff --git a/config.go b/config.go
index 3b4a6ba..25319ad 100644
--- a/config.go
+++ b/config.go
@@ -23,9 +23,10 @@ var configMu sync.RWMutex
var loadConfigOnce sync.Once
type Server struct {
- Name string
- Addr string
- Fallbacks []string
+ Name string
+ Addr string
+ TexturePool string
+ Fallbacks []string
}
// A Config contains information from the configuration file
@@ -87,6 +88,32 @@ func Conf() Config {
return config
}
+// UniquePoolServers returns a []server where each Pool is only
+// represented once
+func UniquePoolServers() []Server {
+ var srvs []Server
+ conf := Conf()
+
+ for _, srv := range conf.Servers {
+ if len(srv.TexturePool) == 0 {
+ srv.TexturePool = srv.Name
+ }
+ }
+
+AddLoop:
+ for _, srv := range conf.Servers {
+ for _, srv2 := range srvs {
+ if srv.TexturePool == srv2.TexturePool {
+ continue AddLoop
+ }
+ }
+
+ srvs = append(srvs, srv)
+ }
+
+ return srvs
+}
+
// AddServer appends a server to the list of configured servers.
func AddServer(server Server) bool {
configMu.Lock()