summaryrefslogtreecommitdiff
path: root/protocols/WhatsAppWeb/src/server.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/WhatsAppWeb/src/server.cpp')
-rw-r--r--protocols/WhatsAppWeb/src/server.cpp27
1 files changed, 8 insertions, 19 deletions
diff --git a/protocols/WhatsAppWeb/src/server.cpp b/protocols/WhatsAppWeb/src/server.cpp
index 515aa86458..ac2ef6c6c0 100644
--- a/protocols/WhatsAppWeb/src/server.cpp
+++ b/protocols/WhatsAppWeb/src/server.cpp
@@ -76,13 +76,15 @@ bool WhatsAppProto::ProcessHandshake(const MBinBuffer &keyEnc)
pCompanion.set_platformtype(proto::DeviceProps_PlatformType_DESKTOP);
pCompanion.set_requirefullsync(true);
- //MBinBuffer buf(pCompanion.ByteSize());
- //pCompanion.SerializeToArray(buf.data(), (int)buf.length());
+ MBinBuffer buf(pCompanion.ByteSize());
+ pCompanion.SerializeToArray(buf.data(), (int)buf.length());
auto *pPairingData = new proto::ClientPayload_DevicePairingRegistrationData();
- //pPairingData->set_deviceprops(buf.data(), buf.length());
+ pPairingData->set_deviceprops(buf.data(), buf.length());
pPairingData->set_buildhash(appVersion, sizeof(appVersion));
- pPairingData->set_eregid("");
+
+ MBinBuffer tmp = encodeBigEndian(getDword(DBKEY_REG_ID));
+ pPairingData->set_eregid(tmp.data(), tmp.length());
node.set_allocated_devicepairingdata(pPairingData);
}
@@ -122,20 +124,6 @@ bool WhatsAppProto::ProcessHandshake(const MBinBuffer &keyEnc)
/////////////////////////////////////////////////////////////////////////////////////////
-void WhatsAppProto::OnRestoreSession1(const JSONNode&, void*)
-{
- ptrA szClient(getStringA(DBKEY_CLIENT_TOKEN)), szServer(getStringA(DBKEY_SERVER_TOKEN));
- if (szClient == nullptr || szServer == nullptr) {
- ShutdownSession();
- return;
- }
-
- // CMStringA payload(FORMAT, "[\"admin\",\"login\",\"%s\",\"%s\",\"%s\",\"takeover\"]", szClient.get(), szServer.get(), m_szClientId.c_str());
- // WSSend(payload, &WhatsAppProto::OnRestoreSession2);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
void WhatsAppProto::ShutdownSession()
{
if (m_bTerminated)
@@ -219,6 +207,7 @@ bool WhatsAppProto::ServerThreadWorker()
delete m_noise;
m_noise = new WANoise(this);
+ m_noise->init();
debugLogA("Server connection succeeded");
m_hServerConn = pReply->nlc;
@@ -226,7 +215,7 @@ bool WhatsAppProto::ServerThreadWorker()
m_iPktNumber = 0;
m_szClientToken = getMStringA(DBKEY_CLIENT_TOKEN);
- auto &pubKey = m_noise->getPub();
+ auto &pubKey = m_noise->noiseKeys.pub;
ptrA szPubKey(mir_base64_encode(pubKey.data(), pubKey.length()));
auto *client = new proto::HandshakeMessage::ClientHello(); client->set_ephemeral(pubKey.data(), pubKey.length());
proto::HandshakeMessage msg; msg.set_allocated_clienthello(client);