Lines Matching defs:wsi
102 lws_socks5c_generate_msg(struct lws *wsi, enum socks_msg_type type,
105 struct lws_context *context = wsi->a.context;
106 struct lws_context_per_thread *pt = &context->pt[(int)wsi->tsi];
127 n = (ssize_t)strlen(wsi->a.vhost->socks_user);
128 passwd_len = (ssize_t)strlen(wsi->a.vhost->socks_password);
142 memcpy(p, wsi->a.vhost->socks_user, (size_t)n);
149 memcpy(p, wsi->a.vhost->socks_password, (size_t)passwd_len);
154 n = (ssize_t)strlen(wsi->stash->cis[CIS_ADDRESS]);
173 memcpy(p, wsi->stash->cis[CIS_ADDRESS], (size_t)n);
176 net_num = (short)htons(wsi->c_port);
219 * Returns 0 = nothing for caller to do, 1 = return wsi, -1 = goto failed
223 lws_socks5c_greet(struct lws *wsi, const char **pcce)
225 struct lws_context_per_thread *pt = &wsi->a.context->pt[(int)wsi->tsi];
230 if (!wsi->a.vhost->socks_proxy_port)
233 if (lws_socks5c_generate_msg(wsi, SOCKS_MSG_GREETING, &plen)) {
238 n = (int)send(wsi->desc.sockfd, (char *)pt->serv_buf, (size_t)plen,
241 lwsl_wsi_debug(wsi, "ERROR writing socks greeting");
246 lws_set_timeout(wsi, PENDING_TIMEOUT_AWAITING_SOCKS_GREETING_REPLY,
247 (int)wsi->a.context->timeout_secs);
249 lwsi_set_state(wsi, LRS_WAITING_SOCKS_GREETING_REPLY);
255 lws_socks5c_handle_state(struct lws *wsi, struct lws_pollfd *pollfd,
258 struct lws_context_per_thread *pt = &wsi->a.context->pt[(int)wsi->tsi];
266 lwsl_wsi_warn(wsi, "SOCKS fd=%d dead", pollfd->fd);
271 n = (int)recv(wsi->desc.sockfd, (void *)pt->serv_buf,
272 wsi->a.context->pt_serv_buf_size, 0);
275 lwsl_wsi_debug(wsi, "SOCKS read EAGAIN, retrying");
278 lwsl_wsi_err(wsi, "ERROR reading from SOCKS socket");
285 switch (lwsi_state(wsi)) {
292 lwsl_wsi_client(wsi, "SOCKS GR: No Auth Method");
293 if (lws_socks5c_generate_msg(wsi, SOCKS_MSG_CONNECT,
295 lwsl_wsi_err(wsi, "generate connect msg fail");
305 lwsl_wsi_client(wsi, "SOCKS GR: User/Pw Method");
306 if (lws_socks5c_generate_msg(wsi,
323 lwsl_wsi_client(wsi, "SOCKS password OK, sending connect");
324 if (lws_socks5c_generate_msg(wsi, SOCKS_MSG_CONNECT, &len)) {
334 n = (int)send(wsi->desc.sockfd, (char *)pt->serv_buf,
337 lwsl_wsi_debug(wsi, "ERROR writing to socks proxy");
342 lws_set_timeout(wsi, (enum pending_timeout)pending_timeout,
343 (int)wsi->a.context->timeout_secs);
344 lwsi_set_state(wsi, (lws_wsi_state_t)conn_mode);
348 lwsl_wsi_err(wsi, "socks reply: v%d, err %d",
358 lwsl_wsi_client(wsi, "socks connect OK");
361 if (lwsi_role_http(wsi) &&
362 lws_hdr_simple_create(wsi, _WSI_TOKEN_CLIENT_PEER_ADDRESS,
363 wsi->a.vhost->socks_proxy_address)) {
369 wsi->c_port = (uint16_t)wsi->a.vhost->socks_proxy_port;
372 lws_set_timeout(wsi, NO_PENDING_TIMEOUT, 0);