Commit ced25af5 authored by Roberto Bonafiglia's avatar Roberto Bonafiglia Committed by Roberto Bonafiglia

Fixed tailscale node IP dualstack mode in case of IPv4 only node

parent ba750e28
...@@ -408,20 +408,18 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N ...@@ -408,20 +408,18 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N
// Pass ipv4, ipv6 or both depending on nodeIPs mode // Pass ipv4, ipv6 or both depending on nodeIPs mode
var vpnIPs []net.IP var vpnIPs []net.IP
dualNode, err := utilsnet.IsDualStackIPs(nodeIPs) if utilsnet.IsIPv4(nodeIPs[0]) && vpnInfo.IPv4Address != nil {
if err != nil { vpnIPs = append(vpnIPs, vpnInfo.IPv4Address)
return nil, errors.Wrapf(err, "failed to validate node-ip: %v", nodeIPs) if vpnInfo.IPv6Address != nil {
}
if dualNode && vpnInfo.IPv4Address != nil && vpnInfo.IPv6Address != nil {
vpnIPs = append(vpnIPs, vpnInfo.IPv4Address, vpnInfo.IPv6Address)
} else {
if utilsnet.IsIPv4(nodeIPs[0]) && vpnInfo.IPv4Address != nil {
vpnIPs = append(vpnIPs, vpnInfo.IPv4Address)
} else if utilsnet.IsIPv6(nodeIPs[0]) && vpnInfo.IPv6Address != nil {
vpnIPs = append(vpnIPs, vpnInfo.IPv6Address) vpnIPs = append(vpnIPs, vpnInfo.IPv6Address)
} else {
return nil, errors.Errorf("address family mismatch when assigning VPN addresses to node: node=%v, VPN ipv4=%v ipv6=%v", nodeIPs, vpnInfo.IPv4Address, vpnInfo.IPv6Address)
} }
} else if utilsnet.IsIPv6(nodeIPs[0]) && vpnInfo.IPv6Address != nil {
vpnIPs = append(vpnIPs, vpnInfo.IPv6Address)
if vpnInfo.IPv4Address != nil {
vpnIPs = append(vpnIPs, vpnInfo.IPv4Address)
}
} else {
return nil, errors.Errorf("address family mismatch when assigning VPN addresses to node: node=%v, VPN ipv4=%v ipv6=%v", nodeIPs, vpnInfo.IPv4Address, vpnInfo.IPv6Address)
} }
// Overwrite nodeip and flannel interface and throw a warning if user explicitly set those parameters // Overwrite nodeip and flannel interface and throw a warning if user explicitly set those parameters
......
...@@ -248,14 +248,8 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont ...@@ -248,14 +248,8 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
return err return err
} }
logrus.Debugf("Processing vpn node-ip based on the detected nodeIPs: %v", nodeIPs)
dualNode, err := utilsnet.IsDualStackIPs(nodeIPs)
if err != nil {
return errors.Wrapf(err, "failed to validate node-ip: %v", nodeIPs)
}
// If we are in ipv6-only mode, we should pass the ipv6 address. Otherwise, ipv4 // If we are in ipv6-only mode, we should pass the ipv6 address. Otherwise, ipv4
if !dualNode && utilsnet.IsIPv6(nodeIPs[0]) { if utilsnet.IsIPv6(nodeIPs[0]) {
if vpnInfo.IPv6Address != nil { if vpnInfo.IPv6Address != nil {
logrus.Infof("Changed advertise-address to %v due to VPN", vpnInfo.IPv6Address) logrus.Infof("Changed advertise-address to %v due to VPN", vpnInfo.IPv6Address)
if serverConfig.ControlConfig.AdvertiseIP != "" { if serverConfig.ControlConfig.AdvertiseIP != "" {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment