Skip to content
Snippets Groups Projects
client-handshake.c 27.1 KiB
Newer Older
  • Learn to ignore specific revisions
  • 		/* the subnegotiation version */
    		pt->serv_buf[len++] = SOCKS_SUBNEGOTIATION_VERSION_1;
    		/* length of the user name */
    
    		pt->serv_buf[len++] = n;
    
    		/* user name */
    		strncpy((char *)&pt->serv_buf[len], wsi->vhost->socks_user,
    			context->pt_serv_buf_size - len);
    
    		len += n;
    
    		/* length of the password */
    		pt->serv_buf[len++] = passwd_len;
    		/* password */
    		strncpy((char *)&pt->serv_buf[len], wsi->vhost->socks_password,
    			context->pt_serv_buf_size - len);
    		len += passwd_len;
    
    		break;
    
    	case SOCKS_MSG_CONNECT:
    		p = (char*)&net_num;
    
    
    		/* socks version */
    		pt->serv_buf[len++] = SOCKS_VERSION_5;
    		/* socks command */
    		pt->serv_buf[len++] = SOCKS_COMMAND_CONNECT;
    		/* reserved */
    		pt->serv_buf[len++] = 0;
    		/* address type */
    		pt->serv_buf[len++] = SOCKS_ATYP_DOMAINNAME;
    
    		/* skip length, we fill it in at the end */
    		n = len++;
    
    		/* the address we tell SOCKS proxy to connect to */
    		strncpy((char *)&(pt->serv_buf[len]), wsi->u.hdr.stash->address,
    			context->pt_serv_buf_size - len);
    		len += strlen(wsi->u.hdr.stash->address);
    
    		net_num = htons(wsi->c_port);
    
    		/* the port we tell SOCKS proxy to connect to */
    
    		pt->serv_buf[len++] = p[0];
    		pt->serv_buf[len++] = p[1];
    
    		/* the length of the address, excluding port */
    
    		pt->serv_buf[n] = strlen(wsi->u.hdr.stash->address);
    		break;
    		
    	default:
    		return;