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,13 +561,15 @@ jboolean handle_tcp(const struct arguments *args,
|
||||||
if (cur->keep_alive) {
|
if (cur->keep_alive) {
|
||||||
cur->keep_alive = 0;
|
cur->keep_alive = 0;
|
||||||
|
|
||||||
int on = 1;
|
if (cur->state == TCP_ESTABLISHED) {
|
||||||
if (setsockopt(cur->socket, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on)))
|
int on = 1;
|
||||||
log_android(ANDROID_LOG_ERROR,
|
if (setsockopt(cur->socket, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on)))
|
||||||
"%s setsockopt SO_KEEPALIVE error %d: %s",
|
log_android(ANDROID_LOG_ERROR,
|
||||||
session, errno, strerror(errno));
|
"%s setsockopt SO_KEEPALIVE error %d: %s",
|
||||||
else
|
session, errno, strerror(errno));
|
||||||
log_android(ANDROID_LOG_WARN, "%s enabled keep alive", session);
|
else
|
||||||
|
log_android(ANDROID_LOG_WARN, "%s enabled keep alive", session);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not change the order of the conditions
|
// Do not change the order of the conditions
|
||||||
|
@ -666,13 +668,17 @@ jboolean handle_tcp(const struct arguments *args,
|
||||||
uint32_t ack = ntohl(tcphdr->ack_seq);
|
uint32_t ack = ntohl(tcphdr->ack_seq);
|
||||||
if ((uint32_t) (ack + 1) == cur->local_seq) {
|
if ((uint32_t) (ack + 1) == cur->local_seq) {
|
||||||
// Keep alive
|
// Keep alive
|
||||||
int on = 1;
|
if (cur->state == TCP_ESTABLISHED) {
|
||||||
if (setsockopt(cur->socket, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on)))
|
int on = 1;
|
||||||
log_android(ANDROID_LOG_ERROR,
|
if (setsockopt(cur->socket, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on)))
|
||||||
"%s setsockopt SO_KEEPALIVE error %d: %s",
|
log_android(ANDROID_LOG_ERROR,
|
||||||
session, errno, strerror(errno));
|
"%s setsockopt SO_KEEPALIVE error %d: %s",
|
||||||
|
session, errno, strerror(errno));
|
||||||
|
else
|
||||||
|
log_android(ANDROID_LOG_WARN, "%s enabled keep alive", session);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
log_android(ANDROID_LOG_WARN, "%s enabled keep alive", session);
|
log_android(ANDROID_LOG_WARN, "%s keep alive", session);
|
||||||
|
|
||||||
} else if (compare_u16(ack, cur->local_seq) < 0) {
|
} else if (compare_u16(ack, cur->local_seq) < 0) {
|
||||||
if (compare_u16(ack, cur->acked) <= 0)
|
if (compare_u16(ack, cur->acked) <= 0)
|
||||||
|
|
Loading…
Reference in New Issue