diff options
author | George Hazan <ghazan@miranda.im> | 2017-01-13 17:47:33 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-01-13 17:47:33 +0300 |
commit | 20a9f536e44c3928ad8c3cf7a2959bce557dab8e (patch) | |
tree | 0b17f148a4155a1ead90bb106e21b3542f2572e0 /src/mir_app | |
parent | e145db68fb5b7d0682a4b2be0174cebfe47dd74e (diff) |
(wiping blood from hands) no more netlib services
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/src/mir_app.def | 10 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 10 | ||||
-rw-r--r-- | src/mir_app/src/netlib.cpp | 33 | ||||
-rw-r--r-- | src/mir_app/src/netlib.h | 14 | ||||
-rw-r--r-- | src/mir_app/src/netlibhttpproxy.cpp | 35 | ||||
-rw-r--r-- | src/mir_app/src/netlibopenconn.cpp | 10 | ||||
-rw-r--r-- | src/mir_app/src/netlibsock.cpp | 42 |
7 files changed, 77 insertions, 77 deletions
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 4e95863c9f..6a1827cab6 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -367,3 +367,13 @@ Netlib_GetMorePackets @367 Netlib_FreeHttpRequest @368
Netlib_AddressToString @369
Netlib_StringToAddress @370
+Netlib_Select @371
+Netlib_SelectEx @372
+Netlib_SendHttpRequest @373
+Netlib_SetStickyHeaders @374
+Netlib_SetPollingTimeout @375
+Netlib_GetSocket @376
+Netlib_StartSsl @377
+Netlib_GetConnectionInfo @378
+Netlib_GetMyIp @379
+Netlib_SetHttpProxyInfo @380
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index b274d440b7..5d65d1173e 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -367,3 +367,13 @@ Netlib_GetMorePackets @367 Netlib_FreeHttpRequest @368
Netlib_AddressToString @369
Netlib_StringToAddress @370
+Netlib_Select @371
+Netlib_SelectEx @372
+Netlib_SendHttpRequest @373
+Netlib_SetStickyHeaders @374
+Netlib_SetPollingTimeout @375
+Netlib_GetSocket @376
+Netlib_StartSsl @377
+Netlib_GetConnectionInfo @378
+Netlib_GetMyIp @379
+Netlib_SetHttpProxyInfo @380
diff --git a/src/mir_app/src/netlib.cpp b/src/mir_app/src/netlib.cpp index cecc32cb5b..fcde4a4056 100644 --- a/src/mir_app/src/netlib.cpp +++ b/src/mir_app/src/netlib.cpp @@ -123,7 +123,7 @@ static INT_PTR GetNetlibUserSettingInt(const char *szUserModule, const char *szS return dbv.dVal;
}
-static char *GetNetlibUserSettingString(const char *szUserModule, const char *szSetting)
+static char* GetNetlibUserSettingString(const char *szUserModule, const char *szSetting)
{
char *szRet = db_get_sa(NULL, szUserModule, szSetting);
if (szRet == NULL)
@@ -316,21 +316,21 @@ MIR_APP_DLL(int) Netlib_CloseHandle(HANDLE hNetlib) /////////////////////////////////////////////////////////////////////////////////////////
-static INT_PTR NetlibGetSocket(WPARAM wParam, LPARAM)
+MIR_APP_DLL(UINT_PTR) Netlib_GetSocket(HANDLE hConnection)
{
SOCKET s;
- if (wParam == 0) {
+ if (hConnection == 0) {
s = INVALID_SOCKET;
SetLastError(ERROR_INVALID_PARAMETER);
}
else {
WaitForSingleObject(hConnectionHeaderMutex, INFINITE);
- switch (GetNetlibHandleType((void*)wParam)) {
+ switch (GetNetlibHandleType(hConnection)) {
case NLH_CONNECTION:
- s = ((NetlibConnection*)wParam)->s;
+ s = ((NetlibConnection*)hConnection)->s;
break;
case NLH_BOUNDPORT:
- s = ((NetlibBoundPort*)wParam)->s;
+ s = ((NetlibBoundPort*)hConnection)->s;
break;
default:
s = INVALID_SOCKET;
@@ -344,17 +344,6 @@ static INT_PTR NetlibGetSocket(WPARAM wParam, LPARAM) /////////////////////////////////////////////////////////////////////////////////////////
-INT_PTR NetlibGetConnectionInfoSrv(WPARAM wParam, LPARAM lParam)
-{
- NetlibGetConnectionInfo((NetlibConnection*)wParam, (NETLIBCONNINFO*)lParam);
- return 0;
-}
-
-INT_PTR NetlibGetMyIp(WPARAM wParam, LPARAM)
-{
- return (INT_PTR)GetMyIp((unsigned)wParam);
-}
-
MIR_APP_DLL(HNETLIBUSER) Netlib_GetConnNlu(HANDLE hConn)
{
if (GetNetlibHandleType(hConn) != NLH_CONNECTION)
@@ -472,16 +461,6 @@ int LoadNetlibModule(void) hConnectionOpenMutex = connectionTimeout ? CreateMutex(NULL, FALSE, NULL) : NULL;
g_LastConnectionTick = GetTickCount();
- CreateServiceFunction(MS_NETLIB_SETHTTPPROXYINFO, NetlibHttpGatewaySetInfo);
- CreateServiceFunction(MS_NETLIB_SETSTICKYHEADERS, NetlibHttpSetSticky);
- CreateServiceFunction(MS_NETLIB_GETSOCKET, NetlibGetSocket);
- CreateServiceFunction(MS_NETLIB_SELECT, NetlibSelect);
- CreateServiceFunction(MS_NETLIB_SELECTEX, NetlibSelectEx);
- CreateServiceFunction(MS_NETLIB_SETPOLLINGTIMEOUT, NetlibHttpSetPollingTimeout);
- CreateServiceFunction(MS_NETLIB_STARTSSL, NetlibStartSsl);
- CreateServiceFunction(MS_NETLIB_GETCONNECTIONINFO, NetlibGetConnectionInfoSrv);
- CreateServiceFunction(MS_NETLIB_GETMYIP, NetlibGetMyIp);
-
hRecvEvent = CreateHookableEvent(ME_NETLIB_FASTRECV);
hSendEvent = CreateHookableEvent(ME_NETLIB_FASTSEND);
diff --git a/src/mir_app/src/netlib.h b/src/mir_app/src/netlib.h index 28c1b549d0..7bb9d08c38 100644 --- a/src/mir_app/src/netlib.h +++ b/src/mir_app/src/netlib.h @@ -225,10 +225,6 @@ int NetlibHttpGatewayRecv(NetlibConnection *nlc, char *buf, int len, int flags); int NetlibHttpGatewayPost(NetlibConnection *nlc, const char *buf, int len, int flags);
void HttpGatewayRemovePacket(NetlibConnection *nlc, int pck);
-INT_PTR NetlibHttpGatewaySetInfo(WPARAM wParam, LPARAM lParam);
-INT_PTR NetlibHttpSetPollingTimeout(WPARAM wParam, LPARAM lParam);
-INT_PTR NetlibHttpSetSticky(WPARAM wParam, LPARAM lParam);
-
// netliblog.c
void NetlibLogShowOptions(void);
void NetlibDumpData(NetlibConnection *nlc, PBYTE buf, int len, int sent, int flags);
@@ -241,7 +237,6 @@ int WaitUntilReadable(SOCKET s, DWORD dwTimeout, bool check = false); int WaitUntilWritable(SOCKET s, DWORD dwTimeout);
bool NetlibDoConnect(NetlibConnection *nlc);
bool NetlibReconnect(NetlibConnection *nlc);
-INT_PTR NetlibStartSsl(WPARAM wParam, LPARAM lParam);
// netlibopts.c
int NetlibOptInitialise(WPARAM wParam, LPARAM lParam);
@@ -252,15 +247,8 @@ void NetlibSaveUserSettingsStruct(const char *szSettingsModule, const NETLIBUSER #define NL_SELECT_WRITE 0x0002
#define NL_SELECT_ALL (NL_SELECT_READ+NL_SELECT_WRITE)
-INT_PTR NetlibSelect(WPARAM wParam, LPARAM lParam);
-INT_PTR NetlibSelectEx(WPARAM wParam, LPARAM lParam);
-
-void NetlibGetConnectionInfo(NetlibConnection* nlc, NETLIBCONNINFO *connInfo);
-NETLIBIPLIST* GetMyIp(unsigned flags);
-
// netlibupnp.c
-bool NetlibUPnPAddPortMapping(WORD intport, char *proto,
- WORD *extport, DWORD *extip, bool search);
+bool NetlibUPnPAddPortMapping(WORD intport, char *proto, WORD *extport, DWORD *extip, bool search);
void NetlibUPnPDeletePortMapping(WORD extport, char* proto);
void NetlibUPnPCleanup(void*);
void NetlibUPnPInit(void);
diff --git a/src/mir_app/src/netlibhttpproxy.cpp b/src/mir_app/src/netlibhttpproxy.cpp index f1535da21a..445193f1bd 100644 --- a/src/mir_app/src/netlibhttpproxy.cpp +++ b/src/mir_app/src/netlibhttpproxy.cpp @@ -243,6 +243,8 @@ int NetlibHttpGatewayPost(NetlibConnection *nlc, const char *buf, int len, int f return len;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
#define NETLIBHTTP_RETRYCOUNT 3
#define NETLIBHTTP_RETRYTIMEOUT 2000
@@ -353,6 +355,8 @@ int NetlibHttpGatewayRecv(NetlibConnection *nlc, char *buf, int len, int flags) return SOCKET_ERROR;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
int NetlibInitHttpConnection(NetlibConnection *nlc, NetlibUser *nlu, NETLIBOPENCONNECTION *nloc)
{
NETLIBHTTPREQUEST *nlhrReply = NULL;
@@ -398,14 +402,12 @@ int NetlibInitHttpConnection(NetlibConnection *nlc, NetlibUser *nlu, NETLIBOPENC return 1;
}
-INT_PTR NetlibHttpGatewaySetInfo(WPARAM wParam, LPARAM lParam)
-{
- NETLIBHTTPPROXYINFO *nlhpi = (NETLIBHTTPPROXYINFO*)lParam;
- NetlibConnection *nlc = (NetlibConnection*)wParam;
+/////////////////////////////////////////////////////////////////////////////////////////
- if (GetNetlibHandleType(nlc) != NLH_CONNECTION || nlhpi == NULL ||
- nlhpi->cbSize < (sizeof(NETLIBHTTPPROXYINFO) - sizeof(int)) ||
- nlhpi->szHttpPostUrl == NULL) {
+MIR_APP_DLL(int) Netlib_SetHttpProxyInfo(HANDLE hConnection, const NETLIBHTTPPROXYINFO *nlhpi)
+{
+ NetlibConnection *nlc = (NetlibConnection*)hConnection;
+ if (GetNetlibHandleType(nlc) != NLH_CONNECTION || nlhpi == NULL || nlhpi->szHttpPostUrl == NULL) {
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
@@ -414,7 +416,7 @@ INT_PTR NetlibHttpGatewaySetInfo(WPARAM wParam, LPARAM lParam) mir_free(nlc->nlhpi.szHttpPostUrl);
nlc->nlhpi.combinePackets = 1;
- memcpy(&nlc->nlhpi, nlhpi, min(nlhpi->cbSize, sizeof(*nlhpi)));
+ memcpy(&nlc->nlhpi, nlhpi, sizeof(*nlhpi));
if (nlc->nlhpi.combinePackets == 0)
nlc->nlhpi.combinePackets = 1;
@@ -423,23 +425,26 @@ INT_PTR NetlibHttpGatewaySetInfo(WPARAM wParam, LPARAM lParam) return 1;
}
-INT_PTR NetlibHttpSetSticky(WPARAM wParam, LPARAM lParam)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+MIR_APP_DLL(int) Netlib_SetStickyHeaders(HNETLIBUSER nlu, const char *szHeaders)
{
- NetlibUser *nu = (NetlibUser*)wParam;
- if (GetNetlibHandleType(nu) != NLH_USER)
+ if (GetNetlibHandleType(nlu) != NLH_USER)
return ERROR_INVALID_PARAMETER;
- replaceStr(nu->szStickyHeaders, (char*)lParam); // pointer is ours
+ replaceStr(nlu->szStickyHeaders, szHeaders); // pointer is ours
return 0;
}
-INT_PTR NetlibHttpSetPollingTimeout(WPARAM wParam, LPARAM lParam)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+MIR_APP_DLL(int) Netlib_SetPollingTimeout(HANDLE hConnection, int iTimeout)
{
- NetlibConnection *nlc = (NetlibConnection*)wParam;
+ NetlibConnection *nlc = (NetlibConnection*)hConnection;
if (GetNetlibHandleType(nlc) != NLH_CONNECTION)
return -1;
int oldTimeout = nlc->pollingTimeout;
- nlc->pollingTimeout = lParam;
+ nlc->pollingTimeout = iTimeout;
return oldTimeout;
}
diff --git a/src/mir_app/src/netlibopenconn.cpp b/src/mir_app/src/netlibopenconn.cpp index a044afba46..9d504b66ad 100644 --- a/src/mir_app/src/netlibopenconn.cpp +++ b/src/mir_app/src/netlibopenconn.cpp @@ -771,7 +771,7 @@ bool NetlibDoConnect(NetlibConnection *nlc) Netlib_Logf(nlu, "(%d) Connected to %s:%d", nlc->s, nloc->szHost, nloc->wPort); if (NLOCF_SSL & nloc->flags) - return NetlibStartSsl((WPARAM)nlc, 0) != 0; + return Netlib_StartSsl(nlc, 0) != 0; return true; } @@ -851,14 +851,14 @@ MIR_APP_DLL(HANDLE) Netlib_OpenConnection(NetlibUser *nlu, const NETLIBOPENCONNE return nlc; } -INT_PTR NetlibStartSsl(WPARAM wParam, LPARAM lParam) +MIR_APP_DLL(int) Netlib_StartSsl(HANDLE hConnection, const char *szHost) { - NetlibConnection *nlc = (NetlibConnection*)wParam; + NetlibConnection *nlc = (NetlibConnection*)hConnection; if (nlc == NULL) return 0; - NETLIBSSL *sp = (NETLIBSSL*)lParam; - const char *szHost = sp ? sp->host : nlc->nloc.szHost; + if (szHost == NULL) + szHost = nlc->nloc.szHost; Netlib_Logf(nlc->nlu, "(%d %s) Starting SSL negotiation", nlc->s, szHost); nlc->hSsl = sslApi.connect(nlc->s, szHost, nlc->nlu->settings.validateSSL); diff --git a/src/mir_app/src/netlibsock.cpp b/src/mir_app/src/netlibsock.cpp index e63ef33ef1..a920f7cd93 100644 --- a/src/mir_app/src/netlibsock.cpp +++ b/src/mir_app/src/netlibsock.cpp @@ -27,6 +27,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern HANDLE hConnectionHeaderMutex, hSendEvent, hRecvEvent;
+/////////////////////////////////////////////////////////////////////////////////////////
+
MIR_APP_DLL(int) Netlib_Send(HANDLE hConn, const char *buf, int len, int flags)
{
NetlibConnection *nlc = (NetlibConnection*)hConn;
@@ -56,6 +58,8 @@ MIR_APP_DLL(int) Netlib_Send(HANDLE hConn, const char *buf, int len, int flags) return result;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
MIR_APP_DLL(int) Netlib_Recv(HANDLE hConn, char *buf, int len, int flags)
{
NetlibConnection *nlc = (NetlibConnection*)hConn;
@@ -89,7 +93,9 @@ MIR_APP_DLL(int) Netlib_Recv(HANDLE hConn, char *buf, int len, int flags) return recvResult;
}
-static int ConnectionListToSocketList(HANDLE *hConns, fd_set *fd, int& pending)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static int ConnectionListToSocketList(const HANDLE *hConns, fd_set *fd, int& pending)
{
FD_ZERO(fd);
for (int i = 0; hConns[i] && hConns[i] != INVALID_HANDLE_VALUE && i < FD_SETSIZE; i++) {
@@ -105,10 +111,9 @@ static int ConnectionListToSocketList(HANDLE *hConns, fd_set *fd, int& pending) return 1;
}
-INT_PTR NetlibSelect(WPARAM, LPARAM lParam)
+MIR_APP_DLL(int) Netlib_Select(NETLIBSELECT *nls)
{
- NETLIBSELECT *nls = (NETLIBSELECT*)lParam;
- if (nls == NULL || nls->cbSize != sizeof(NETLIBSELECT)) {
+ if (nls == NULL) {
SetLastError(ERROR_INVALID_PARAMETER);
return SOCKET_ERROR;
}
@@ -133,10 +138,9 @@ INT_PTR NetlibSelect(WPARAM, LPARAM lParam) return select(0, &readfd, &writefd, &exceptfd, nls->dwTimeout == INFINITE ? NULL : &tv);
}
-INT_PTR NetlibSelectEx(WPARAM, LPARAM lParam)
+MIR_APP_DLL(int) Netlib_SelectEx(NETLIBSELECTEX *nls)
{
- NETLIBSELECTEX *nls = (NETLIBSELECTEX*)lParam;
- if (nls == NULL || nls->cbSize != sizeof(NETLIBSELECTEX)) {
+ if (nls == NULL) {
SetLastError(ERROR_INVALID_PARAMETER);
return SOCKET_ERROR;
}
@@ -190,6 +194,8 @@ INT_PTR NetlibSelectEx(WPARAM, LPARAM lParam) return rc;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
MIR_APP_DLL(bool) Netlib_StringToAddress(const char *str, SOCKADDR_INET_M *addr)
{
if (!str) return false;
@@ -216,9 +222,13 @@ MIR_APP_DLL(char*) Netlib_AddressToString(sockaddr_in *addr) return NULL;
}
-void NetlibGetConnectionInfo(NetlibConnection *nlc, NETLIBCONNINFO *connInfo)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+MIR_APP_DLL(int) Netlib_GetConnectionInfo(HANDLE hConnection, NETLIBCONNINFO *connInfo)
{
- if (!nlc || !connInfo || connInfo->cbSize < sizeof(NETLIBCONNINFO)) return;
+ NetlibConnection *nlc = (NetlibConnection*)hConnection;
+ if (!nlc || !connInfo)
+ return 1;
sockaddr_in sin = { 0 };
int len = sizeof(sin);
@@ -227,15 +237,18 @@ void NetlibGetConnectionInfo(NetlibConnection *nlc, NETLIBCONNINFO *connInfo) connInfo->dwIpv4 = sin.sin_family == AF_INET ? htonl(sin.sin_addr.s_addr) : 0;
strncpy_s(connInfo->szIpPort, ptrA(Netlib_AddressToString(&sin)), _TRUNCATE);
}
+ return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
inline bool IsAddrGlobal(const IN6_ADDR *a)
{
unsigned char High = a->s6_bytes[0] & 0xf0;
return High != 0 && High != 0xf0;
}
-static NETLIBIPLIST* GetMyIpv6(unsigned flags)
+MIR_APP_DLL(NETLIBIPLIST*) Netlib_GetMyIp(bool bGlobalOnly)
{
addrinfo *air = NULL, *ai, hints = { 0 };
const char *szMyHost = "";
@@ -249,7 +262,7 @@ static NETLIBIPLIST* GetMyIpv6(unsigned flags) unsigned n = 0;
for (ai = air; ai; ai = ai->ai_next) {
SOCKADDR_INET_M *iaddr = (SOCKADDR_INET_M*)ai->ai_addr;
- if (ai->ai_family == AF_INET || (ai->ai_family == AF_INET6 && (!(flags & 1) || IsAddrGlobal(&iaddr->Ipv6.sin6_addr))))
+ if (ai->ai_family == AF_INET || (ai->ai_family == AF_INET6 && (!bGlobalOnly || IsAddrGlobal(&iaddr->Ipv6.sin6_addr))))
++n;
}
@@ -259,7 +272,7 @@ static NETLIBIPLIST* GetMyIpv6(unsigned flags) unsigned i = 0;
for (ai = air; ai; ai = ai->ai_next) {
sockaddr_in6 *iaddr = (sockaddr_in6*)ai->ai_addr;
- if (ai->ai_family == AF_INET || (ai->ai_family == AF_INET6 && (!(flags & 1) || IsAddrGlobal(&iaddr->sin6_addr)))) {
+ if (ai->ai_family == AF_INET || (ai->ai_family == AF_INET6 && (!bGlobalOnly || IsAddrGlobal(&iaddr->sin6_addr)))) {
char *szIp = Netlib_AddressToString((sockaddr_in*)iaddr);
if (szIp)
strncpy_s(addr->szIp[i++], szIp, _TRUNCATE);
@@ -289,8 +302,3 @@ static NETLIBIPLIST* GetMyIpv4(void) return addr;
}
-
-NETLIBIPLIST* GetMyIp(unsigned flags)
-{
- return GetMyIpv6(flags);
-}
|