tulir / whatsmeow

Go library for the WhatsApp web multidevice API
https://go.mau.fi/whatsmeow
Mozilla Public License 2.0
2.29k stars 427 forks source link

HTTPS Proxy is not working: unknown scheme https #700

Open mircoianese opened 5 days ago

mircoianese commented 5 days ago

Hello,

I'm trying to set up an HTTPS proxy but I'm getting this error while connecting: failed to connect: couldn't dial whatsapp web websocket: proxy: unknown scheme: https

This is my code:

client := whatsmeow.NewClient(device, clientLog)

err := client.SetProxyAddress("https://username:password@proxy-address.com:1234", whatsmeow.SetProxyOptions{
    NoWebsocket: false,
    NoMedia:     false,
})

// err here is nil

err := client.Connect()

By further looking at the code, I see the proxy_FromURL function from x_net_proxy.go package getting called:

// FromURL returns a Dialer given a URL specification and an underlying
// Dialer for it to make network requests.
func proxy_FromURL(u *url.URL, forward proxy_Dialer) (proxy_Dialer, error) {
    var auth *proxy_Auth
    if u.User != nil {
        auth = new(proxy_Auth)
        auth.User = u.User.Username()
        if p, ok := u.User.Password(); ok {
            auth.Password = p
        }
    }

    switch u.Scheme {
    case "socks5":
        return proxy_SOCKS5("tcp", u.Host, auth, forward)
    }

    // If the scheme doesn't match any of the built-in schemes, see if it
    // was registered by another package.
    if proxy_proxySchemes != nil {
        if f, ok := proxy_proxySchemes[u.Scheme]; ok {
            return f(u, forward)
        }
    }

    return nil, errors.New("proxy: unknown scheme: " + u.Scheme)
}

And this is the function that's returning the error. Thank you