TUN-3494: Proceed to create tunnel if at least one edge address can be resolved
This commit is contained in:
parent
e933ef9e1a
commit
18c359cb86
|
@ -121,15 +121,15 @@ func resolveSRVToTCP(srv *net.SRV) ([]*net.TCPAddr, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResolveAddrs resolves TCP address given a list of addresses. Address can be a hostname, however, it will return at most one
|
// ResolveAddrs resolves TCP address given a list of addresses. Address can be a hostname, however, it will return at most one
|
||||||
// of the hostname's IP addresses
|
// of the hostname's IP addresses.
|
||||||
func ResolveAddrs(addrs []string) ([]*net.TCPAddr, error) {
|
func ResolveAddrs(addrs []string, logger logger.Service) (resolved []*net.TCPAddr) {
|
||||||
var tcpAddrs []*net.TCPAddr
|
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
tcpAddr, err := net.ResolveTCPAddr("tcp", addr)
|
tcpAddr, err := net.ResolveTCPAddr("tcp", addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
logger.Errorf("Failed to resolve %s, err: %v", addr, err)
|
||||||
|
} else {
|
||||||
|
resolved = append(resolved, tcpAddr)
|
||||||
}
|
}
|
||||||
tcpAddrs = append(tcpAddrs, tcpAddr)
|
|
||||||
}
|
}
|
||||||
return tcpAddrs, nil
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,12 +35,12 @@ func ResolveEdge(logger logger.Service) (*Regions, error) {
|
||||||
|
|
||||||
// StaticEdge creates a list of edge addresses from the list of hostnames.
|
// StaticEdge creates a list of edge addresses from the list of hostnames.
|
||||||
// Mainly used for testing connectivity.
|
// Mainly used for testing connectivity.
|
||||||
func StaticEdge(hostnames []string) (*Regions, error) {
|
func StaticEdge(hostnames []string, logger logger.Service) (*Regions, error) {
|
||||||
addrs, err := ResolveAddrs(hostnames)
|
resolved := ResolveAddrs(hostnames, logger)
|
||||||
if err != nil {
|
if len(resolved) == 0 {
|
||||||
return nil, err
|
return nil, fmt.Errorf("failed to resolve any edge address")
|
||||||
}
|
}
|
||||||
return NewNoResolve(addrs), nil
|
return NewNoResolve(resolved), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewNoResolve doesn't resolve the edge. Instead it just uses the given addresses.
|
// NewNoResolve doesn't resolve the edge. Instead it just uses the given addresses.
|
||||||
|
|
|
@ -41,7 +41,7 @@ func ResolveEdge(l logger.Service) (*Edge, error) {
|
||||||
|
|
||||||
// StaticEdge creates a list of edge addresses from the list of hostnames. Mainly used for testing connectivity.
|
// StaticEdge creates a list of edge addresses from the list of hostnames. Mainly used for testing connectivity.
|
||||||
func StaticEdge(l logger.Service, hostnames []string) (*Edge, error) {
|
func StaticEdge(l logger.Service, hostnames []string) (*Edge, error) {
|
||||||
regions, err := allregions.StaticEdge(hostnames)
|
regions, err := allregions.StaticEdge(hostnames, l)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return new(Edge), err
|
return new(Edge), err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue