Merge remote-tracking branch 'github/master' into dev
This commit is contained in:
@@ -79,6 +79,10 @@ func (c *Curlx) WithProxySocks5(address string) error {
|
||||
baseDialer := &net.Dialer{
|
||||
// Timeout: 180 * time.Second,
|
||||
// KeepAlive: 180 * time.Second,
|
||||
Resolver: &net.Resolver{
|
||||
PreferGo: true,
|
||||
Dial: c.transport.DialContext,
|
||||
},
|
||||
}
|
||||
dialSocksProxy, err := proxy.SOCKS5("tcp", address, nil, baseDialer)
|
||||
if err != nil {
|
||||
@@ -94,7 +98,7 @@ func (c *Curlx) WithProxySocks5(address string) error {
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用HTTP代理
|
||||
* 使用HTTP/HTTPS代理
|
||||
* @param proxyAddr "https://proxyserver:port"
|
||||
*/
|
||||
func (c *Curlx) WithProxyHttp(proxyAddr string) error {
|
||||
@@ -311,7 +315,7 @@ func (c *Curlx) SendStream(ctx context.Context, ps ...Param) (<-chan string, err
|
||||
go func() {
|
||||
defer close(data)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*30)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), c.opts.TimeOut)
|
||||
defer cancel()
|
||||
|
||||
_, response, err := c.SendExec(ctx, ps...)
|
||||
|
||||
@@ -48,3 +48,10 @@ func TestForm(t *testing.T) {
|
||||
resp, code, err := NewCurlx().Send(context.Background(), SetParamsAll(p))
|
||||
fmt.Println(resp, code, err)
|
||||
}
|
||||
|
||||
func TestProxy(t *testing.T) {
|
||||
c := NewCurlx()
|
||||
c.WithProxySocks5("127.0.0.1:1080")
|
||||
res, code, err := c.Send(context.Background(), SetParamsUrl("https://www.google.com"),SetParamsMethod(MethodGet))
|
||||
t.Log(string(res), code, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user