hlsdk

Proxy support for ac lol

Aug 15th, 2010
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. // proxy support for nawp's autisticube client
  2. // by uf ok
  3. //
  4. // at the moment this only supports TCP. which is what i'm pretty sure assaultcube uses
  5. // since its netcode sucks
  6. //
  7. // this is a new and improved version of old socks5 code i wrote circa 2006. the original
  8. // sucks ass so this new version should work a lot better.
  9. //
  10. // TODO:
  11. // - everything
  12. // - automatic fetching of proxy lists from certain locations
  13.  
  14. #include <stdio.h>
  15. #include <winsock.h>
  16.  
  17. typedef struct {
  18. IN_ADDR address;
  19. UINT16 port;
  20.  
  21. socks5pxy_t* nextproxy;
  22. } socks5pxy_t;
  23.  
  24. socks5pxy_t* firstproxy;
  25.  
  26. static BOOL DetokenizeProxy( const char * szInput, IN_ADDR* pAddress, UINT16* pPort ) {
  27.  
  28. // this should be the correct format or we will be dying a painful death
  29. // format is ip:port
  30.  
  31. char buffer[ 256 ];
  32.  
  33.  
  34. char* pPointerToPortSeparator = strchr( szInput, ':' );
  35. if (!pPointerToPortSeparator) {
  36. printf("Invalid proxy entry, skipping\n");
  37. return FALSE;
  38. }
  39.  
  40. // split it
  41. strncpy( buffer, szInput, ( pPointerToPortSeparator - szInput )
  42.  
  43. return FALSE;
  44. }
  45.  
  46. //
  47. // Socks5Init: Loads the proxy lists etc.
  48. //
  49. BOOL Socks5Init() {
  50. FILE * f = fopen("Socks5.txt", "r");
  51.  
  52. if (!f) return FALSE;
  53.  
  54. char buffer [ 1024 ];
  55.  
  56. while (!feof( f ) ) {
  57. fgets( buffer, 1024, f );
  58.  
  59. // ignore comments
  60. if (!strncmp( buffer, "//", 2 )) continue;
  61.  
  62. // parse this as an entry
  63. // TODO: Complete this
  64.  
  65. }
  66.  
  67. }
  68.  
  69. //
  70. // Socks5Test: Tests all proxies on the list.
  71. // All invalid proxies will be removed from the list, then the list
  72. // file will be saved.
  73. //
  74. void Socks5Test() {
  75.  
  76. }
  77.  
  78. // Opens a socket to a proxy.
  79. BOOL Socks5Connect( const char* szAddress, UINT32 dwPort ) {
  80.  
  81. // pick a random proxy from the list
  82.  
  83. // connect to it, and handshake.
  84. // we should also do checks to see if it supports UDP.
  85.  
  86.  
  87. return FALSE;
  88. }
Advertisement
Add Comment
Please, Sign In to add comment