Socks4 Proxy Support
Hello Please add support for Socks4 proxy Thanks
You can use something like https://github.com/SteffenLoges/socks4
Then use the SetDial function of your req client to make it use the SOCKS4 dialer
could you please give me a sample? @oddmario Is it possible to use https://github.com/wzshiming/socks4 ? he also has a socks5 lib + udp support https://github.com/wzshiming/socks5 it maybe able to fix https://github.com/imroc/req/issues/347
could you please give me a sample? @oddmario Is it possible to use https://github.com/wzshiming/socks4 ? he also has a socks5 lib + udp support https://github.com/wzshiming/socks5 it maybe able to fix #347
This is an example using https://github.com/SteffenLoges/socks4:
package main
import (
"context"
"fmt"
"net"
"time"
"github.com/SteffenLoges/socks4"
"github.com/imroc/req/v3"
)
func main() {
client := req.C()
protocol := socks4.SOCKS4 // socks4.SOCKS4 or socks4.SOCKS4A
proxyAddr := "127.0.0.1:1080" // proxy address with port
userID := "" // userID string for authentication, leave blank if no authentication is required
timeout := time.Second * 5 // use 0 to dial without a timeout
socks4Dialer := socks4.Dialer(protocol, proxyAddr, userID, timeout)
client.SetDial(func(ctx context.Context, network string, addr string) (net.Conn, error) {
return socks4Dialer(network, addr)
})
req_ := client.R()
resp, err := req_.Send("GET", "https://google.com/humans.txt")
if err != nil {
fmt.Println(err)
return
}
fmt.Println(resp.String())
}
If https://github.com/wzshiming/socks4 returns a Dialer similarly, you can use it like the above code