Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
/* the subnegotiation version */
pt->serv_buf[len++] = SOCKS_SUBNEGOTIATION_VERSION_1;
/* length of the user name */
pt->serv_buf[len++] = user_len;
/* user name */
strncpy((char *)&pt->serv_buf[len], wsi->vhost->socks_user,
context->pt_serv_buf_size - len);
len += user_len;
/* 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;
}
else if (type == SOCKS_MSG_CONNECT) {
size_t len_index = 0;
short net_num = 0;
char *net_buf = (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;
len_index = len;
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((short)wsi->c_port);
/* the port we tell SOCKS proxy to connect to */
pt->serv_buf[len++] = net_buf[0];
pt->serv_buf[len++] = net_buf[1];
/* the length of the address, excluding port */
pt->serv_buf[len_index] = strlen(wsi->u.hdr.stash->address);
}
*msg_len = len;
}
#endif