diff options
Diffstat (limited to 'internal/config/config.go')
| -rw-r--r-- | internal/config/config.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index b5030ee..f04aa57 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -19,6 +19,10 @@ type Node struct { originalId string } +func (n Node) Address() string { + return fmt.Sprintf("%s:%d", n.Hostname, n.Port) +} + type Config struct { StateDir string ScoreFile string @@ -57,6 +61,10 @@ func NewFromConfigFile(configFile string) (Config, error) { for id, node := range conf.Nodes { log.Printf("adding node %s: %v", id, node) node.originalId = id + if node.Alias != "" { + newNodes[node.Alias] = node + continue + } newNodes[node.Hostname] = node } conf.Nodes = newNodes @@ -181,5 +189,5 @@ func (conf Config) findNode(hostname string) (Node, error) { } } - return Node{}, fmt.Errorf("node %s not found", hostname) + return Node{}, fmt.Errorf("node %s not found in %v", hostname, conf.Nodes) } |
