mirror of https://github.com/M66B/NetGuard.git
Native keep alive in established state only
This commit is contained in:
parent
81ee9a2614
commit
02f8abaf1c
|
@ -561,6 +561,7 @@ jboolean handle_tcp(const struct arguments *args,
|
|||
if (cur->keep_alive) {
|
||||
cur->keep_alive = 0;
|
||||
|
||||
if (cur->state == TCP_ESTABLISHED) {
|
||||
int on = 1;
|
||||
if (setsockopt(cur->socket, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on)))
|
||||
log_android(ANDROID_LOG_ERROR,
|
||||
|
@ -569,6 +570,7 @@ jboolean handle_tcp(const struct arguments *args,
|
|||
else
|
||||
log_android(ANDROID_LOG_WARN, "%s enabled keep alive", session);
|
||||
}
|
||||
}
|
||||
|
||||
// Do not change the order of the conditions
|
||||
|
||||
|
@ -666,6 +668,7 @@ jboolean handle_tcp(const struct arguments *args,
|
|||
uint32_t ack = ntohl(tcphdr->ack_seq);
|
||||
if ((uint32_t) (ack + 1) == cur->local_seq) {
|
||||
// Keep alive
|
||||
if (cur->state == TCP_ESTABLISHED) {
|
||||
int on = 1;
|
||||
if (setsockopt(cur->socket, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on)))
|
||||
log_android(ANDROID_LOG_ERROR,
|
||||
|
@ -673,6 +676,9 @@ jboolean handle_tcp(const struct arguments *args,
|
|||
session, errno, strerror(errno));
|
||||
else
|
||||
log_android(ANDROID_LOG_WARN, "%s enabled keep alive", session);
|
||||
}
|
||||
else
|
||||
log_android(ANDROID_LOG_WARN, "%s keep alive", session);
|
||||
|
||||
} else if (compare_u16(ack, cur->local_seq) < 0) {
|
||||
if (compare_u16(ack, cur->acked) <= 0)
|
||||
|
|
Loading…
Reference in New Issue