aboutsummaryrefslogtreecommitdiff
path: root/DnsQueryLog.h
Commit message (Collapse)AuthorAgeFilesLines
* Remove validity time constraint in DNS query logKen Chen2023-06-051-7/+2
| | | | | | | | | | | Carriers will use DNS query logs in tests. Removes log expiration time limit so logs persist long enough for 24 hour testing. Bug: 279596912 Bug: 231264474 Bug: 200748696 Test: atest resolv_unit_test:DnsQueryLogTest Change-Id: Ib98b16053d0386e98be370fa6138d667dfcb03c9
* Read DNS query log settings from system propertyKen Chen2023-06-051-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, we need to provide a special build of the image for carrier testing, so that we can find out which apps are using DNS queries when the device idle. In fact, DnsQueryLog already can dump the required information, but lacks the interface to set the number of records. The default number of records 200 may not be enough for a 24 hours idle test. This commit enables DNS resolver to read the record setting from system properties, which is limited to 0 ~ 10000. Dumping DnsQueryLog requires root permission. There is no privacy concern in production builds. Bug: 279596912 Bug: 231264474 Bug: 200748696 Test: Run script like this to trigger 400 DNS queries #!/bin/bash for ((i=1; i<=400; i++)) do hostname="http://example${i}.com" adb shell am start -a android.intent.action.VIEW -d "$hostname" sleep 1 done $adb root; chmod +x run_dns_queries.sh; ./run_dns_queries.sh $adb shell dumpsys dnsresolver querylog | grep time | wc -l 200 $adb shell setprop persist.net.dns_query_log_size 3 $adb reboot $adb root; chmod +x run_dns_queries.sh; ./run_dns_queries.sh $adb shell dumpsys dnsresolver querylog | grep time | wc -l 3 $adb shell setprop persist.net.dns_query_log_size 300 $adb reboot $adb root; chmod +x run_dns_queries.sh; ./run_dns_queries.sh $adb shell dumpsys dnsresolver querylog | grep time | wc -l 300 Change-Id: Ic8fbe7e3ec52e1901fea9962d1c7564152693fc3
* Add LockedRingBufferMike Yu2020-12-221-9/+7
| | | | | | | | | This is a refactor for DnsQueryLog. No functional behavior change. Bug: 79727473 Test: resolv_unit_test passed Test: adb shell dumpsys dnsresolver querylog Change-Id: Id9fc9b7868dab5861feda5ab2cb04759e7a34846
* Add unit tests for DnsQueryLogMike Yu2019-12-111-3/+10
| | | | | | | | Ensure the basic functions of DnsQueryLog work as expected. Bug: 139040977 Test: cd packages/modules/DnsResolver && atest Change-Id: I6b318beeed7ff5942e8d08474c354e48ebdac936
* Log DNS resolved answersMike Yu2019-12-111-0/+66
Introduce a thread-safe queue, DnsQueryLog, to log the DNS resolved answers which are not found in the cache. The sensitive data is masked in order not to reveal privacy information. The log can be shown only by "dumpsys dnsresolver querylog", and it can show only the most-recent-one-hour queries. Example output: DNS query log (last 60 minutes): time=17:27:09.262 netId=100 uid=10107 pid=3322 hostname=w*** answer=[2404:***, 216.***] (33ms) time=17:27:14.303 netId=100 uid=10097 pid=3363 hostname=w*** answer=[13.***] (21ms) Bug: 139040977 Test: cd packages/modules/DnsResolver && atest Test: "adb shell dumpsys dnsresolver querylog" passed Change-Id: I8d063f4ac920f41c4fbc77e60a3e3a919d9daa62