1
0
Fork 0
mirror of https://github.com/M66B/NetGuard.git synced 2025-02-26 16:13:01 +00:00

Native delay get uid, reduce logging

This commit is contained in:
M66B 2016-01-20 10:27:18 +01:00
parent 28a6f1d935
commit 17772a9c45
2 changed files with 8 additions and 5 deletions

View file

@ -693,8 +693,9 @@ void handle_ip(const struct arguments *args, int usock, const uint8_t *buffer,
// Get uid // Get uid
jint uid = -1; jint uid = -1;
if ((protocol == IPPROTO_TCP && (!args->filter || syn)) || protocol == IPPROTO_UDP) { if ((protocol == IPPROTO_TCP && (!args->filter || syn)) || protocol == IPPROTO_UDP) {
log_android(ANDROID_LOG_INFO, "get uid %s/%u syn %d", dest, dport, syn); log_android(ANDROID_LOG_DEBUG, "get uid %s/%u syn %d", dest, dport, syn);
int tries = 0; int tries = 0;
usleep(1000 * UID_DELAY);
while (uid < 0 && tries++ < UID_MAXTRY) { while (uid < 0 && tries++ < UID_MAXTRY) {
// Check IPv6 table first // Check IPv6 table first
if (version == 4) { if (version == 4) {
@ -711,8 +712,9 @@ void handle_ip(const struct arguments *args, int usock, const uint8_t *buffer,
// Retry delay // Retry delay
if (uid < 0 && tries < UID_MAXTRY) { if (uid < 0 && tries < UID_MAXTRY) {
log_android(ANDROID_LOG_WARN, "get uid try %d", tries); log_android(ANDROID_LOG_WARN, "get uid %s/%u syn %d try %d",
usleep(1000 * UID_DELAY); dest, dport, syn, tries);
usleep(1000 * UID_DELAYTRY);
} }
} }
@ -816,7 +818,7 @@ jboolean handle_tcp(const struct arguments *args, const uint8_t *buffer, uint16_
uint8_t tcpoptlen = (tcphdr->doff - 5) * 4; uint8_t tcpoptlen = (tcphdr->doff - 5) * 4;
if (tcpoptlen) { if (tcpoptlen) {
// TODO handle TCP options // TODO handle TCP options
log_android(ANDROID_LOG_INFO, "optlen %d", tcpoptlen); log_android(ANDROID_LOG_DEBUG, "optlen %d", tcpoptlen);
} }
// Get data // Get data

View file

@ -9,7 +9,8 @@
#define TCP_CLOSE_TIMEOUT 30 #define TCP_CLOSE_TIMEOUT 30
#define TCP_TTL 64 #define TCP_TTL 64
#define TCP_WINDOW 32768 #define TCP_WINDOW 32768
#define UID_DELAY 10 // milliseconds #define UID_DELAY 1 // milliseconds
#define UID_DELAYTRY 10 // milliseconds
#define UID_MAXTRY 3 #define UID_MAXTRY 3
#define MAX_PCAP 80 #define MAX_PCAP 80