mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 13:05:46 +00:00
1147c7fd4f
We also have to make a one-off change to /etc/wsl.conf to stop every invocation of wsl.exe clobbering the /etc/resolv.conf. This appears to be a safe change to make permanently, as even though the resolv.conf is constantly clobbered, it is always the same stable internal IP that is set as a nameserver. (I believe the resolv.conf clobbering predates the MS stub resolver.) Tested on WSL2, should work for WSL1 too. Fixes #775 Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
38 lines
879 B
Go
38 lines
879 B
Go
// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package dns
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestParseIni(t *testing.T) {
|
|
var tests = []struct {
|
|
src string
|
|
want map[string]map[string]string
|
|
}{
|
|
{
|
|
src: `# appended wsl.conf file
|
|
[automount]
|
|
enabled = true
|
|
root=/mnt/
|
|
# added by tailscale
|
|
[network] # trailing comment
|
|
generateResolvConf = false # trailing comment`,
|
|
want: map[string]map[string]string{
|
|
"automount": map[string]string{"enabled": "true", "root": "/mnt/"},
|
|
"network": map[string]string{"generateResolvConf": "false"},
|
|
},
|
|
},
|
|
}
|
|
for _, test := range tests {
|
|
got := parseIni(test.src)
|
|
if !reflect.DeepEqual(got, test.want) {
|
|
t.Errorf("for:\n%s\ngot: %v\nwant: %v", test.src, got, test.want)
|
|
}
|
|
}
|
|
}
|