Skip to content

Commit

Permalink
Drop packet if out of buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
madeye committed Feb 7, 2021
1 parent 06f7663 commit db1dafb
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions tun2socks/SocksUdpGwClient.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,28 +616,17 @@ void SocksUdpGwClient_SubmitPacket (SocksUdpGwClient *o, BAddr local_addr, BAddr
if (!con) {
// create new connection
con = connection_init(o, conaddr, data, data_len, is_dns);

} else {
// move connection to front of the list
LinkedList1_Remove(&o->connections_list, &con->connections_list_node);
LinkedList1_Append(&o->connections_list, &con->connections_list_node);

// reset the connection
reset_connection(o, con, conaddr, is_dns);

// send packet to existing connection
int res = connection_send(con, data, data_len);
if (res == 1) {
BLog(BLOG_ERROR, "The current UDP connection is broken, recreating a new one");

// free broken connection
connection_free(con);

// create new connection
con = connection_init(o, conaddr, data, data_len, is_dns);
} else {
// remove connection from list
LinkedList1_Remove(&o->connections_list, &con->connections_list_node);

// move connection to front of the list
LinkedList1_Append(&o->connections_list, &con->connections_list_node);
}
// drop the packet if out of buffer
connection_send(con, data, data_len);
}
#else
// submit to udpgw client
Expand Down

0 comments on commit db1dafb

Please sign in to comment.