summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/Rhymen/go-whatsapp/conn.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2019-10-27 01:45:57 +0200
committerGitHub <noreply@github.com>2019-10-27 01:45:57 +0200
commit0bc159341dbb4aece685ce373e9bc0b6b32984e7 (patch)
treeed67d8e03541b2cb61ab161771f1c6e41070d372 /vendor/github.com/Rhymen/go-whatsapp/conn.go
parent45bf1fd63a62b46fc80fe5143e667f6779705a0d (diff)
downloadmatterbridge-msglm-0bc159341dbb4aece685ce373e9bc0b6b32984e7.tar.gz
matterbridge-msglm-0bc159341dbb4aece685ce373e9bc0b6b32984e7.tar.bz2
matterbridge-msglm-0bc159341dbb4aece685ce373e9bc0b6b32984e7.zip
Update vendor (#932)
* Update vendor * Fix godiscord api change
Diffstat (limited to 'vendor/github.com/Rhymen/go-whatsapp/conn.go')
-rw-r--r--vendor/github.com/Rhymen/go-whatsapp/conn.go20
1 files changed, 19 insertions, 1 deletions
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
}