mirror of
https://github.com/NekoX-Dev/NekoX.git
synced 2024-11-27 03:29:14 +01:00
Native changes
This commit is contained in:
parent
3f7138d260
commit
5eb5f9de51
@ -160,6 +160,43 @@ void applyDatacenterAddress(JNIEnv *env, jclass c, jint instanceNum, jint datace
|
||||
}
|
||||
}
|
||||
|
||||
void setDatacenterPublicKey(JNIEnv *env, jclass c, jint instanceNum, jint dataCenterId, jstring publicKey, jlong fingerprint) {
|
||||
const char *publicKeyStr = env->GetStringUTFChars(publicKey, nullptr);
|
||||
|
||||
ConnectionsManager::getInstance(instanceNum).setDatacenterPublicKey(dataCenterId, publicKeyStr,fingerprint);
|
||||
|
||||
if (publicKeyStr != nullptr) {
|
||||
env->ReleaseStringUTFChars(publicKey, publicKeyStr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void setDatacenterAddress(JNIEnv *env, jclass c, jint instanceNum, jint datacenterId, jstring ipv4Address, jstring ipv6Address, jint port) {
|
||||
const char *v4Str = env->GetStringUTFChars(ipv4Address, nullptr);
|
||||
const char *v6Str = env->GetStringUTFChars(ipv4Address, nullptr);
|
||||
|
||||
ConnectionsManager::getInstance(instanceNum).setDatacenterAddress((uint32_t) datacenterId, std::string(v4Str), std::string(v6Str), (uint32_t) port);
|
||||
|
||||
if (v4Str != nullptr) {
|
||||
env->ReleaseStringUTFChars(ipv4Address, v4Str);
|
||||
}
|
||||
if (v6Str != nullptr) {
|
||||
env->ReleaseStringUTFChars(ipv6Address, v6Str);
|
||||
}
|
||||
}
|
||||
|
||||
void setLayer(JNIEnv *env, jclass c, jint instanceNum, jint layer) {
|
||||
|
||||
ConnectionsManager::getInstance(instanceNum).setLayer((uint32_t) layer);
|
||||
|
||||
}
|
||||
|
||||
void saveDatacenters(JNIEnv *env, jclass c,jint instanceNum) {
|
||||
|
||||
ConnectionsManager::getInstance(instanceNum).saveDatacenters();
|
||||
|
||||
}
|
||||
|
||||
void setProxySettings(JNIEnv *env, jclass c, jint instanceNum, jstring address, jint port, jstring username, jstring password, jstring secret) {
|
||||
const char *addressStr = env->GetStringUTFChars(address, 0);
|
||||
const char *usernameStr = env->GetStringUTFChars(username, 0);
|
||||
@ -260,29 +297,29 @@ jlong checkProxy(JNIEnv *env, jclass c, jint instanceNum, jstring address, jint
|
||||
}
|
||||
|
||||
class Delegate : public ConnectiosManagerDelegate {
|
||||
|
||||
|
||||
void onUpdate(int32_t instanceNum) {
|
||||
jniEnv[instanceNum]->CallStaticVoidMethod(jclass_ConnectionsManager, jclass_ConnectionsManager_onUpdate, instanceNum);
|
||||
}
|
||||
|
||||
|
||||
void onSessionCreated(int32_t instanceNum) {
|
||||
jniEnv[instanceNum]->CallStaticVoidMethod(jclass_ConnectionsManager, jclass_ConnectionsManager_onSessionCreated, instanceNum);
|
||||
}
|
||||
|
||||
|
||||
void onConnectionStateChanged(ConnectionState state, int32_t instanceNum) {
|
||||
jniEnv[instanceNum]->CallStaticVoidMethod(jclass_ConnectionsManager, jclass_ConnectionsManager_onConnectionStateChanged, state, instanceNum);
|
||||
}
|
||||
|
||||
|
||||
void onUnparsedMessageReceived(int64_t reqMessageId, NativeByteBuffer *buffer, ConnectionType connectionType, int32_t instanceNum) {
|
||||
if (connectionType == ConnectionTypeGeneric) {
|
||||
jniEnv[instanceNum]->CallStaticVoidMethod(jclass_ConnectionsManager, jclass_ConnectionsManager_onUnparsedMessageReceived, (jlong) (intptr_t) buffer, instanceNum);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void onLogout(int32_t instanceNum) {
|
||||
jniEnv[instanceNum]->CallStaticVoidMethod(jclass_ConnectionsManager, jclass_ConnectionsManager_onLogout, instanceNum);
|
||||
}
|
||||
|
||||
|
||||
void onUpdateConfig(TL_config *config, int32_t instanceNum) {
|
||||
NativeByteBuffer *buffer = BuffersStorage::getInstance().getFreeBuffer(config->getObjectSize());
|
||||
config->serializeToStream(buffer);
|
||||
@ -290,7 +327,7 @@ class Delegate : public ConnectiosManagerDelegate {
|
||||
jniEnv[instanceNum]->CallStaticVoidMethod(jclass_ConnectionsManager, jclass_ConnectionsManager_onUpdateConfig, (jlong) (intptr_t) buffer, instanceNum);
|
||||
buffer->reuse();
|
||||
}
|
||||
|
||||
|
||||
void onInternalPushReceived(int32_t instanceNum) {
|
||||
jniEnv[instanceNum]->CallStaticVoidMethod(jclass_ConnectionsManager, jclass_ConnectionsManager_onInternalPushReceived, instanceNum);
|
||||
}
|
||||
@ -322,7 +359,7 @@ class Delegate : public ConnectiosManagerDelegate {
|
||||
}
|
||||
};
|
||||
|
||||
void onHostNameResolved(JNIEnv *env, jclass c, jstring host, jlong address, jstring ip) {
|
||||
void onHostNameResolved(JNIEnv *env, jclass c, jstring host, jlong address, jstring ip,jboolean ipv6) {
|
||||
const char *ipStr = env->GetStringUTFChars(ip, 0);
|
||||
const char *hostStr = env->GetStringUTFChars(host, 0);
|
||||
std::string i = std::string(ipStr);
|
||||
@ -334,7 +371,7 @@ void onHostNameResolved(JNIEnv *env, jclass c, jstring host, jlong address, jstr
|
||||
env->ReleaseStringUTFChars(host, hostStr);
|
||||
}
|
||||
ConnectionSocket *socket = (ConnectionSocket *) (intptr_t) address;
|
||||
socket->onHostNameResolved(h, i, false);
|
||||
socket->onHostNameResolved(h, i, ipv6);
|
||||
}
|
||||
|
||||
void setLangCode(JNIEnv *env, jclass c, jint instanceNum, jstring langCode) {
|
||||
@ -428,6 +465,10 @@ static JNINativeMethod ConnectionsManagerMethods[] = {
|
||||
{"native_cancelRequestsForGuid", "(II)V", (void *) cancelRequestsForGuid},
|
||||
{"native_bindRequestToGuid", "(III)V", (void *) bindRequestToGuid},
|
||||
{"native_applyDatacenterAddress", "(IILjava/lang/String;I)V", (void *) applyDatacenterAddress},
|
||||
{"native_setDatacenterPublicKey", "(IILjava/lang/String;J)V", (void *) setDatacenterPublicKey},
|
||||
{"native_setDatacenterAddress", "(IILjava/lang/String;Ljava/lang/String;I)V", (void *) setDatacenterAddress},
|
||||
{"native_saveDatacenters", "(I)V", (void *) saveDatacenters},
|
||||
{"native_setLayer", "(II)V", (void *) setLayer},
|
||||
{"native_setProxySettings", "(ILjava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", (void *) setProxySettings},
|
||||
{"native_getConnectionState", "(I)I", (void *) getConnectionState},
|
||||
{"native_setUserId", "(II)V", (void *) setUserId},
|
||||
@ -445,7 +486,7 @@ static JNINativeMethod ConnectionsManagerMethods[] = {
|
||||
{"native_setJava", "(Z)V", (void *) setJava},
|
||||
{"native_applyDnsConfig", "(IJLjava/lang/String;I)V", (void *) applyDnsConfig},
|
||||
{"native_checkProxy", "(ILjava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Lorg/telegram/tgnet/RequestTimeDelegate;)J", (void *) checkProxy},
|
||||
{"native_onHostNameResolved", "(Ljava/lang/String;JLjava/lang/String;)V", (void *) onHostNameResolved}
|
||||
{"native_onHostNameResolved", "(Ljava/lang/String;JLjava/lang/String;Z)V", (void *) onHostNameResolved}
|
||||
};
|
||||
|
||||
inline int registerNativeMethods(JNIEnv *env, const char *className, JNINativeMethod *methods, int methodsCount) {
|
||||
@ -462,15 +503,15 @@ inline int registerNativeMethods(JNIEnv *env, const char *className, JNINativeMe
|
||||
|
||||
extern "C" int registerNativeTgNetFunctions(JavaVM *vm, JNIEnv *env) {
|
||||
java = vm;
|
||||
|
||||
|
||||
if (!registerNativeMethods(env, NativeByteBufferClassPathName, NativeByteBufferMethods, sizeof(NativeByteBufferMethods) / sizeof(NativeByteBufferMethods[0]))) {
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
|
||||
if (!registerNativeMethods(env, ConnectionsManagerClassPathName, ConnectionsManagerMethods, sizeof(ConnectionsManagerMethods) / sizeof(ConnectionsManagerMethods[0]))) {
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
|
||||
jclass_RequestDelegateInternal = (jclass) env->NewGlobalRef(env->FindClass("org/telegram/tgnet/RequestDelegateInternal"));
|
||||
if (jclass_RequestDelegateInternal == 0) {
|
||||
return JNI_FALSE;
|
||||
|
@ -433,7 +433,9 @@ void ConnectionsManager::loadConfig() {
|
||||
}
|
||||
}
|
||||
|
||||
initDatacenters();
|
||||
if (datacenters.empty()) {
|
||||
initDatacenters();
|
||||
}
|
||||
|
||||
if ((datacenters.size() != 0 && currentDatacenterId == 0) || pushSessionId == 0) {
|
||||
if (pushSessionId == 0) {
|
||||
@ -681,7 +683,9 @@ void ConnectionsManager::onConnectionClosed(Connection *connection, int reason)
|
||||
} else {
|
||||
requestingSecondAddress = 0;
|
||||
}
|
||||
delegate->onRequestNewServerIpAndPort(requestingSecondAddress, instanceNum);
|
||||
if (datacenter->keyFingerprint == 0) {
|
||||
delegate->onRequestNewServerIpAndPort(requestingSecondAddress,instanceNum);
|
||||
}
|
||||
} else {
|
||||
if (LOGS_ENABLED) DEBUG_D("connection has usefull data, don't request anything");
|
||||
}
|
||||
@ -3071,6 +3075,77 @@ void ConnectionsManager::applyDatacenterAddress(uint32_t datacenterId, std::stri
|
||||
});
|
||||
}
|
||||
|
||||
void ConnectionsManager::setDatacenterAddress(uint32_t datacenterId, std::string ipv4Address,std::string ipv6Address, uint32_t port) {
|
||||
scheduleTask([&, datacenterId, ipv4Address,ipv6Address, port] {
|
||||
Datacenter *datacenter = getDatacenterWithId(datacenterId);
|
||||
if (datacenter != nullptr) {
|
||||
|
||||
datacenter->suspendConnections(true);
|
||||
datacenter->resetAddressAndPortNum();
|
||||
datacenter->addressesIpv4Download.clear();
|
||||
datacenter->addressesIpv6Download.clear();
|
||||
datacenter->addressesIpv4Temp.clear();
|
||||
|
||||
if (ipv4Address.empty()) {
|
||||
datacenter->addressesIpv4.clear();
|
||||
} else {
|
||||
std::vector<TcpAddress> v4Addresses;
|
||||
v4Addresses.push_back(TcpAddress(ipv4Address, port, 0, ""));
|
||||
datacenter->replaceAddresses(v4Addresses, 0);
|
||||
}
|
||||
|
||||
if (ipv6Address.empty()) {
|
||||
datacenter->addressesIpv6.clear();
|
||||
} else {
|
||||
std::vector<TcpAddress> v6Addresses;
|
||||
v6Addresses.push_back(TcpAddress(ipv4Address, port, 1, ""));
|
||||
datacenter->replaceAddresses(v6Addresses, 1);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void ConnectionsManager::setLayer(uint32_t layer) {
|
||||
|
||||
scheduleTask([&, layer] {
|
||||
|
||||
currentLayer = layer;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
void ConnectionsManager::saveDatacenters() {
|
||||
|
||||
scheduleTask([&] {
|
||||
|
||||
saveConfig();
|
||||
|
||||
for (std::map<uint32_t, Datacenter *>::iterator iter = datacenters.begin(); iter != datacenters.end(); iter++) {
|
||||
iter->second->clearAuthKey(HandshakeTypeAll);
|
||||
iter->second->recreateSessions(HandshakeTypeAll);
|
||||
iter->second->authorized = false;
|
||||
if (iter->second->isHandshakingAny()) {
|
||||
iter->second->beginHandshake(HandshakeTypeCurrent, true);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
void ConnectionsManager::setDatacenterPublicKey(uint32_t datacenterId, std::string publicKey, uint64_t fingerprint) {
|
||||
scheduleTask([&, datacenterId, publicKey, fingerprint] {
|
||||
Datacenter *datacenter = getDatacenterWithId(datacenterId);
|
||||
if (datacenter != nullptr) {
|
||||
datacenter->publicKey = publicKey;
|
||||
datacenter->keyFingerprint = fingerprint;
|
||||
datacenter->storePermConfig();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ConnectionState ConnectionsManager::getConnectionState() {
|
||||
return connectionState;
|
||||
}
|
||||
@ -3175,13 +3250,19 @@ void ConnectionsManager::applyDnsConfig(NativeByteBuffer *buffer, std::string ph
|
||||
}
|
||||
if (requestingSecondAddress == 2) {
|
||||
requestingSecondAddress = 3;
|
||||
delegate->onRequestNewServerIpAndPort(requestingSecondAddress, instanceNum);
|
||||
if (getDatacenterWithId(currentDatacenterId)->keyFingerprint == 0) {
|
||||
delegate->onRequestNewServerIpAndPort(requestingSecondAddress, instanceNum);
|
||||
}
|
||||
} else if (requestingSecondAddress == 1) {
|
||||
requestingSecondAddress = 2;
|
||||
delegate->onRequestNewServerIpAndPort(requestingSecondAddress, instanceNum);
|
||||
if (getDatacenterWithId(currentDatacenterId)->keyFingerprint == 0) {
|
||||
delegate->onRequestNewServerIpAndPort(requestingSecondAddress, instanceNum);
|
||||
}
|
||||
} else if (requestingSecondAddress == 0) {
|
||||
requestingSecondAddress = 1;
|
||||
delegate->onRequestNewServerIpAndPort(requestingSecondAddress, instanceNum);
|
||||
if (getDatacenterWithId(currentDatacenterId)->keyFingerprint == 0) {
|
||||
delegate->onRequestNewServerIpAndPort(requestingSecondAddress, instanceNum);
|
||||
}
|
||||
} else {
|
||||
requestingSecondAddress = 0;
|
||||
}
|
||||
|
@ -55,6 +55,10 @@ public:
|
||||
void cancelRequestsForGuid(int32_t guid);
|
||||
void bindRequestToGuid(int32_t requestToken, int32_t guid);
|
||||
void applyDatacenterAddress(uint32_t datacenterId, std::string ipAddress, uint32_t port);
|
||||
void setDatacenterPublicKey(uint32_t datacenterId, std::string publicKey, uint64_t fingerprint);
|
||||
void setDatacenterAddress(uint32_t datacenterId, std::string ipv4Address, std::string ipv6Address,uint32_t port);
|
||||
void setLayer(uint32_t layer);
|
||||
void saveDatacenters();
|
||||
void setDelegate(ConnectiosManagerDelegate *connectiosManagerDelegate);
|
||||
ConnectionState getConnectionState();
|
||||
void setUserId(int32_t userId);
|
||||
@ -245,6 +249,7 @@ private:
|
||||
friend class Config;
|
||||
friend class FileLog;
|
||||
friend class Handshake;
|
||||
|
||||
};
|
||||
|
||||
#ifdef ANDROID
|
||||
|
@ -191,6 +191,17 @@ Datacenter::Datacenter(int32_t instance, NativeByteBuffer *data) {
|
||||
currentPortNumIpv6Download = 0;
|
||||
currentAddressNumIpv6Download = 0;
|
||||
}
|
||||
if (permConfig == nullptr) {
|
||||
permConfig = new Config(instanceNum, "dc" + to_string_int32(datacenterId) + "perm.dat");
|
||||
}
|
||||
NativeByteBuffer *permBuffer = permConfig->readConfig();
|
||||
if (permBuffer != nullptr) {
|
||||
publicKey = permBuffer->readString(nullptr);
|
||||
keyFingerprint = permBuffer->readUint64(nullptr);
|
||||
permBuffer->reuse();
|
||||
} else {
|
||||
publicKey = "";
|
||||
}
|
||||
}
|
||||
|
||||
TcpAddress *Datacenter::getCurrentAddress(uint32_t flags) {
|
||||
@ -481,6 +492,37 @@ void Datacenter::storeCurrentAddressAndPortNum() {
|
||||
buffer->reuse();
|
||||
}
|
||||
|
||||
void Datacenter::storePermConfig() {
|
||||
|
||||
if (permConfig == nullptr) {
|
||||
permConfig = new Config(instanceNum, "dc" + to_string_int32(datacenterId) + "perm.dat");
|
||||
}
|
||||
|
||||
if (sizeCalculator == nullptr) {
|
||||
sizeCalculator = new NativeByteBuffer(true);
|
||||
}
|
||||
|
||||
sizeCalculator->clearCapacity();
|
||||
sizeCalculator->writeString(publicKey);
|
||||
sizeCalculator->writeInt64(keyFingerprint);
|
||||
|
||||
NativeByteBuffer *buffer = BuffersStorage::getInstance().getFreeBuffer(sizeCalculator->capacity());
|
||||
sizeCalculator->clearCapacity();
|
||||
|
||||
buffer->writeString(publicKey);
|
||||
buffer->writeInt64(keyFingerprint);
|
||||
|
||||
permConfig->writeConfig(buffer);
|
||||
|
||||
buffer->reuse();
|
||||
|
||||
for (std::vector<std::unique_ptr<Handshake>>::iterator iter = handshakes.begin(); iter != handshakes.end(); iter++) {
|
||||
Handshake *handshake = iter->get();
|
||||
handshake->clearServerPublicKey();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Datacenter::resetAddressAndPortNum() {
|
||||
currentPortNumIpv4 = 0;
|
||||
currentAddressNumIpv4 = 0;
|
||||
|
@ -97,6 +97,8 @@ private:
|
||||
uint32_t lastInitMediaVersion = 0;
|
||||
bool authorized = false;
|
||||
|
||||
std::string publicKey;
|
||||
uint64_t keyFingerprint = 0;
|
||||
std::vector<TcpAddress> addressesIpv4;
|
||||
std::vector<TcpAddress> addressesIpv6;
|
||||
std::vector<TcpAddress> addressesIpv4Download;
|
||||
@ -121,6 +123,7 @@ private:
|
||||
ByteArray *authKeyMediaTemp = nullptr;
|
||||
int64_t authKeyMediaTempId = 0;
|
||||
Config *config = nullptr;
|
||||
Config *permConfig = nullptr;
|
||||
bool isCdnDatacenter = false;
|
||||
|
||||
std::vector<std::unique_ptr<Handshake>> handshakes;
|
||||
@ -148,6 +151,9 @@ private:
|
||||
friend class Connection;
|
||||
friend class Handshake;
|
||||
friend class Request;
|
||||
|
||||
NativeByteBuffer *sizeCalculator;
|
||||
void storePermConfig();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -108,6 +108,13 @@ void Handshake::cleanupHandshake() {
|
||||
authKeyTempPendingId = 0;
|
||||
}
|
||||
|
||||
void Handshake::clearServerPublicKey() {
|
||||
|
||||
serverPublicKeys.clear();
|
||||
clearServerPublicKey();
|
||||
|
||||
}
|
||||
|
||||
inline Connection *Handshake::getConnection() {
|
||||
return handshakeType == HandshakeTypeMediaTemp ? currentDatacenter->createGenericMediaConnection() : currentDatacenter->createGenericConnection();
|
||||
}
|
||||
@ -353,94 +360,106 @@ void Handshake::processHandshakeResponse(TLObject *message, int64_t messageId) {
|
||||
}
|
||||
} else {
|
||||
if (serverPublicKeys.empty()) {
|
||||
|
||||
if (!currentDatacenter->publicKey.empty()) {
|
||||
|
||||
serverPublicKeys.push_back(currentDatacenter->publicKey);
|
||||
serverPublicKeysFingerprints.push_back(currentDatacenter->keyFingerprint);
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
#ifdef USE_OLD_KEYS
|
||||
serverPublicKeys.push_back("-----BEGIN RSA PUBLIC KEY-----\n"
|
||||
"MIIBCgKCAQEAwVACPi9w23mF3tBkdZz+zwrzKOaaQdr01vAbU4E1pvkfj4sqDsm6\n"
|
||||
"lyDONS789sVoD/xCS9Y0hkkC3gtL1tSfTlgCMOOul9lcixlEKzwKENj1Yz/s7daS\n"
|
||||
"an9tqw3bfUV/nqgbhGX81v/+7RFAEd+RwFnK7a+XYl9sluzHRyVVaTTveB2GazTw\n"
|
||||
"Efzk2DWgkBluml8OREmvfraX3bkHZJTKX4EQSjBbbdJ2ZXIsRrYOXfaA+xayEGB+\n"
|
||||
"8hdlLmAjbCVfaigxX0CDqWeR1yFL9kwd9P0NsZRPsmoqVwMbMu7mStFai6aIhc3n\n"
|
||||
"Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB\n"
|
||||
"-----END RSA PUBLIC KEY-----");
|
||||
serverPublicKeysFingerprints.push_back(0xc3b42b026ce86b21LL);
|
||||
serverPublicKeys.push_back("-----BEGIN RSA PUBLIC KEY-----\n"
|
||||
"MIIBCgKCAQEAwVACPi9w23mF3tBkdZz+zwrzKOaaQdr01vAbU4E1pvkfj4sqDsm6\n"
|
||||
"lyDONS789sVoD/xCS9Y0hkkC3gtL1tSfTlgCMOOul9lcixlEKzwKENj1Yz/s7daS\n"
|
||||
"an9tqw3bfUV/nqgbhGX81v/+7RFAEd+RwFnK7a+XYl9sluzHRyVVaTTveB2GazTw\n"
|
||||
"Efzk2DWgkBluml8OREmvfraX3bkHZJTKX4EQSjBbbdJ2ZXIsRrYOXfaA+xayEGB+\n"
|
||||
"8hdlLmAjbCVfaigxX0CDqWeR1yFL9kwd9P0NsZRPsmoqVwMbMu7mStFai6aIhc3n\n"
|
||||
"Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB\n"
|
||||
"-----END RSA PUBLIC KEY-----");
|
||||
serverPublicKeysFingerprints.push_back(0xc3b42b026ce86b21LL);
|
||||
|
||||
serverPublicKeys.push_back("-----BEGIN RSA PUBLIC KEY-----\n"
|
||||
"MIIBCgKCAQEAxq7aeLAqJR20tkQQMfRn+ocfrtMlJsQ2Uksfs7Xcoo77jAid0bRt\n"
|
||||
"ksiVmT2HEIJUlRxfABoPBV8wY9zRTUMaMA654pUX41mhyVN+XoerGxFvrs9dF1Ru\n"
|
||||
"vCHbI02dM2ppPvyytvvMoefRoL5BTcpAihFgm5xCaakgsJ/tH5oVl74CdhQw8J5L\n"
|
||||
"xI/K++KJBUyZ26Uba1632cOiq05JBUW0Z2vWIOk4BLysk7+U9z+SxynKiZR3/xdi\n"
|
||||
"XvFKk01R3BHV+GUKM2RYazpS/P8v7eyKhAbKxOdRcFpHLlVwfjyM1VlDQrEZxsMp\n"
|
||||
"NTLYXb6Sce1Uov0YtNx5wEowlREH1WOTlwIDAQAB\n"
|
||||
"-----END RSA PUBLIC KEY-----");
|
||||
serverPublicKeysFingerprints.push_back(0x9a996a1db11c729bLL);
|
||||
serverPublicKeys.push_back("-----BEGIN RSA PUBLIC KEY-----\n"
|
||||
"MIIBCgKCAQEAxq7aeLAqJR20tkQQMfRn+ocfrtMlJsQ2Uksfs7Xcoo77jAid0bRt\n"
|
||||
"ksiVmT2HEIJUlRxfABoPBV8wY9zRTUMaMA654pUX41mhyVN+XoerGxFvrs9dF1Ru\n"
|
||||
"vCHbI02dM2ppPvyytvvMoefRoL5BTcpAihFgm5xCaakgsJ/tH5oVl74CdhQw8J5L\n"
|
||||
"xI/K++KJBUyZ26Uba1632cOiq05JBUW0Z2vWIOk4BLysk7+U9z+SxynKiZR3/xdi\n"
|
||||
"XvFKk01R3BHV+GUKM2RYazpS/P8v7eyKhAbKxOdRcFpHLlVwfjyM1VlDQrEZxsMp\n"
|
||||
"NTLYXb6Sce1Uov0YtNx5wEowlREH1WOTlwIDAQAB\n"
|
||||
"-----END RSA PUBLIC KEY-----");
|
||||
serverPublicKeysFingerprints.push_back(0x9a996a1db11c729bLL);
|
||||
|
||||
serverPublicKeys.push_back("-----BEGIN RSA PUBLIC KEY-----\n"
|
||||
"MIIBCgKCAQEAsQZnSWVZNfClk29RcDTJQ76n8zZaiTGuUsi8sUhW8AS4PSbPKDm+\n"
|
||||
"DyJgdHDWdIF3HBzl7DHeFrILuqTs0vfS7Pa2NW8nUBwiaYQmPtwEa4n7bTmBVGsB\n"
|
||||
"1700/tz8wQWOLUlL2nMv+BPlDhxq4kmJCyJfgrIrHlX8sGPcPA4Y6Rwo0MSqYn3s\n"
|
||||
"g1Pu5gOKlaT9HKmE6wn5Sut6IiBjWozrRQ6n5h2RXNtO7O2qCDqjgB2vBxhV7B+z\n"
|
||||
"hRbLbCmW0tYMDsvPpX5M8fsO05svN+lKtCAuz1leFns8piZpptpSCFn7bWxiA9/f\n"
|
||||
"x5x17D7pfah3Sy2pA+NDXyzSlGcKdaUmwQIDAQAB\n"
|
||||
"-----END RSA PUBLIC KEY-----");
|
||||
serverPublicKeysFingerprints.push_back(0xb05b2a6f70cdea78LL);
|
||||
serverPublicKeys.push_back("-----BEGIN RSA PUBLIC KEY-----\n"
|
||||
"MIIBCgKCAQEAsQZnSWVZNfClk29RcDTJQ76n8zZaiTGuUsi8sUhW8AS4PSbPKDm+\n"
|
||||
"DyJgdHDWdIF3HBzl7DHeFrILuqTs0vfS7Pa2NW8nUBwiaYQmPtwEa4n7bTmBVGsB\n"
|
||||
"1700/tz8wQWOLUlL2nMv+BPlDhxq4kmJCyJfgrIrHlX8sGPcPA4Y6Rwo0MSqYn3s\n"
|
||||
"g1Pu5gOKlaT9HKmE6wn5Sut6IiBjWozrRQ6n5h2RXNtO7O2qCDqjgB2vBxhV7B+z\n"
|
||||
"hRbLbCmW0tYMDsvPpX5M8fsO05svN+lKtCAuz1leFns8piZpptpSCFn7bWxiA9/f\n"
|
||||
"x5x17D7pfah3Sy2pA+NDXyzSlGcKdaUmwQIDAQAB\n"
|
||||
"-----END RSA PUBLIC KEY-----");
|
||||
serverPublicKeysFingerprints.push_back(0xb05b2a6f70cdea78LL);
|
||||
|
||||
serverPublicKeys.push_back("-----BEGIN RSA PUBLIC KEY-----\n"
|
||||
"MIIBCgKCAQEAwqjFW0pi4reKGbkc9pK83Eunwj/k0G8ZTioMMPbZmW99GivMibwa\n"
|
||||
"xDM9RDWabEMyUtGoQC2ZcDeLWRK3W8jMP6dnEKAlvLkDLfC4fXYHzFO5KHEqF06i\n"
|
||||
"qAqBdmI1iBGdQv/OQCBcbXIWCGDY2AsiqLhlGQfPOI7/vvKc188rTriocgUtoTUc\n"
|
||||
"/n/sIUzkgwTqRyvWYynWARWzQg0I9olLBBC2q5RQJJlnYXZwyTL3y9tdb7zOHkks\n"
|
||||
"WV9IMQmZmyZh/N7sMbGWQpt4NMchGpPGeJ2e5gHBjDnlIf2p1yZOYeUYrdbwcS0t\n"
|
||||
"UiggS4UeE8TzIuXFQxw7fzEIlmhIaq3FnwIDAQAB\n"
|
||||
"-----END RSA PUBLIC KEY-----");
|
||||
serverPublicKeysFingerprints.push_back(0x71e025b6c76033e3LL);
|
||||
serverPublicKeys.push_back("-----BEGIN RSA PUBLIC KEY-----\n"
|
||||
"MIIBCgKCAQEAwqjFW0pi4reKGbkc9pK83Eunwj/k0G8ZTioMMPbZmW99GivMibwa\n"
|
||||
"xDM9RDWabEMyUtGoQC2ZcDeLWRK3W8jMP6dnEKAlvLkDLfC4fXYHzFO5KHEqF06i\n"
|
||||
"qAqBdmI1iBGdQv/OQCBcbXIWCGDY2AsiqLhlGQfPOI7/vvKc188rTriocgUtoTUc\n"
|
||||
"/n/sIUzkgwTqRyvWYynWARWzQg0I9olLBBC2q5RQJJlnYXZwyTL3y9tdb7zOHkks\n"
|
||||
"WV9IMQmZmyZh/N7sMbGWQpt4NMchGpPGeJ2e5gHBjDnlIf2p1yZOYeUYrdbwcS0t\n"
|
||||
"UiggS4UeE8TzIuXFQxw7fzEIlmhIaq3FnwIDAQAB\n"
|
||||
"-----END RSA PUBLIC KEY-----");
|
||||
serverPublicKeysFingerprints.push_back(0x71e025b6c76033e3LL);
|
||||
#endif
|
||||
|
||||
serverPublicKeys.push_back("-----BEGIN RSA PUBLIC KEY-----\n"
|
||||
"MIIBCgKCAQEAruw2yP/BCcsJliRoW5eBVBVle9dtjJw+OYED160Wybum9SXtBBLX\n"
|
||||
"riwt4rROd9csv0t0OHCaTmRqBcQ0J8fxhN6/cpR1GWgOZRUAiQxoMnlt0R93LCX/\n"
|
||||
"j1dnVa/gVbCjdSxpbrfY2g2L4frzjJvdl84Kd9ORYjDEAyFnEA7dD556OptgLQQ2\n"
|
||||
"e2iVNq8NZLYTzLp5YpOdO1doK+ttrltggTCy5SrKeLoCPPbOgGsdxJxyz5KKcZnS\n"
|
||||
"Lj16yE5HvJQn0CNpRdENvRUXe6tBP78O39oJ8BTHp9oIjd6XWXAsp2CvK45Ol8wF\n"
|
||||
"XGF710w9lwCGNbmNxNYhtIkdqfsEcwR5JwIDAQAB\n"
|
||||
"-----END RSA PUBLIC KEY-----");
|
||||
serverPublicKeysFingerprints.push_back(0xbc35f3509f7b7a5LL);
|
||||
serverPublicKeys.push_back("-----BEGIN RSA PUBLIC KEY-----\n"
|
||||
"MIIBCgKCAQEAruw2yP/BCcsJliRoW5eBVBVle9dtjJw+OYED160Wybum9SXtBBLX\n"
|
||||
"riwt4rROd9csv0t0OHCaTmRqBcQ0J8fxhN6/cpR1GWgOZRUAiQxoMnlt0R93LCX/\n"
|
||||
"j1dnVa/gVbCjdSxpbrfY2g2L4frzjJvdl84Kd9ORYjDEAyFnEA7dD556OptgLQQ2\n"
|
||||
"e2iVNq8NZLYTzLp5YpOdO1doK+ttrltggTCy5SrKeLoCPPbOgGsdxJxyz5KKcZnS\n"
|
||||
"Lj16yE5HvJQn0CNpRdENvRUXe6tBP78O39oJ8BTHp9oIjd6XWXAsp2CvK45Ol8wF\n"
|
||||
"XGF710w9lwCGNbmNxNYhtIkdqfsEcwR5JwIDAQAB\n"
|
||||
"-----END RSA PUBLIC KEY-----");
|
||||
serverPublicKeysFingerprints.push_back(0xbc35f3509f7b7a5LL);
|
||||
|
||||
serverPublicKeys.push_back("-----BEGIN RSA PUBLIC KEY-----\n"
|
||||
"MIIBCgKCAQEAvfLHfYH2r9R70w8prHblWt/nDkh+XkgpflqQVcnAfSuTtO05lNPs\n"
|
||||
"pQmL8Y2XjVT4t8cT6xAkdgfmmvnvRPOOKPi0OfJXoRVylFzAQG/j83u5K3kRLbae\n"
|
||||
"7fLccVhKZhY46lvsueI1hQdLgNV9n1cQ3TDS2pQOCtovG4eDl9wacrXOJTG2990V\n"
|
||||
"jgnIKNA0UMoP+KF03qzryqIt3oTvZq03DyWdGK+AZjgBLaDKSnC6qD2cFY81UryR\n"
|
||||
"WOab8zKkWAnhw2kFpcqhI0jdV5QaSCExvnsjVaX0Y1N0870931/5Jb9ICe4nweZ9\n"
|
||||
"kSDF/gip3kWLG0o8XQpChDfyvsqB9OLV/wIDAQAB\n"
|
||||
"-----END RSA PUBLIC KEY-----");
|
||||
serverPublicKeysFingerprints.push_back(0x15ae5fa8b5529542LL);
|
||||
serverPublicKeys.push_back("-----BEGIN RSA PUBLIC KEY-----\n"
|
||||
"MIIBCgKCAQEAvfLHfYH2r9R70w8prHblWt/nDkh+XkgpflqQVcnAfSuTtO05lNPs\n"
|
||||
"pQmL8Y2XjVT4t8cT6xAkdgfmmvnvRPOOKPi0OfJXoRVylFzAQG/j83u5K3kRLbae\n"
|
||||
"7fLccVhKZhY46lvsueI1hQdLgNV9n1cQ3TDS2pQOCtovG4eDl9wacrXOJTG2990V\n"
|
||||
"jgnIKNA0UMoP+KF03qzryqIt3oTvZq03DyWdGK+AZjgBLaDKSnC6qD2cFY81UryR\n"
|
||||
"WOab8zKkWAnhw2kFpcqhI0jdV5QaSCExvnsjVaX0Y1N0870931/5Jb9ICe4nweZ9\n"
|
||||
"kSDF/gip3kWLG0o8XQpChDfyvsqB9OLV/wIDAQAB\n"
|
||||
"-----END RSA PUBLIC KEY-----");
|
||||
serverPublicKeysFingerprints.push_back(0x15ae5fa8b5529542LL);
|
||||
|
||||
serverPublicKeys.push_back("-----BEGIN RSA PUBLIC KEY-----\n"
|
||||
"MIIBCgKCAQEAs/ditzm+mPND6xkhzwFIz6J/968CtkcSE/7Z2qAJiXbmZ3UDJPGr\n"
|
||||
"zqTDHkO30R8VeRM/Kz2f4nR05GIFiITl4bEjvpy7xqRDspJcCFIOcyXm8abVDhF+\n"
|
||||
"th6knSU0yLtNKuQVP6voMrnt9MV1X92LGZQLgdHZbPQz0Z5qIpaKhdyA8DEvWWvS\n"
|
||||
"Uwwc+yi1/gGaybwlzZwqXYoPOhwMebzKUk0xW14htcJrRrq+PXXQbRzTMynseCoP\n"
|
||||
"Ioke0dtCodbA3qQxQovE16q9zz4Otv2k4j63cz53J+mhkVWAeWxVGI0lltJmWtEY\n"
|
||||
"K6er8VqqWot3nqmWMXogrgRLggv/NbbooQIDAQAB\n"
|
||||
"-----END RSA PUBLIC KEY-----");
|
||||
serverPublicKeysFingerprints.push_back(0xaeae98e13cd7f94fLL);
|
||||
serverPublicKeys.push_back("-----BEGIN RSA PUBLIC KEY-----\n"
|
||||
"MIIBCgKCAQEAs/ditzm+mPND6xkhzwFIz6J/968CtkcSE/7Z2qAJiXbmZ3UDJPGr\n"
|
||||
"zqTDHkO30R8VeRM/Kz2f4nR05GIFiITl4bEjvpy7xqRDspJcCFIOcyXm8abVDhF+\n"
|
||||
"th6knSU0yLtNKuQVP6voMrnt9MV1X92LGZQLgdHZbPQz0Z5qIpaKhdyA8DEvWWvS\n"
|
||||
"Uwwc+yi1/gGaybwlzZwqXYoPOhwMebzKUk0xW14htcJrRrq+PXXQbRzTMynseCoP\n"
|
||||
"Ioke0dtCodbA3qQxQovE16q9zz4Otv2k4j63cz53J+mhkVWAeWxVGI0lltJmWtEY\n"
|
||||
"K6er8VqqWot3nqmWMXogrgRLggv/NbbooQIDAQAB\n"
|
||||
"-----END RSA PUBLIC KEY-----");
|
||||
serverPublicKeysFingerprints.push_back(0xaeae98e13cd7f94fLL);
|
||||
|
||||
serverPublicKeys.push_back("-----BEGIN RSA PUBLIC KEY-----\n"
|
||||
"MIIBCgKCAQEAvmpxVY7ld/8DAjz6F6q05shjg8/4p6047bn6/m8yPy1RBsvIyvuD\n"
|
||||
"uGnP/RzPEhzXQ9UJ5Ynmh2XJZgHoE9xbnfxL5BXHplJhMtADXKM9bWB11PU1Eioc\n"
|
||||
"3+AXBB8QiNFBn2XI5UkO5hPhbb9mJpjA9Uhw8EdfqJP8QetVsI/xrCEbwEXe0xvi\n"
|
||||
"fRLJbY08/Gp66KpQvy7g8w7VB8wlgePexW3pT13Ap6vuC+mQuJPyiHvSxjEKHgqe\n"
|
||||
"Pji9NP3tJUFQjcECqcm0yV7/2d0t/pbCm+ZH1sadZspQCEPPrtbkQBlvHb4OLiIW\n"
|
||||
"PGHKSMeRFvp3IWcmdJqXahxLCUS1Eh6MAQIDAQAB\n"
|
||||
"-----END RSA PUBLIC KEY-----");
|
||||
serverPublicKeysFingerprints.push_back(0x5a181b2235057d98LL);
|
||||
|
||||
}
|
||||
|
||||
serverPublicKeys.push_back("-----BEGIN RSA PUBLIC KEY-----\n"
|
||||
"MIIBCgKCAQEAvmpxVY7ld/8DAjz6F6q05shjg8/4p6047bn6/m8yPy1RBsvIyvuD\n"
|
||||
"uGnP/RzPEhzXQ9UJ5Ynmh2XJZgHoE9xbnfxL5BXHplJhMtADXKM9bWB11PU1Eioc\n"
|
||||
"3+AXBB8QiNFBn2XI5UkO5hPhbb9mJpjA9Uhw8EdfqJP8QetVsI/xrCEbwEXe0xvi\n"
|
||||
"fRLJbY08/Gp66KpQvy7g8w7VB8wlgePexW3pT13Ap6vuC+mQuJPyiHvSxjEKHgqe\n"
|
||||
"Pji9NP3tJUFQjcECqcm0yV7/2d0t/pbCm+ZH1sadZspQCEPPrtbkQBlvHb4OLiIW\n"
|
||||
"PGHKSMeRFvp3IWcmdJqXahxLCUS1Eh6MAQIDAQAB\n"
|
||||
"-----END RSA PUBLIC KEY-----");
|
||||
serverPublicKeysFingerprints.push_back(0x5a181b2235057d98LL);
|
||||
}
|
||||
|
||||
size_t count2 = serverPublicKeysFingerprints.size();
|
||||
for (uint32_t a = 0; a < count1; a++) {
|
||||
for (uint32_t b = 0; b < count2; b++) {
|
||||
if ((uint64_t) result->server_public_key_fingerprints[a] == serverPublicKeysFingerprints[b]) {
|
||||
keyFingerprint = result->server_public_key_fingerprints[a];
|
||||
for (uint32_t a = 0; a < count2; a++) {
|
||||
for (uint32_t b = 0; b < count1; b++) {
|
||||
if ((uint64_t) result->server_public_key_fingerprints[b] == serverPublicKeysFingerprints[a]) {
|
||||
keyFingerprint = result->server_public_key_fingerprints[b];
|
||||
key = serverPublicKeys[a];
|
||||
break;
|
||||
}
|
||||
@ -462,6 +481,8 @@ void Handshake::processHandshakeResponse(TLObject *message, int64_t messageId) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (LOGS_ENABLED) DEBUG_D("publicKey: %s, fingerprint: %lld",key.c_str(),keyFingerprint);
|
||||
|
||||
authServerNonce = new ByteArray(result->server_nonce.get());
|
||||
|
||||
uint64_t pq = ((uint64_t) (result->pq->bytes[0] & 0xff) << 56) |
|
||||
|
@ -33,6 +33,7 @@ public:
|
||||
ByteArray *getPendingAuthKey();
|
||||
int64_t getPendingAuthKeyId();
|
||||
TLObject *getCurrentHandshakeRequest();
|
||||
void clearServerPublicKey();
|
||||
|
||||
private:
|
||||
|
||||
@ -62,6 +63,7 @@ private:
|
||||
static void loadCdnConfig(Datacenter *datacenter);
|
||||
|
||||
inline Connection *getConnection();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user