代码拉取完成,页面将自动刷新
package transport
import (
"fmt"
"net"
"strings"
"time"
"github.com/elastic/beats/libbeat/logp"
"github.com/elastic/beats/libbeat/testing"
)
func NetDialer(timeout time.Duration) Dialer {
return TestNetDialer(testing.NullDriver, timeout)
}
func TestNetDialer(d testing.Driver, timeout time.Duration) Dialer {
return DialerFunc(func(network, address string) (net.Conn, error) {
switch network {
case "tcp", "tcp4", "tcp6", "udp", "udp4", "udp6":
default:
d.Fatal("network type", fmt.Errorf("unsupported network type %v", network))
return nil, fmt.Errorf("unsupported network type %v", network)
}
host, port, err := net.SplitHostPort(address)
d.Fatal("parse host", err)
if err != nil {
return nil, err
}
addresses, err := net.LookupHost(host)
d.Fatal("dns lookup", err)
d.Info("addresses", strings.Join(addresses, ", "))
if err != nil {
logp.Warn(`DNS lookup failure "%s": %v`, host, err)
return nil, err
}
// dial via host IP by randomized iteration of known IPs
dialer := &net.Dialer{Timeout: timeout}
return DialWith(dialer, network, host, addresses, port)
})
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。