Skip to content

Commit

Permalink
both: don't send udp 0 over wss
Browse files Browse the repository at this point in the history
  • Loading branch information
liudongmiao committed Apr 11, 2024
1 parent 47d4681 commit a5ec9ba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions common.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,10 @@ static void raw_forward_cb(struct bufferevent *raw, void *wss) {
}
total_size -= UDP_FRAME_LENGTH_SIZE;
payload_size = htons(payload_size);
if (payload_size == 0) {
LOGW("payload size is 0");
continue;
}
}
size = evbuffer_remove(src, wss_frame_data.buffer, payload_size);
if (size <= 0) {
Expand Down
4 changes: 4 additions & 0 deletions wss-proxy-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,10 @@ static void udp_read_cb_server(evutil_socket_t sock, short event, void *ctx) {
if ((size = udp_read(sock, &udp_frame, key.sockaddr, &(key.socklen))) < 0) {
break;
}
if (size == 0) {
LOGW("udp read empty from %d", get_port(key.sockaddr));
continue;
}
if ((data = init_udp_server(&key, context, sock, get_port(key.sockaddr))) == NULL) {
break;
}
Expand Down
4 changes: 4 additions & 0 deletions wss-proxy-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ static void udp_read_cb_client(evutil_socket_t sock, short event, void *ctx) {
if ((size = udp_read(sock, &udp_frame, (struct sockaddr *) &sockaddr, &socklen)) < 0) {
break;
}
if (size == 0) {
LOGW("udp read empty from %d", get_port((const struct sockaddr *) &sockaddr));
continue;
}
evbuffer_add(raw->input, &udp_frame, size + UDP_FRAME_LENGTH_SIZE);
event_add(&(raw->ev_read), &one_minute);
}
Expand Down

0 comments on commit a5ec9ba

Please sign in to comment.