diff options
author | Wim <wim@42.be> | 2020-08-24 23:35:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-24 23:35:08 +0200 |
commit | 2f506425c25504662f50f49e742529195d63ff27 (patch) | |
tree | 47170c6086cee16549a695329a478fd49174c299 /vendor/github.com/Rhymen/go-whatsapp/session.go | |
parent | e8167ee3d73c47353eea1b0bd7062bd2fc3fc127 (diff) | |
download | matterbridge-msglm-2f506425c25504662f50f49e742529195d63ff27.tar.gz matterbridge-msglm-2f506425c25504662f50f49e742529195d63ff27.tar.bz2 matterbridge-msglm-2f506425c25504662f50f49e742529195d63ff27.zip |
Update whatsapp vendor and fix a panic (#1209)
* Fix another whatsapp panic
* Update whatsapp vendor
Diffstat (limited to 'vendor/github.com/Rhymen/go-whatsapp/session.go')
-rw-r--r-- | vendor/github.com/Rhymen/go-whatsapp/session.go | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/vendor/github.com/Rhymen/go-whatsapp/session.go b/vendor/github.com/Rhymen/go-whatsapp/session.go index f026df7d..dc3acd57 100644 --- a/vendor/github.com/Rhymen/go-whatsapp/session.go +++ b/vendor/github.com/Rhymen/go-whatsapp/session.go @@ -18,7 +18,7 @@ import ( ) //represents the WhatsAppWeb client version -var waVersion = []int{0, 4, 2080} +var waVersion = []int{2, 2033, 7} /* Session contains session individual information. To be able to resume the connection without scanning the qr code @@ -141,11 +141,11 @@ func CheckCurrentServerVersion() ([]int, error) { SetClientName sets the long and short client names that are sent to WhatsApp when logging in and displayed in the WhatsApp Web device list. As the values are only sent when logging in, changing them after logging in is not possible. */ -func (wac *Conn) SetClientName(long, short, version string) error { +func (wac *Conn) SetClientName(long, short string) error { if wac.session != nil && (wac.session.EncKey != nil || wac.session.MacKey != nil) { return fmt.Errorf("cannot change client name after logging in") } - wac.longClientName, wac.shortClientName, wac.clientVersion = long, short, version + wac.longClientName, wac.shortClientName = long, short return nil } @@ -231,7 +231,12 @@ func (wac *Conn) Login(qrChan chan<- string) (Session, error) { return session, fmt.Errorf("error decoding login resp: %v\n", err) } - ref := resp["ref"].(string) + var ref string + if rref, ok := resp["ref"].(string); ok { + ref = rref + } else { + return session, fmt.Errorf("error decoding login resp: invalid resp['ref']\n") + } priv, pub, err := curve25519.GenerateKey() if err != nil { @@ -390,9 +395,11 @@ func (wac *Conn) Restore() error { } if int(resp["status"].(float64)) != 200 { + wac.timeTag = "" return fmt.Errorf("init responded with %d", resp["status"]) } case <-time.After(wac.msgTimeout): + wac.timeTag = "" return fmt.Errorf("restore session init timed out") } @@ -401,10 +408,11 @@ func (wac *Conn) Restore() error { select { case r1 := <-s1: if err := json.Unmarshal([]byte(r1), &connResp); err != nil { + wac.timeTag = "" return fmt.Errorf("error decoding s1 message: %v\n", err) } case <-time.After(wac.msgTimeout): - + wac.timeTag = "" //check for an error message select { case r := <-loginChan: @@ -429,15 +437,18 @@ func (wac *Conn) Restore() error { wac.listener.Unlock() if err := wac.resolveChallenge(connResp[1].(map[string]interface{})["challenge"].(string)); err != nil { + wac.timeTag = "" return fmt.Errorf("error resolving challenge: %v\n", err) } select { case r := <-s2: if err := json.Unmarshal([]byte(r), &connResp); err != nil { + wac.timeTag = "" return fmt.Errorf("error decoding s2 message: %v\n", err) } case <-time.After(wac.msgTimeout): + wac.timeTag = "" return fmt.Errorf("restore session challenge timed out") } } @@ -447,13 +458,16 @@ func (wac *Conn) Restore() error { case r := <-loginChan: var resp map[string]interface{} if err = json.Unmarshal([]byte(r), &resp); err != nil { + wac.timeTag = "" return fmt.Errorf("error decoding login connResp: %v\n", err) } if int(resp["status"].(float64)) != 200 { + wac.timeTag = "" return fmt.Errorf("admin login responded with %d", resp["status"]) } case <-time.After(wac.msgTimeout): + wac.timeTag = "" return fmt.Errorf("restore session login timed out") } |