Remove Port from registry

This commit is contained in:
Asim Aslam
2019-07-08 08:01:42 +01:00
parent 5b7454e5a8
commit e0bf1c2283
35 changed files with 92 additions and 228 deletions

View File

@@ -3,7 +3,9 @@ package registry
import (
"context"
"fmt"
"net"
"strconv"
"strings"
"sync"
"time"
@@ -127,14 +129,22 @@ func (m *mdnsRegistry) Register(service *Service, opts ...RegisterOption) error
continue
}
//
host, pt, err := net.SplitHostPort(node.Address)
if err != nil {
gerr = err
continue
}
port, _ := strconv.Atoi(pt)
// we got here, new node
s, err := mdns.NewMDNSService(
node.Id,
service.Name,
"",
"",
node.Port,
[]net.IP{net.ParseIP(node.Address)},
port,
[]net.IP{net.ParseIP(host)},
txt,
)
if err != nil {
@@ -238,8 +248,7 @@ func (m *mdnsRegistry) GetService(service string) ([]*Service, error) {
s.Nodes = append(s.Nodes, &Node{
Id: strings.TrimSuffix(e.Name, "."+p.Service+"."+p.Domain+"."),
Address: e.AddrV4.String(),
Port: e.Port,
Address: fmt.Sprintf("%s:%d", e.AddrV4.String(), e.Port),
Metadata: txt.Metadata,
})