add V6Only (#1677)

* add `V6Only`

* add `V6Only`
This commit is contained in:
xqzr 2023-02-25 00:54:40 +08:00 committed by GitHub
parent 03b8c094de
commit c8b4580869
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 23 deletions

View file

@ -155,6 +155,12 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig)
}
}
if config.V6Only {
if err := syscall.SetsockoptInt(int(fd), syscall.SOL_IPV6, syscall.IPV6_V6ONLY, 1); err != nil {
return newError("failed to set IPV6_V6ONLY", err)
}
}
return nil
}