mirror of
https://github.com/M66B/NetGuard.git
synced 2025-01-04 06:23:04 +00:00
Fallback to source port only on last try finding uid
This commit is contained in:
parent
c570daca8f
commit
19deabe342
2 changed files with 8 additions and 7 deletions
|
@ -372,7 +372,7 @@ jint get_uid_retry(const int version, const int protocol,
|
||||||
|
|
||||||
jint get_uid(const int version, const int protocol,
|
jint get_uid(const int version, const int protocol,
|
||||||
const void *saddr, const uint16_t sport,
|
const void *saddr, const uint16_t sport,
|
||||||
int dump) {
|
int lasttry) {
|
||||||
char line[250];
|
char line[250];
|
||||||
char hex[16 * 2 + 1];
|
char hex[16 * 2 + 1];
|
||||||
int fields;
|
int fields;
|
||||||
|
@ -402,10 +402,10 @@ jint get_uid(const int version, const int protocol,
|
||||||
else
|
else
|
||||||
return uid;
|
return uid;
|
||||||
|
|
||||||
if (dump) {
|
if (lasttry) {
|
||||||
char source[INET6_ADDRSTRLEN + 1];
|
char source[INET6_ADDRSTRLEN + 1];
|
||||||
inet_ntop(version == 4 ? AF_INET : AF_INET6, saddr, source, sizeof(source));
|
inet_ntop(version == 4 ? AF_INET : AF_INET6, saddr, source, sizeof(source));
|
||||||
log_android(ANDROID_LOG_INFO, "Searching %s/%u in %s", source, sport, fn);
|
log_android(ANDROID_LOG_WARN, "Searching %s/%u in %s", source, sport, fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open proc file
|
// Open proc file
|
||||||
|
@ -442,16 +442,17 @@ jint get_uid(const int version, const int protocol,
|
||||||
for (int w = 0; w < 4; w++)
|
for (int w = 0; w < 4; w++)
|
||||||
((uint32_t *) addr6)[w] = htonl(((uint32_t *) addr6)[w]);
|
((uint32_t *) addr6)[w] = htonl(((uint32_t *) addr6)[w]);
|
||||||
|
|
||||||
if (dump) {
|
if (lasttry) {
|
||||||
char source[INET6_ADDRSTRLEN + 1];
|
char source[INET6_ADDRSTRLEN + 1];
|
||||||
inet_ntop(version == 4 ? AF_INET : AF_INET6,
|
inet_ntop(version == 4 ? AF_INET : AF_INET6,
|
||||||
version == 4 ? addr4 : addr6,
|
version == 4 ? addr4 : addr6,
|
||||||
source, sizeof(source));
|
source, sizeof(source));
|
||||||
log_android(ANDROID_LOG_INFO, "%s/%u %d %s", source, port, u, line);
|
log_android(ANDROID_LOG_WARN, "%s/%u %d %s", source, port, u, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (port == sport &&
|
if (port == sport &&
|
||||||
memcmp(version == 4 ? addr4 : addr6, saddr, version == 4 ? 4 : 16) == 0) {
|
(lasttry ||
|
||||||
|
memcmp(version == 4 ? addr4 : addr6, saddr, version == 4 ? 4 : 16) == 0)) {
|
||||||
uid = u;
|
uid = u;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -457,7 +457,7 @@ jint get_uid_retry(const int version, const int protocol,
|
||||||
|
|
||||||
jint get_uid(const int version, const int protocol,
|
jint get_uid(const int version, const int protocol,
|
||||||
const void *saddr, const uint16_t sport,
|
const void *saddr, const uint16_t sport,
|
||||||
int dump);
|
int lasttry);
|
||||||
|
|
||||||
int protect_socket(const struct arguments *args, int socket);
|
int protect_socket(const struct arguments *args, int socket);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue