static int handle_state_tcp_connected(mspool *nsp, msevent *nse, void *udata) { struct proxy_chain_context *px_ctx = nse->iod->px_ctx; char *res; int reslen; res = nse_readbuf(nse, &reslen); /* TODO string check!! */ if (!((reslen >= 15) && strstr(res, "200 OK"))) { struct proxy_node *node; node = proxy_ctx_node_current(px_ctx); nsock_log_debug(nsp, "Connection refused from proxy %s", node->nodestr); return -EINVAL; } px_ctx->px_state = PROXY_STATE_HTTP_TUNNEL_ESTABLISHED; if (px_ctx->px_current->next == NULL) { forward_event(nsp, nse, udata); } else { px_ctx->px_current = px_ctx->px_current->next; px_ctx->px_state = PROXY_STATE_INITIAL; nsock_proxy_ev_dispatch(nsp, nse, udata); } return 0; }
void nsock_proxy_ev_dispatch(nsock_pool nspool, nsock_event nsevent, void *udata) { msevent *nse = (msevent *)nsevent; if (nse->status == NSE_STATUS_SUCCESS) { struct proxy_node *current; current = proxy_ctx_node_current(nse->iod->px_ctx); assert(current); current->spec->ops->handler(nspool, nsevent, udata); } else { forward_event(nspool, nsevent, udata); } }