/[winpt]/trunk/Src/wptSOCKS.cpp
ViewVC logotype

Diff of /trunk/Src/wptSOCKS.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 272 by twoaday, Sun Nov 5 08:57:45 2006 UTC revision 273 by twoaday, Fri Dec 8 10:22:17 2006 UTC
# Line 83  send_methods (int conn_fd) Line 83  send_methods (int conn_fd)
83      pkt[1] = 0x02;      pkt[1] = 0x02;
84      pkt[2] = METH_NOAUTH;      pkt[2] = METH_NOAUTH;
85      pkt[3] = METH_USERPASS;      pkt[3] = METH_USERPASS;
86      if (send (conn_fd, (const char*)pkt, 4, 0) == SOCKET_ERROR) {      if (send (conn_fd, (const char*)pkt, DIM (pkt), 0) == SOCKET_ERROR) {
87          log_debug ("send_methods failed ec=%d\n", (int)WSAGetLastError ());          log_debug ("send_methods failed ec=%d\n", (int)WSAGetLastError ());
88          return -1;          return -1;
89      }      }
# Line 97  recv_method (int conn_fd) Line 97  recv_method (int conn_fd)
97  {  {
98      BYTE pkt[2];      BYTE pkt[2];
99    
100      if (recv (conn_fd, (char*)pkt, 2, 0) == SOCKET_ERROR) {      if (recv (conn_fd, (char*)pkt, DIM (pkt), 0) == SOCKET_ERROR) {
101          log_debug ("recv_method failed ec=%d\n", (int)WSAGetLastError ());          log_debug ("recv_method failed ec=%d\n", (int)WSAGetLastError ());
102          return -1;          return -1;
103      }      }
# Line 205  send_connect_request (int conn_fd, const Line 205  send_connect_request (int conn_fd, const
205      pkt[7] = (BYTE)addr >>  0;      pkt[7] = (BYTE)addr >>  0;
206      pkt[8] = (BYTE)port >>  8;      pkt[8] = (BYTE)port >>  8;
207      pkt[9] = (BYTE)port >>  0;      pkt[9] = (BYTE)port >>  0;
208      if (send (conn_fd, (const char*)pkt, 9, 0) == SOCKET_ERROR) {      if (send (conn_fd, (const char*)pkt, 10, 0) == SOCKET_ERROR) {
209          log_debug ("send_connect_request failed ec=%d\n", (int)WSAGetLastError ());          log_debug ("send_connect_request failed ec=%d\n", (int)WSAGetLastError ());
210          return -1;          return -1;
211      }      }
# Line 230  recv_connect_reply (int conn_fd, int *er Line 230  recv_connect_reply (int conn_fd, int *er
230      int ndomain;      int ndomain;
231    
232      *err = 0;      *err = 0;
233      if (recv (conn_fd, (char*)pkt, 4, 0) == SOCKET_ERROR)      if (recv (conn_fd, (char*)pkt, DIM (pkt), 0) == SOCKET_ERROR) {
234            log_debug ("recv_connect_reply: recv() failed ec=%d\n",
235                        (int)WSAGetLastError ());
236          return -1;          return -1;
237        }
238      if (pkt[0] != 0x05 || pkt[2] != 0x00) {      if (pkt[0] != 0x05 || pkt[2] != 0x00) {
239          log_debug ("recv_connect_reply: protocol violation.\n");          log_debug ("recv_connect_reply: protocol violation.\n");
240          return -1;          return -1;
# Line 248  recv_connect_reply (int conn_fd, int *er Line 251  recv_connect_reply (int conn_fd, int *er
251      case ADDR_DOMAIN:      case ADDR_DOMAIN:
252          recv (conn_fd, (char*)addr, 1, 0);          recv (conn_fd, (char*)addr, 1, 0);
253          ndomain = addr[0];          ndomain = addr[0];
254            /* Ignore the output, just empty the socket buffer. */
255          while (ndomain-- > 0)          while (ndomain-- > 0)
256              recv (conn_fd, (char*)addr, 1, 0);              recv (conn_fd, (char*)addr, 1, 0);
257          break;          break;
258    
259      case ADDR_IPV6:      case ADDR_IPV6:
260          if ( recv (conn_fd, (char*)addr, 16, 0) == SOCKET_ERROR)          if (recv (conn_fd, (char*)addr, DIM (addr), 0) == SOCKET_ERROR)
261              return -1;              return -1;
262          break;          break;
263      }      }
264      if (recv (conn_fd, (char*)port, 2, 0) == SOCKET_ERROR)      if (recv (conn_fd, (char*)port, DIM (port), 0) == SOCKET_ERROR)
265          return -1;          return -1;
266      return 0;      return 0;
267  }  }
# Line 279  socks_handshake (keyserver_proxy_t ctx, Line 283  socks_handshake (keyserver_proxy_t ctx,
283      }      }
284      if (do_auth (conn_fd, method, ctx, &err)) {      if (do_auth (conn_fd, method, ctx, &err)) {
285          if (!err)          if (!err)
286              msg_box (NULL, _("Authentication failed or unspported"), _("SOCKS Proxy"), MB_ERR);              msg_box (NULL, _("Authentication failed or unspported"),
287                         _("SOCKS Proxy"), MB_ERR);
288          else          else
289              msg_box (NULL, socks_strerror (err), _("SOCKS Proxy"), MB_ERR);              msg_box (NULL, socks_strerror (err), _("SOCKS Proxy"), MB_ERR);
290          return -1;          return -1;
291      }      }
292      if (send_connect_request (conn_fd, hostname, port)) {      if (send_connect_request (conn_fd, hostname, port)) {
293          msg_box (NULL, _("Could not send SOCKS request"), _("SOCKS Proxy"), MB_ERR);          msg_box (NULL, _("Could not send SOCKS request"),
294                     _("SOCKS Proxy"), MB_ERR);
295          return -1;          return -1;
296      }      }
297      if (recv_connect_reply (conn_fd, &err)) {      if (recv_connect_reply (conn_fd, &err)) {
298          if (!err)          if (!err)
299              msg_box (NULL, _("Error while parsing SOCKS reply"), _("SOCKS Proxy"), MB_ERR);              msg_box (NULL, _("Error while parsing SOCKS reply"),
300                         _("SOCKS Proxy"), MB_ERR);
301          else          else
302              msg_box (NULL, socks_strerror (err), _("SOCKS Proxy"), MB_ERR);              msg_box (NULL, socks_strerror (err), _("SOCKS Proxy"), MB_ERR);
303          return -1;          return -1;

Legend:
Removed from v.272  
changed lines
  Added in v.273

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26