Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions yowsup/env/env_android.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ class AndroidYowsupEnv(YowsupEnv):
"YHNtYoIvt5R3X6YZylbPftF/8ayWTALBgcqhkjOOAQDBQADLwAwLAIUAKYCp0d6z4QQdyN74JDfQ2WCyi8CFDUM4CaNB+ceVXd" \
"KtOrNTQcc0e+t"

"""
If you have "old_version" registration error:
1. Download com.whatsapp.apk (for example with https://github.com/matlink/gplaycli)
-gplaycli -d com.whatsapp
2. Calculate version and MD5 with https://gist.github.com/masbog/d29c779539581defbf542e70ce724ed8
3. Replace the appropriate values (_MD5_CLASSES and _VERSION)
"""

_MD5_CLASSES = "/QhoCBMppKpKQumhTC8kcQ=="
_KEY = "eQV5aq/Cg63Gsq1sshN9T3gh+UUp0wIw0xgHYT1bnCjEqOJQKCRrWxdAe2yvsDeCJL+Y4G3PRD2HUF7oUgiGo8vGlNJOaux26k+A2F3hj8A="

Expand Down
17 changes: 12 additions & 5 deletions yowsup/layers/noise/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import threading
import logging
import base64


logger = logging.getLogger(__name__)
Expand All @@ -40,7 +41,8 @@ def __init__(self):
) # type: WANoiseProtocol

self._handshake_worker = None
self._stream = BlockingQueueSegmentedStream() # type: BlockingQueueSegmentedStream
# type: BlockingQueueSegmentedStream
self._stream = BlockingQueueSegmentedStream()
self._read_buffer = bytearray()
self._flush_lock = threading.Lock()
self._incoming_segments_queue = Queue.Queue()
Expand Down Expand Up @@ -72,8 +74,12 @@ def on_auth(self, event):
)
)
else:
if type(local_static) is bytes:
_type = type(local_static)
if _type is bytes:
local_static = KeyPair.from_bytes(local_static)
elif _type is str:
local_static = KeyPair.from_bytes(
base64.b64decode(local_static))
assert type(local_static) is KeyPair, type(local_static)
passive = event.getArg('passive')

Expand Down Expand Up @@ -112,7 +118,7 @@ def on_auth(self, event):
short_connect=True
)
if not self._in_handshake():
logger.debug("Performing handshake [username= %d, passive=%s]" % (username, passive) )
logger.debug("Performing handshake [username= %d, passive=%s]" % (username, passive))
self._handshake_worker = WANoiseProtocolHandshakeWorker(
self._wa_noiseprotocol, self._stream, client_config, local_static, remote_static,
self.on_handshake_finished
Expand All @@ -124,8 +130,9 @@ def on_auth(self, event):
def on_handshake_finished(self, e=None):
# type: (Exception) -> None
if e is not None:
self.emitEvent(YowLayerEvent(self.EVENT_HANDSHAKE_FAILED, reason=e))
data=WriteEncoder(TokenDictionary()).protocolTreeNodeToBytes(
self.emitEvent(YowLayerEvent(
self.EVENT_HANDSHAKE_FAILED, reason=e))
data = WriteEncoder(TokenDictionary()).protocolTreeNodeToBytes(
ProtocolTreeNode("failure", {"reason": str(e)})
)
self.toUpper(data)
Expand Down