Newer
Older
i.ssl_connection = ssl_connection;
i.path = path;
i.host = host;
i.origin = origin;
i.protocol = protocol;
i.ietf_version_or_minus_one = ietf_version_or_minus_one;
i.userdata = NULL;
return lws_client_connect_via_info(&i);
#if defined(LWS_WITH_SOCKS5)
void socks_generate_msg(struct lws *wsi, enum socks_msg_type type,
{
struct lws_context *context = wsi->context;
struct lws_context_per_thread *pt = &context->pt[(int)wsi->tsi];
ssize_t len = 0, n, passwd_len;
short net_num;
char *p;
switch (type) {
case SOCKS_MSG_GREETING:
/* socks version, version 5 only */
pt->serv_buf[len++] = SOCKS_VERSION_5;
/* number of methods */
pt->serv_buf[len++] = 2;
/* username password method */
pt->serv_buf[len++] = SOCKS_AUTH_USERNAME_PASSWORD;
/* no authentication method */
pt->serv_buf[len++] = SOCKS_AUTH_NO_AUTH;
case SOCKS_MSG_USERNAME_PASSWORD:
n = strlen(wsi->vhost->socks_user);
passwd_len = strlen(wsi->vhost->socks_password);
/* the subnegotiation version */
pt->serv_buf[len++] = SOCKS_SUBNEGOTIATION_VERSION_1;
/* length of the user name */
/* user name */
strncpy((char *)&pt->serv_buf[len], wsi->vhost->socks_user,
context->pt_serv_buf_size - 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;
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->stash->address,
/* 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 */