move dial functions into golib (#2767)

This commit is contained in:
fatedier
2022-01-20 20:03:07 +08:00
committed by GitHub
parent 293003fcdb
commit 70f4caac23
9 changed files with 114 additions and 195 deletions

View File

@@ -13,7 +13,7 @@ import (
"time"
"github.com/fatedier/frp/test/e2e/pkg/rpc"
libnet "github.com/fatedier/golib/net"
libdial "github.com/fatedier/golib/net/dial"
)
type Request struct {
@@ -141,7 +141,11 @@ func (r *Request) Do() (*Response, error) {
if r.protocol != "tcp" {
return nil, fmt.Errorf("only tcp protocol is allowed for proxy")
}
conn, err = libnet.DialTcpByProxy(r.proxyURL, addr)
proxyType, proxyAddress, auth, err := libdial.ParseProxyURL(r.proxyURL)
if err != nil {
return nil, fmt.Errorf("parse ProxyURL error: %v", err)
}
conn, err = libdial.Dial(addr, libdial.WithProxy(proxyType, proxyAddress), libdial.WithProxyAuth(auth))
if err != nil {
return nil, err
}