util/winutil: consolidate interface specific registry keys

Code movement to allow reuse in a follow up PR.

Updates #1659

Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
Maisem Ali
2022-08-12 14:55:01 -07:00
committed by Maisem Ali
parent 23f37b05a3
commit 545639ee44
4 changed files with 116 additions and 109 deletions

View File

@@ -339,11 +339,12 @@ func deleteFakeGPKey(t *testing.T) {
}
func createFakeInterfaceKey(t *testing.T, guid windows.GUID) (func(), error) {
basePaths := []string{ipv4RegBase, ipv6RegBase}
basePaths := []winutil.RegistryPathPrefix{winutil.IPv4TCPIPInterfacePrefix, winutil.IPv6TCPIPInterfacePrefix}
keyPaths := make([]string, 0, len(basePaths))
guidStr := guid.String()
for _, basePath := range basePaths {
keyPath := fmt.Sprintf(`%s\Interfaces\%s`, basePath, guid)
keyPath := string(basePath.WithSuffix(guidStr))
key, _, err := registry.CreateKey(registry.LOCAL_MACHINE, keyPath, registry.SET_VALUE)
if err != nil {
return nil, err