当请求本地回环地址时,不能指定出口IP地址

This commit is contained in:
赟翼 2020-08-31 13:57:23 +08:00
parent 737b77981a
commit 7f2d5907b0

View File

@ -372,6 +372,9 @@ func ResolverChainOption(resolver Resolver) ChainOption {
// BindChainOption specifies tcp bind address used by Chain.Dial.
func BindChainOption(bindAddr net.IP) ChainOption {
return func(opts *ChainOptions) {
if !bindAddr.IsLoopback(){
//只要非本地回环地址才能指定,否则会无法连接网络。当为空的时候,自动使用主网卡。
opts.BindAddr = bindAddr
}
}
}