提交 0186b0bb 编写于 作者: D Davies Liu

support IPv6 address in customized http client

上级 3ffdbb64
......@@ -57,8 +57,8 @@ func newOOS(endpoint, accessKey, secretKey string) (ObjectStorage, error) {
Endpoint: &endpoint,
DisableSSL: aws.Bool(!ssl),
S3ForcePathStyle: aws.Bool(!forcePathStyle),
// HTTPClient: httpClient,
Credentials: credentials.NewStaticCredentials(accessKey, secretKey, ""),
HTTPClient: httpClient,
Credentials: credentials.NewStaticCredentials(accessKey, secretKey, ""),
}
ses := session.New(awsConfig)
......
......@@ -35,6 +35,7 @@ func init() {
Dial: func(network string, address string) (net.Conn, error) {
separator := strings.LastIndex(address, ":")
host := address[:separator]
port := address[separator:]
ips, err := resolver.Fetch(host)
if err != nil {
return nil, err
......@@ -44,7 +45,11 @@ func init() {
}
ip := ips[rand.Intn(len(ips))]
dialer := &net.Dialer{Timeout: time.Second * 10}
return dialer.Dial("tcp", ip.String()+address[separator:])
address = ip.String()
if port != "" {
address = net.JoinHostPort(address, port[1:])
}
return dialer.Dial(network, address)
},
DisableCompression: true,
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册