@@ -103,7 +103,7 @@ func (d *Dialer) GetDialFunc(useEnv bool) (dialFunc fasthttp.DialFunc, err error
103
103
case "socks5" , "socks5h" :
104
104
proxyDialer , err = proxy .FromURL (proxyURL , d )
105
105
if err != nil {
106
- return
106
+ return nil , err
107
107
}
108
108
case "http" :
109
109
proxyAddr , auth := addrAndAuth (proxyURL )
@@ -128,7 +128,7 @@ func (d *Dialer) GetDialFunc(useEnv bool) (dialFunc fasthttp.DialFunc, err error
128
128
reqURL := & url.URL {Host : addr , Scheme : scheme }
129
129
proxyURL , err = proxyFunc (reqURL )
130
130
if err != nil {
131
- return
131
+ return nil , err
132
132
}
133
133
if proxyURL == nil {
134
134
// dial directly
@@ -138,7 +138,7 @@ func (d *Dialer) GetDialFunc(useEnv bool) (dialFunc fasthttp.DialFunc, err error
138
138
case "socks5" , "socks5h" :
139
139
proxyDialer , err = proxy .FromURL (proxyURL , d )
140
140
if err != nil {
141
- return
141
+ return nil , err
142
142
}
143
143
case "http" :
144
144
proxyAddr , auth := addrAndAuth (proxyURL )
@@ -167,7 +167,7 @@ func (d *Dialer) Dial(network, addr string) (conn net.Conn, err error) {
167
167
return d .TCPDialer .DialDualStack (addr )
168
168
}
169
169
err = errors .New ("dont support the network: " + network )
170
- return
170
+ return nil , err
171
171
}
172
172
173
173
func (d * Dialer ) connectTimeout () time.Duration {
@@ -193,7 +193,7 @@ func (d DialerFunc) Dial(network, addr string) (net.Conn, error) {
193
193
func httpProxyDial (dialer proxy.Dialer , network , addr , proxyAddr , auth string ) (conn net.Conn , err error ) {
194
194
conn , err = dialer .Dial (network , proxyAddr )
195
195
if err != nil {
196
- return
196
+ return nil , err
197
197
}
198
198
var connectTimeout time.Duration
199
199
hp , ok := dialer .(httpProxyDialer )
@@ -218,21 +218,21 @@ func httpProxyDial(dialer proxy.Dialer, network, addr, proxyAddr, auth string) (
218
218
_ , err = conn .Write ([]byte (req ))
219
219
if err != nil {
220
220
_ = conn .Close ()
221
- return
221
+ return nil , err
222
222
}
223
223
res := fasthttp .AcquireResponse ()
224
224
defer fasthttp .ReleaseResponse (res )
225
225
res .SkipBody = true
226
226
if err = res .Read (bufio .NewReaderSize (conn , 1024 )); err != nil {
227
227
_ = conn .Close ()
228
- return
228
+ return nil , err
229
229
}
230
230
if res .Header .StatusCode () != 200 {
231
231
_ = conn .Close ()
232
232
err = fmt .Errorf ("could not connect to proxyAddr: %s status code: %d" , proxyAddr , res .Header .StatusCode ())
233
- return
233
+ return nil , err
234
234
}
235
- return
235
+ return conn , err
236
236
}
237
237
238
238
// Cache authentication information for HTTP proxies.
@@ -244,7 +244,7 @@ type proxyInfo struct {
244
244
func addrAndAuth (pu * url.URL ) (proxyAddr , auth string ) {
245
245
if pu .User == nil {
246
246
proxyAddr = pu .Host + pu .Path
247
- return
247
+ return proxyAddr , auth
248
248
}
249
249
var info * proxyInfo
250
250
v , ok := authCache .Load (pu )
0 commit comments