diff options
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/MSN/src/msn_auth.cpp | 8 | ||||
-rw-r--r-- | protocols/MSN/src/msn_proto.cpp | 2 | ||||
-rw-r--r-- | protocols/MSN/src/msn_proto.h | 1 | ||||
-rw-r--r-- | protocols/MSN/src/msn_threads.cpp | 58 | ||||
-rw-r--r-- | protocols/MSN/src/msn_ws.cpp | 57 | ||||
-rw-r--r-- | protocols/MSN/src/stdafx.h | 1 |
6 files changed, 34 insertions, 93 deletions
diff --git a/protocols/MSN/src/msn_auth.cpp b/protocols/MSN/src/msn_auth.cpp index 39d1d0cc98..0580831dc4 100644 --- a/protocols/MSN/src/msn_auth.cpp +++ b/protocols/MSN/src/msn_auth.cpp @@ -525,16 +525,16 @@ static void derive_key(BYTE* der, unsigned char* key, size_t keylen, unsigned ch BYTE* buf = (BYTE*)alloca(buflen);
unsigned int len;
- HMAC(EVP_sha1(), key, keylen, data, datalen, hash1, &len);
- HMAC(EVP_sha1(), key, keylen, hash1, MIR_SHA1_HASH_SIZE, hash3, &len);
+ HMAC(EVP_sha1(), key, (int)keylen, data, (int)datalen, hash1, &len);
+ HMAC(EVP_sha1(), key, (int)keylen, hash1, MIR_SHA1_HASH_SIZE, hash3, &len);
memcpy(buf, hash1, MIR_SHA1_HASH_SIZE);
memcpy(buf + MIR_SHA1_HASH_SIZE, data, datalen);
- HMAC(EVP_sha1(), key, keylen, buf, buflen, hash2, &len);
+ HMAC(EVP_sha1(), key, (int)keylen, buf, buflen, hash2, &len);
memcpy(buf, hash3, MIR_SHA1_HASH_SIZE);
memcpy(buf + MIR_SHA1_HASH_SIZE, data, datalen);
- HMAC(EVP_sha1(), key, keylen, buf, buflen, hash4, &len);
+ HMAC(EVP_sha1(), key, (int)keylen, buf, buflen, hash4, &len);
memcpy(der, hash2, MIR_SHA1_HASH_SIZE);
memcpy(der + MIR_SHA1_HASH_SIZE, hash4, 4);
diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp index 7cf5e8e644..d49f560c11 100644 --- a/protocols/MSN/src/msn_proto.cpp +++ b/protocols/MSN/src/msn_proto.cpp @@ -932,8 +932,6 @@ int CMsnProto::SetStatus(int iNewStatus) return 0;
}
- usingGateway = false;
-
int oldMode = m_iStatus;
m_iStatus = ID_STATUS_CONNECTING;
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldMode, m_iStatus);
diff --git a/protocols/MSN/src/msn_proto.h b/protocols/MSN/src/msn_proto.h index d323433591..53ce1aca40 100644 --- a/protocols/MSN/src/msn_proto.h +++ b/protocols/MSN/src/msn_proto.h @@ -148,7 +148,6 @@ struct CMsnProto : public PROTO<CMsnProto> ThreadData* msnNsThread;
bool msnLoggedIn;
- bool usingGateway;
char* msnExternalIP;
char* msnRegistration;
diff --git a/protocols/MSN/src/msn_threads.cpp b/protocols/MSN/src/msn_threads.cpp index aad945a171..94870e2a1f 100644 --- a/protocols/MSN/src/msn_threads.cpp +++ b/protocols/MSN/src/msn_threads.cpp @@ -38,19 +38,15 @@ void __cdecl CMsnProto::msn_keepAliveThread(void*) switch (WaitForSingleObject(hKeepAliveThreadEvt, msnPingTimeout * 1000)) {
case WAIT_TIMEOUT:
keepFlag = msnNsThread != nullptr;
- if (usingGateway)
- msnPingTimeout = 45;
- else {
- msnPingTimeout = 20;
+ msnPingTimeout = 20;
- if (msnNsThread) {
- if (lastMsgId)
- keepFlag = msnNsThread->sendPacketPayload("PNG", "CON", "\bLast-Msg-Id: %I64u\r\n\r\n", lastMsgId);
- else if (msnRegistration)
- keepFlag = msnNsThread->sendPacketPayload("PNG", "CON", "\b\r\n");
- else
- keepFlag = msnNsThread->sendPacket("PNG", "CON 0");
- }
+ if (msnNsThread) {
+ if (lastMsgId)
+ keepFlag = msnNsThread->sendPacketPayload("PNG", "CON", "\bLast-Msg-Id: %I64u\r\n\r\n", lastMsgId);
+ else if (msnRegistration)
+ keepFlag = msnNsThread->sendPacketPayload("PNG", "CON", "\b\r\n");
+ else
+ keepFlag = msnNsThread->sendPacket("PNG", "CON 0");
}
if (hHttpsConnection && (clock() - mHttpsTS) > 60 * CLOCKS_PER_SEC) {
@@ -123,44 +119,20 @@ void __cdecl CMsnProto::MSNServerThread(void* arg) *tPortDelim = '\0';
if ((tPortNumber = atoi(tPortDelim + 1)) == 0)
tPortNumber = -1;
- else if (usingGateway && !(tPortNumber == 80 || tPortNumber == 443))
- usingGateway = false;
}
}
- if (usingGateway) {
- if (info->mServer[0] == 0)
- mir_strcpy(info->mServer, MSN_DEFAULT_LOGIN_SERVER);
- else if (info->mIsMainThread)
- mir_strcpy(info->mGatewayIP, info->mServer);
-
- if (info->gatewayType)
- mir_strcpy(info->mGatewayIP, info->mServer);
- else {
- if (info->mGatewayIP[0] == 0 && db_get_static(NULL, m_szModuleName, "GatewayServer", info->mGatewayIP, sizeof(info->mGatewayIP)))
- mir_strcpy(info->mGatewayIP, MSN_DEFAULT_GATEWAY);
- }
- }
- else {
- if (info->mServer[0] == 0 && db_get_static(NULL, m_szModuleName, "DirectServer", info->mServer, sizeof(info->mServer)))
- mir_strcpy(info->mServer, MSN_DEFAULT_LOGIN_SERVER);
- }
+ if (info->mServer[0] == 0 && db_get_static(NULL, m_szModuleName, "DirectServer", info->mServer, sizeof(info->mServer)))
+ mir_strcpy(info->mServer, MSN_DEFAULT_LOGIN_SERVER);
NETLIBOPENCONNECTION tConn = { 0 };
tConn.cbSize = sizeof(tConn);
tConn.flags = NLOCF_V2;
tConn.timeout = 5;
+ tConn.flags = NLOCF_SSL;
+ tConn.szHost = info->mServer;
+ tConn.wPort = MSN_DEFAULT_PORT;
- if (usingGateway) {
- tConn.flags |= NLOCF_HTTPGATEWAY;
- tConn.szHost = info->mGatewayIP;
- tConn.wPort = MSN_DEFAULT_GATEWAY_PORT;
- }
- else {
- tConn.flags = NLOCF_SSL;
- tConn.szHost = info->mServer;
- tConn.wPort = MSN_DEFAULT_PORT;
- }
if (tPortNumber != -1)
tConn.wPort = (WORD)tPortNumber;
@@ -178,9 +150,6 @@ void __cdecl CMsnProto::MSNServerThread(void* arg) return;
}
- if (usingGateway)
- Netlib_SetPollingTimeout(info->s, info->mGatewayTimeout);
-
debugLogA("Connected with handle=%08X", info->s);
if (info->mType == SERVER_NOTIFICATION)
@@ -338,7 +307,6 @@ ThreadData* CMsnProto::MSN_GetThreadByConnection(HANDLE s) ThreadData::ThreadData()
{
memset(&mInitialContactWLID, 0, sizeof(ThreadData) - 2 * sizeof(STRLIST));
- mGatewayTimeout = 2;
resetTimeout();
hWaitEvent = CreateSemaphore(nullptr, 0, MSN_PACKETS_COMBINE, nullptr);
mData = (char*)mir_calloc((mDataSize = 8192) + 1);
diff --git a/protocols/MSN/src/msn_ws.cpp b/protocols/MSN/src/msn_ws.cpp index 4ffd68c685..54a45e2e19 100644 --- a/protocols/MSN/src/msn_ws.cpp +++ b/protocols/MSN/src/msn_ws.cpp @@ -29,11 +29,6 @@ int ThreadData::send(const char data[], size_t datalen) {
resetTimeout();
- if (proto->usingGateway) {
- mGatewayTimeout = 2;
- Netlib_SetPollingTimeout(s, mGatewayTimeout);
- }
-
int rlen = Netlib_Send(s, data, (int)datalen);
if (rlen == SOCKET_ERROR) {
// should really also check if sendlen is the same as datalen
@@ -57,7 +52,7 @@ bool ThreadData::isTimeout(void) bool res = false;
if (mIsMainThread)
- res = !proto->usingGateway;
+ res = true;
else if (mJoinedContactsWLID.getCount() <= 1 || mChatID[0] == 0)
res = true;
@@ -73,28 +68,25 @@ bool ThreadData::isTimeout(void) int ThreadData::recv(char* data, size_t datalen)
{
- if (!proto->usingGateway) {
- resetTimeout();
-
- NETLIBSELECT nls = {};
- nls.dwTimeout = 1000;
- nls.hReadConns[0] = s;
-
- for (;;) {
- int ret = Netlib_Select(&nls);
- if (ret < 0) {
- proto->debugLogA("Connection abortively closed, error %d", WSAGetLastError());
- return ret;
- }
- else if (ret == 0) {
- if (isTimeout()) return 0;
- }
- else
- break;
+ resetTimeout();
+
+ NETLIBSELECT nls = {};
+ nls.dwTimeout = 1000;
+ nls.hReadConns[0] = s;
+
+ for (;;) {
+ int ret = Netlib_Select(&nls);
+ if (ret < 0) {
+ proto->debugLogA("Connection abortively closed, error %d", WSAGetLastError());
+ return ret;
}
+ else if (ret == 0) {
+ if (isTimeout()) return 0;
+ }
+ else
+ break;
}
-LBL_RecvAgain:
int ret = Netlib_Recv(s, data, (int)datalen);
if (ret == 0) {
proto->debugLogA("Connection closed gracefully");
@@ -106,20 +98,5 @@ LBL_RecvAgain: return ret;
}
- if (proto->usingGateway) {
- if (ret == 1 && *data == 0) {
- if (sessionClosed || isTimeout()) return 0;
- if ((mGatewayTimeout += 2) > 20) mGatewayTimeout = 20;
-
- Netlib_SetPollingTimeout(s, mGatewayTimeout);
- goto LBL_RecvAgain;
- }
- else {
- resetTimeout();
- mGatewayTimeout = 1;
- Netlib_SetPollingTimeout(s, mGatewayTimeout);
- }
- }
-
return ret;
}
diff --git a/protocols/MSN/src/stdafx.h b/protocols/MSN/src/stdafx.h index bbc01ec445..e4b3b8e4fc 100644 --- a/protocols/MSN/src/stdafx.h +++ b/protocols/MSN/src/stdafx.h @@ -464,7 +464,6 @@ struct ThreadData //----| for gateways |----------------------------------------------------------------
char mSessionID[50]; // Gateway session ID
char mGatewayIP[80]; // Gateway IP address
- int mGatewayTimeout;
bool sessionClosed;
bool termPending;
bool gatewayType;
|