tstest/natlab/vnet: add start of IPv6 support
Updates #13038 Change-Id: Ic3d095f167daf6c7129463e881b18f2e0d5693f5 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
31b5239a2f
commit
b78df4d48a
+17
-4
@@ -28,6 +28,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"tailscale.com/atomicfile"
|
||||
"tailscale.com/client/tailscale"
|
||||
"tailscale.com/hostinfo"
|
||||
"tailscale.com/util/must"
|
||||
@@ -85,13 +86,25 @@ func main() {
|
||||
flag.Parse()
|
||||
|
||||
if distro.Get() == distro.Gokrazy {
|
||||
nsRx := regexp.MustCompile(`(?m)^nameserver (.*)`)
|
||||
for t := time.Now(); time.Since(t) < 10*time.Second; time.Sleep(10 * time.Millisecond) {
|
||||
all, _ := os.ReadFile("/etc/resolv.conf")
|
||||
if nsRx.Match(all) {
|
||||
cmdLine, _ := os.ReadFile("/proc/cmdline")
|
||||
explicitNS := false
|
||||
for _, s := range strings.Fields(string(cmdLine)) {
|
||||
if ns, ok := strings.CutPrefix(s, "tta.nameserver="); ok {
|
||||
err := atomicfile.WriteFile("/tmp/resolv.conf", []byte("nameserver "+ns+"\n"), 0644)
|
||||
log.Printf("Wrote /tmp/resolv.conf: %v", err)
|
||||
explicitNS = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !explicitNS {
|
||||
nsRx := regexp.MustCompile(`(?m)^nameserver (.*)`)
|
||||
for t := time.Now(); time.Since(t) < 10*time.Second; time.Sleep(10 * time.Millisecond) {
|
||||
all, _ := os.ReadFile("/etc/resolv.conf")
|
||||
if nsRx.Match(all) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("Tailscale Test Agent running.")
|
||||
|
||||
Reference in New Issue
Block a user