diff options
Diffstat (limited to 'plugins/!NotAdopted/Xfire/xfiretest/Xfire_proxy.cpp')
-rw-r--r-- | plugins/!NotAdopted/Xfire/xfiretest/Xfire_proxy.cpp | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/plugins/!NotAdopted/Xfire/xfiretest/Xfire_proxy.cpp b/plugins/!NotAdopted/Xfire/xfiretest/Xfire_proxy.cpp new file mode 100644 index 0000000000..35185defe1 --- /dev/null +++ b/plugins/!NotAdopted/Xfire/xfiretest/Xfire_proxy.cpp @@ -0,0 +1,103 @@ +#include "stdafx.h"
+
+#include "Xfire_proxy.h"
+
+extern HANDLE hNetlib;
+HANDLE hBindPort=NULL;
+HANDLE netlibcon=NULL;
+
+
+void FromServerToClient(LPVOID lParam) {
+ char buf[1024]={0};
+
+ HANDLE hConnection=(HANDLE)lParam;
+ do {
+ if(!hBindPort) return;
+
+ int cbRead = Netlib_Recv(netlibcon, buf, sizeof(buf), 0);
+ if( cbRead == SOCKET_ERROR)
+ break;
+
+ if(cbRead) {
+ Netlib_Send(hConnection, buf, cbRead, 0);
+ }
+ }
+ while(1);
+}
+
+//xfireclient baut verbindung auf
+void XfireclientConnecting(HANDLE hConnection, DWORD, void* extra )
+{
+ char buf[1024]={0};
+
+ //verbindung zum richtigen xfire server aufbauen
+ NETLIBOPENCONNECTION ncon = { 0 };
+ ncon.cbSize = sizeof(ncon);
+ ncon.szHost = "206.220.42.147";
+ ncon.wPort = (WORD)atol("25999");
+ ncon.timeout=5;
+ netlibcon = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) hNetlib, (LPARAM) & ncon);
+
+ if(!netlibcon) {
+ Netlib_CloseHandle(hConnection);
+ }
+
+ mir_forkthread(FromServerToClient,(LPVOID)hConnection);
+
+ //schleife behandelt empfangende daten
+ do {
+ int cbRead = Netlib_Recv(hConnection, buf, sizeof(buf), 0);
+ if( cbRead == SOCKET_ERROR)
+ {
+ Netlib_CloseHandle(hConnection);
+ Netlib_CloseHandle(netlibcon);
+ break;
+ }
+
+ if(cbRead) {
+ if(!Netlib_Send(netlibcon, buf, cbRead, 0))
+ {
+ Netlib_CloseHandle(hConnection);
+ Netlib_CloseHandle(netlibcon);
+ break;
+ }
+ }
+ }
+ while(1);
+}
+
+//inits nachdem alle module geladen wurden
+int AfterSystemModulesLoaded(WPARAM wParam,LPARAM lParam)
+{
+ //init netlib handle
+ NETLIBUSER nlu = {0};
+ nlu.cbSize = sizeof(nlu);
+ nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_INCOMING;
+ nlu.szSettingsModule = protocolname;
+ nlu.szDescriptiveName = "XFire server connection";
+ hNetlib = (HANDLE) CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM) & nlu);
+
+ //init socet server
+ NETLIBBIND nb = {0};
+ nb.cbSize = NETLIBBIND_SIZEOF_V2;
+ nb.pfnNewConnectionV2 = XfireclientConnecting;
+ nb.pExtra = NULL;
+ nb.wPort = 25999;
+ hBindPort = (HANDLE)CallService( MS_NETLIB_BINDPORT, (WPARAM)hNetlib,(LPARAM) &nb);
+
+
+ return 0;
+}
+
+int initXfireProxy() {
+ //inits nach dem alle module geladen wurden
+ HookEvent(ME_SYSTEM_MODULESLOADED, AfterSystemModulesLoaded);
+
+/* PROTOCOLDESCRIPTOR pd;
+ ZeroMemory(&pd,sizeof(pd));
+ pd.cbSize=sizeof(pd);
+ pd.szName=protocolname;
+ pd.type=PROTOTYPE_FILTER;
+ CallService(MS_PROTO_REGISTERMODULE,0,(LPARAM)&pd);*/
+ return 0;
+}
\ No newline at end of file |