fix socks proxy without auth
This commit is contained in:
parent
d45ac95957
commit
dbe17fb4d0
1 changed files with 10 additions and 1 deletions
11
scraper.go
11
scraper.go
|
|
@ -143,7 +143,16 @@ func (s *Scraper) SetProxy(proxyAddr string) error {
|
||||||
host := proxyURL.Hostname()
|
host := proxyURL.Hostname()
|
||||||
port := proxyURL.Port()
|
port := proxyURL.Port()
|
||||||
|
|
||||||
dialSocksProxy, err := proxy.SOCKS5("tcp", host+":"+port, &proxy.Auth{User: username, Password: password}, baseDialer)
|
var auth *proxy.Auth
|
||||||
|
|
||||||
|
if username != "" || password != "" {
|
||||||
|
auth = &proxy.Auth{
|
||||||
|
User: username,
|
||||||
|
Password: password,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dialSocksProxy, err := proxy.SOCKS5("tcp", host+":"+port, auth, baseDialer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("error creating socks5 proxy :" + err.Error())
|
return errors.New("error creating socks5 proxy :" + err.Error())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue