Update nebula control for netip
This commit is contained in:
parent
2d74360bc2
commit
be7fe4f88d
|
@ -4,7 +4,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net/netip"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
|
@ -12,9 +12,7 @@ import (
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/slackhq/nebula"
|
"github.com/slackhq/nebula"
|
||||||
nc "github.com/slackhq/nebula/config"
|
nc "github.com/slackhq/nebula/config"
|
||||||
"github.com/slackhq/nebula/iputil"
|
|
||||||
"github.com/slackhq/nebula/overlay"
|
"github.com/slackhq/nebula/overlay"
|
||||||
"github.com/slackhq/nebula/udp"
|
|
||||||
"github.com/slackhq/nebula/util"
|
"github.com/slackhq/nebula/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -108,8 +106,8 @@ func (n *Nebula) ListHostmap(pending bool) (string, error) {
|
||||||
return string(b), nil
|
return string(b), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Nebula) GetHostInfoByVpnIp(vpnIp string, pending bool) (string, error) {
|
func (n *Nebula) GetHostInfoByVpnIp(vpnIp netip.Addr, pending bool) (string, error) {
|
||||||
b, err := json.Marshal(n.c.GetHostInfoByVpnIp(stringIpToInt(vpnIp), pending))
|
b, err := json.Marshal(n.c.GetHostInfoByVpnIp(vpnIp, pending))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -117,17 +115,17 @@ func (n *Nebula) GetHostInfoByVpnIp(vpnIp string, pending bool) (string, error)
|
||||||
return string(b), nil
|
return string(b), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Nebula) CloseTunnel(vpnIp string) bool {
|
func (n *Nebula) CloseTunnel(vpnIp netip.Addr) bool {
|
||||||
return n.c.CloseTunnel(stringIpToInt(vpnIp), false)
|
return n.c.CloseTunnel(vpnIp, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Nebula) SetRemoteForTunnel(vpnIp string, addr string) (string, error) {
|
func (n *Nebula) SetRemoteForTunnel(vpnIp netip.Addr, addr string) (string, error) {
|
||||||
udpAddr := udp.NewAddrFromString(addr)
|
udpAddr, err := netip.ParseAddrPort(addr)
|
||||||
if udpAddr == nil {
|
if err != nil {
|
||||||
return "", errors.New("could not parse udp address")
|
return "", errors.New("could not parse udp address")
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := json.Marshal(n.c.SetRemoteForTunnel(stringIpToInt(vpnIp), *udpAddr))
|
b, err := json.Marshal(n.c.SetRemoteForTunnel(vpnIp, udpAddr))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -140,7 +138,3 @@ func (n *Nebula) Sleep() {
|
||||||
n.l.WithField("tunnels", closed).Info("Sleep called, closed non lighthouse tunnels")
|
n.l.WithField("tunnels", closed).Info("Sleep called, closed non lighthouse tunnels")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func stringIpToInt(ip string) iputil.VpnIp {
|
|
||||||
return iputil.Ip2VpnIp(net.ParseIP(ip))
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue