wgengine: fix build on linux/freebsd/openbsd/windows

Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
pull/78/head
David Crawshaw 5 years ago
parent 431929c09a
commit 45d687e213

@ -237,7 +237,7 @@ func setFirewall(ifcGUID *windows.GUID) (bool, error) {
return false, nil return false, nil
} }
func ConfigureInterface(m *wgcfg.Config, tun *tun.NativeTun, dns []net.IP, dnsDomains []string) error { func ConfigureInterface(m *wgcfg.Config, tun *tun.NativeTun, dns []wgcfg.IP, dnsDomains []string) error {
const mtu = 0 const mtu = 0
guid := tun.GUID() guid := tun.GUID()
log.Printf("wintun GUID is %v\n", guid) log.Printf("wintun GUID is %v\n", guid)
@ -268,8 +268,8 @@ func ConfigureInterface(m *wgcfg.Config, tun *tun.NativeTun, dns []net.IP, dnsDo
routes := []winipcfg.RouteData{} routes := []winipcfg.RouteData{}
var firstGateway4 *net.IP var firstGateway4 *net.IP
var firstGateway6 *net.IP var firstGateway6 *net.IP
addresses := make([]*net.IPNet, len(m.Interface.Addresses)) addresses := make([]*net.IPNet, len(m.Addresses))
for i, addr := range m.Interface.Addresses { for i, addr := range m.Addresses {
ipnet := addr.IPNet() ipnet := addr.IPNet()
addresses[i] = ipnet addresses[i] = ipnet
gateway := ipnet.IP gateway := ipnet.IP
@ -361,7 +361,11 @@ func ConfigureInterface(m *wgcfg.Config, tun *tun.NativeTun, dns []net.IP, dnsDo
errAcc = err errAcc = err
} }
err = iface.SetDNS(dns) var dnsIPs []net.IP
for _, ip := range dns {
dnsIPs = append(dnsIPs, ip.IP())
}
err = iface.SetDNS(dnsIPs)
if err != nil && errAcc == nil { if err != nil && errAcc == nil {
log.Printf("setdns: %v\n", err) log.Printf("setdns: %v\n", err)
errAcc = err errAcc = err

@ -7,7 +7,6 @@ package wgengine
import ( import (
"fmt" "fmt"
"log" "log"
"net"
"os/exec" "os/exec"
"github.com/tailscale/wireguard-go/device" "github.com/tailscale/wireguard-go/device"
@ -154,5 +153,5 @@ func (r *freebsdRouter) Close() error {
// TODO(mbaillie): these are no-ops for now. They could re-use the Linux funcs // TODO(mbaillie): these are no-ops for now. They could re-use the Linux funcs
// (sans systemd parts), but I note Linux DNS is disabled(?) so leaving for now. // (sans systemd parts), but I note Linux DNS is disabled(?) so leaving for now.
func (r *freebsdRouter) replaceResolvConf(_ []net.IP, _ []string) error { return nil } func (r *freebsdRouter) replaceResolvConf(_ []wgcfg.IP, _ []string) error { return nil }
func (r *freebsdRouter) restoreResolvConf() error { return nil } func (r *freebsdRouter) restoreResolvConf() error { return nil }

@ -9,7 +9,6 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"log" "log"
"net"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
@ -177,7 +176,7 @@ const (
resolvConf = "/etc/resolv.conf" resolvConf = "/etc/resolv.conf"
) )
func (r *linuxRouter) replaceResolvConf(servers []net.IP, domains []string) error { func (r *linuxRouter) replaceResolvConf(servers []wgcfg.IP, domains []string) error {
if len(servers) == 0 { if len(servers) == 0 {
return r.restoreResolvConf() return r.restoreResolvConf()
} }

@ -7,7 +7,6 @@ package wgengine
import ( import (
"fmt" "fmt"
"log" "log"
"net"
"os/exec" "os/exec"
"github.com/tailscale/wireguard-go/device" "github.com/tailscale/wireguard-go/device"
@ -175,5 +174,5 @@ func (r *openbsdRouter) Close() error {
// TODO(mbaillie): these are no-ops for now. They could re-use the Linux funcs // TODO(mbaillie): these are no-ops for now. They could re-use the Linux funcs
// (sans systemd parts), but I note Linux DNS is disabled(?) so leaving for now. // (sans systemd parts), but I note Linux DNS is disabled(?) so leaving for now.
func (r *openbsdRouter) replaceResolvConf(_ []net.IP, _ []string) error { return nil } func (r *openbsdRouter) replaceResolvConf(_ []wgcfg.IP, _ []string) error { return nil }
func (r *openbsdRouter) restoreResolvConf() error { return nil } func (r *openbsdRouter) restoreResolvConf() error { return nil }

Loading…
Cancel
Save