chore: better bind in windows

This commit is contained in:
wwqgtxx
2023-02-13 10:14:59 +08:00
parent cc2a775271
commit ce8929d153
5 changed files with 107 additions and 13 deletions

View File

@ -6,7 +6,6 @@ import (
"fmt"
"net"
"net/netip"
"runtime"
"strings"
"sync"
@ -25,17 +24,6 @@ var (
ErrorDisableIPv6 = errors.New("IPv6 is disabled, dialer cancel")
)
func ParseNetwork(network string, addr netip.Addr) string {
if runtime.GOOS == "windows" { // fix bindIfaceToListenConfig() in windows force bind to an ipv4 address
if !strings.HasSuffix(network, "4") &&
!strings.HasSuffix(network, "6") &&
addr.Unmap().Is6() {
network += "6"
}
}
return network
}
func applyOptions(options ...Option) *option {
opt := &option{
interfaceName: DefaultInterface.Load(),