|
|
@ -9,6 +9,7 @@ import (
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"net/netip"
|
|
|
|
"path/filepath"
|
|
|
|
"path/filepath"
|
|
|
|
"reflect"
|
|
|
|
"reflect"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
@ -17,7 +18,6 @@ import (
|
|
|
|
"github.com/tailscale/tailscale-android/jni"
|
|
|
|
"github.com/tailscale/tailscale-android/jni"
|
|
|
|
"golang.org/x/sys/unix"
|
|
|
|
"golang.org/x/sys/unix"
|
|
|
|
"golang.zx2c4.com/wireguard/tun"
|
|
|
|
"golang.zx2c4.com/wireguard/tun"
|
|
|
|
"inet.af/netaddr"
|
|
|
|
|
|
|
|
"tailscale.com/ipn"
|
|
|
|
"tailscale.com/ipn"
|
|
|
|
"tailscale.com/ipn/ipnlocal"
|
|
|
|
"tailscale.com/ipn/ipnlocal"
|
|
|
|
"tailscale.com/logpolicy"
|
|
|
|
"tailscale.com/logpolicy"
|
|
|
@ -68,8 +68,8 @@ const (
|
|
|
|
// googleDnsServers are used on ChromeOS, where an empty VpnBuilder DNS setting results
|
|
|
|
// googleDnsServers are used on ChromeOS, where an empty VpnBuilder DNS setting results
|
|
|
|
// in erasing the platform DNS servers. The developer docs say this is not supposed to happen,
|
|
|
|
// in erasing the platform DNS servers. The developer docs say this is not supposed to happen,
|
|
|
|
// but nonetheless it does.
|
|
|
|
// but nonetheless it does.
|
|
|
|
var googleDnsServers = []netaddr.IP{netaddr.MustParseIP("8.8.8.8"), netaddr.MustParseIP("8.8.4.4"),
|
|
|
|
var googleDnsServers = []netip.Addr{netip.MustParseAddr("8.8.8.8"), netip.MustParseAddr("8.8.4.4"),
|
|
|
|
netaddr.MustParseIP("2001:4860:4860::8888"), netaddr.MustParseIP("2001:4860:4860::8844"),
|
|
|
|
netip.MustParseAddr("2001:4860:4860::8888"), netip.MustParseAddr("2001:4860:4860::8844"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// errVPNNotPrepared is used when VPNService.Builder.establish returns
|
|
|
|
// errVPNNotPrepared is used when VPNService.Builder.establish returns
|
|
|
@ -236,7 +236,7 @@ func (b *backend) updateTUN(service jni.Object, rcfg *router.Config, dcfg *dns.O
|
|
|
|
_, err = jni.CallObjectMethod(env,
|
|
|
|
_, err = jni.CallObjectMethod(env,
|
|
|
|
builder,
|
|
|
|
builder,
|
|
|
|
addRoute,
|
|
|
|
addRoute,
|
|
|
|
jni.Value(jni.JavaString(env, route.IP().String())),
|
|
|
|
jni.Value(jni.JavaString(env, route.Addr().String())),
|
|
|
|
jni.Value(route.Bits()),
|
|
|
|
jni.Value(route.Bits()),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
@ -250,7 +250,7 @@ func (b *backend) updateTUN(service jni.Object, rcfg *router.Config, dcfg *dns.O
|
|
|
|
_, err = jni.CallObjectMethod(env,
|
|
|
|
_, err = jni.CallObjectMethod(env,
|
|
|
|
builder,
|
|
|
|
builder,
|
|
|
|
addAddress,
|
|
|
|
addAddress,
|
|
|
|
jni.Value(jni.JavaString(env, addr.IP().String())),
|
|
|
|
jni.Value(jni.JavaString(env, addr.Addr().String())),
|
|
|
|
jni.Value(addr.Bits()),
|
|
|
|
jni.Value(addr.Bits()),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
@ -424,7 +424,7 @@ func (b *backend) getDNSBaseConfig() (dns.OSConfig, error) {
|
|
|
|
config := dns.OSConfig{}
|
|
|
|
config := dns.OSConfig{}
|
|
|
|
addrs := strings.Trim(lines[0], " \n")
|
|
|
|
addrs := strings.Trim(lines[0], " \n")
|
|
|
|
for _, addr := range strings.Split(addrs, " ") {
|
|
|
|
for _, addr := range strings.Split(addrs, " ") {
|
|
|
|
ip, err := netaddr.ParseIP(addr)
|
|
|
|
ip, err := netip.ParseAddr(addr)
|
|
|
|
if err == nil {
|
|
|
|
if err == nil {
|
|
|
|
config.Nameservers = append(config.Nameservers, ip)
|
|
|
|
config.Nameservers = append(config.Nameservers, ip)
|
|
|
|
}
|
|
|
|
}
|
|
|
|