Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed ''backup_token' error during registration process #3127

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion yowsup/env/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from .env import YowsupEnv
from .env_android import AndroidYowsupEnv
from .env_ios import iOsYowsupEnv
from .env_android import AndroidYowsupEnv
12 changes: 11 additions & 1 deletion yowsup/env/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

logger = logging.getLogger(__name__)

DEFAULT = "android"
DEFAULT = "ios"


class YowsupEnvType(abc.ABCMeta):
Expand Down Expand Up @@ -58,6 +58,16 @@ def getCurrent(cls):
logger.debug("Env not set, setting it to %s" % env)
cls.setEnv(env)
return cls.__CURR

@classmethod
def getAndroidEnv(cls):
env = "android"
envs = cls.getRegisteredEnvs()
if env not in envs:
env = envs[0]
logger.debug("Env not set, setting it to %s" % env)
cls.setEnv(env)
return cls.__CURR

@abc.abstractmethod
def getToken(self, phoneNumber):
Expand Down
4 changes: 2 additions & 2 deletions yowsup/env/env_android.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class AndroidYowsupEnv(YowsupEnv):
"YHNtYoIvt5R3X6YZylbPftF/8ayWTALBgcqhkjOOAQDBQADLwAwLAIUAKYCp0d6z4QQdyN74JDfQ2WCyi8CFDUM4CaNB+ceVXd" \
"KtOrNTQcc0e+t"

_MD5_CLASSES = "WuFH18yXKRVezywQm+S24A=="
_MD5_CLASSES = "XJnX1aI5e1bGaWmv350l+g=="
_KEY = "eQV5aq/Cg63Gsq1sshN9T3gh+UUp0wIw0xgHYT1bnCjEqOJQKCRrWxdAe2yvsDeCJL+Y4G3PRD2HUF7oUgiGo8vGlNJOaux26k+A2F3hj8A="

_VERSION = "2.21.21.18" # 2.20.206.24
_VERSION = "2.22.2.73" # 2.20.206.24
_OS_NAME = "Android"
_OS_VERSION = "8.0.0"
_DEVICE_NAME = "star2lte"
Expand Down
39 changes: 39 additions & 0 deletions yowsup/env/env_ios.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from .env import YowsupEnv
import base64
import hashlib


class iOsYowsupEnv(YowsupEnv):
_VERSION = "2.22.5.71" # 2.20.206.24
_OS_NAME = "iOS"
_OS_VERSION = "15.3.1"
_DEVICE_NAME = "iPhone 7"
_MANUFACTURER = "Apple"
_BUILD_VERSION = "19D52"
_AXOLOTL = True
_TOKEN = "0a1mLfGUIBVrMKF1RdvLI5lkRBvof6vn0fD2QRSM45e25b6ddecace8d01828dd00bd4ff64{phone}"

def getVersion(self):
return self.__class__._VERSION

def getOSName(self):
return self.__class__._OS_NAME

def getOSVersion(self):
return self.__class__._OS_VERSION

def getDeviceName(self):
return self.__class__._DEVICE_NAME

def getBuildVersion(self):
return self.__class__._BUILD_VERSION

def getManufacturer(self):
return self.__class__._MANUFACTURER

def isAxolotlEnabled(self):
return self.__class__._AXOLOTL

def getToken(self, phoneNumber):
result = hashlib.md5(self.__class__._TOKEN.format(phone = phoneNumber).encode()).hexdigest()
return result
11 changes: 9 additions & 2 deletions yowsup/layers/noise/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,20 @@ def on_auth(self, event):
remote_static = config.server_static_public

self._rs = remote_static
yowsupenv = YowsupEnv.getCurrent()
yowsupenv = YowsupEnv.getAndroidEnv()

##prepare os version
version_str = yowsupenv.getVersion()
version_list = version_str.split('.')
if len(version_list) > 3:
version_str = "%s.%s.%s" % (version_list[0], version_list[1], version_list[2])

client_config = ClientConfig(
username=username,
passive=passive,
useragent=UserAgentConfig(
platform=0,
app_version=yowsupenv.getVersion(),
app_version=version_str,
mcc=config.mcc or "000",
mnc=config.mnc or "000",
os_version=yowsupenv.getOSVersion(),
Expand Down