Skip to content

Commit

Permalink
client: when wss is not ready, just close it
Browse files Browse the repository at this point in the history
  • Loading branch information
liudongmiao committed Mar 22, 2024
1 parent 95afc7e commit e51c34c
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion common.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,21 @@ void raw_event_cb(struct bufferevent *raw, short event, void *wss) {
#ifdef WSS_PROXY_CLIENT
port = get_peer_port(raw);
#endif
#ifdef WSS_PROXY_SERVER
port = get_http_port(wss);
#endif
LOGD("connection %u closed for wss %p (won't send close), event: 0x%02x", port, wss, event);
bufferevent_free(raw);
evhttp_connection_free(wss);
}
}

static void raw_event_cb_wss(struct bufferevent *raw, short event, void *wss) {
uint16_t port;
if (event & (BEV_EVENT_EOF | BEV_EVENT_ERROR)) {
#ifdef WSS_PROXY_CLIENT
port = get_peer_port(raw);
#endif
#ifdef WSS_PROXY_SERVER
port = get_http_port(wss);
#endif
Expand Down Expand Up @@ -573,7 +588,7 @@ void tunnel_wss(struct bufferevent *raw, struct evhttp_connection *wss) {
#endif

bufferevent_enable(raw, EV_READ | EV_WRITE);
bufferevent_setcb(raw, raw_forward_cb, NULL, raw_event_cb, wss);
bufferevent_setcb(raw, raw_forward_cb, NULL, raw_event_cb_wss, wss);
}

#ifdef HAVE_SSL_CTX_SET_KEYLOG_CALLBACK
Expand Down

0 comments on commit e51c34c

Please sign in to comment.