Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,9 @@ func handleGetConfig(path string) (*config.RawConfig, error) {
if err != nil {
return nil, err
}
if !prof.IPv6 {
prof.Tun.Inet6Address = nil
}
return prof, nil
}

Expand Down
22 changes: 22 additions & 0 deletions core/hub_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package main

import (
"os"
"path/filepath"
"testing"
)

func TestHandleGetConfigOmitsTunIPv6WhenIPv6IsDisabled(t *testing.T) {
path := filepath.Join(t.TempDir(), "config.yaml")
if err := os.WriteFile(path, []byte("ipv6: false\ntun:\n enable: true\n"), 0o600); err != nil {
t.Fatalf("write config: %v", err)
}

config, err := handleGetConfig(path)
if err != nil {
t.Fatalf("get config: %v", err)
}
if len(config.Tun.Inet6Address) != 0 {
t.Fatalf("tun inet6-address = %v, want no addresses when IPv6 is disabled", config.Tun.Inet6Address)
}
}