From 0bc159341dbb4aece685ce373e9bc0b6b32984e7 Mon Sep 17 00:00:00 2001 From: Wim Date: Sun, 27 Oct 2019 01:45:57 +0200 Subject: Update vendor (#932) * Update vendor * Fix godiscord api change --- vendor/github.com/Rhymen/go-whatsapp/conn.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'vendor/github.com/Rhymen/go-whatsapp/conn.go') diff --git a/vendor/github.com/Rhymen/go-whatsapp/conn.go b/vendor/github.com/Rhymen/go-whatsapp/conn.go index 2bdeb118..915ad4d9 100644 --- a/vendor/github.com/Rhymen/go-whatsapp/conn.go +++ b/vendor/github.com/Rhymen/go-whatsapp/conn.go @@ -4,6 +4,7 @@ package whatsapp import ( "math/rand" "net/http" + "net/url" "sync" "time" @@ -91,6 +92,7 @@ type Conn struct { shortClientName string loginSessionLock sync.RWMutex + Proxy func(*http.Request) (*url.URL, error) } type websocketWrapper struct { @@ -121,6 +123,21 @@ func NewConn(timeout time.Duration) (*Conn, error) { return wac, wac.connect() } +// NewConnWithProxy Create a new connect with a given timeout and a http proxy. +func NewConnWithProxy(timeout time.Duration, proxy func(*http.Request) (*url.URL, error)) (*Conn, error) { + wac := &Conn{ + handler: make([]Handler, 0), + msgCount: 0, + msgTimeout: timeout, + Store: newStore(), + + longClientName: "github.com/rhymen/go-whatsapp", + shortClientName: "go-whatsapp", + Proxy: proxy, + } + return wac, wac.connect() +} + // connect should be guarded with wsWriteMutex func (wac *Conn) connect() (err error) { if wac.connected { @@ -137,6 +154,7 @@ func (wac *Conn) connect() (err error) { ReadBufferSize: 25 * 1024 * 1024, WriteBufferSize: 10 * 1024 * 1024, HandshakeTimeout: wac.msgTimeout, + Proxy: wac.Proxy, } headers := http.Header{"Origin": []string{"https://web.whatsapp.com"}} @@ -202,7 +220,7 @@ func (wac *Conn) AdminTest() (bool, error) { return false, ErrInvalidSession } - result, err := wac.sendAdminTest() + result, err := wac.sendAdminTest() return result, err } -- cgit v1.2.3