From 228ee7ca894e98adb40e7384730d0e4d0d88a6a6 Mon Sep 17 00:00:00 2001 From: Tom Mychost Date: Mon, 1 Apr 2024 18:40:43 +0100 Subject: [PATCH] Add support for setting IPv6 address on macOS --- pkg/vpn/interface_darwin.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/vpn/interface_darwin.go b/pkg/vpn/interface_darwin.go index 8038c737..fcb0383b 100644 --- a/pkg/vpn/interface_darwin.go +++ b/pkg/vpn/interface_darwin.go @@ -54,7 +54,13 @@ func prepareInterface(c *Config) error { // Add the address to the interface. This is not directly possible with the `net` package, // so we use the `ifconfig` command. - cmd = exec.Command("ifconfig", iface.Name, "inet", ip.String(), ip.String()) + if ip.To4() == nil { + // IPV6 + cmd = exec.Command("ifconfig", iface.Name, "inet6", ip.String()) + } else { + // IPv4 + cmd = exec.Command("ifconfig", iface.Name, "inet", ip.String(), ip.String()) + } err = cmd.Run() if err != nil { return err