Hosts file usually gets ignored on some ROMs due to SELinux restrictions if it is a symlink to file on different partition.
Technically it works by attaching to all packages/apps and hooking DNS resolution API. On first name resolution API call hosts file is read and stored in memory (in HPPC OpenHashMap structure).
Additional features of hosts file:
- use of IP address 127.0.0.0 allows to fail name resolution of associated hosts
- use of DNS names instead of IP addresses (these DNS names are passed directly to DNS resolver - they are not looked up in hosts file recursively)
- JNI libraries are not affected (some applications may still ignore hosts file)
- hosts file is read in memory of each application when it makes first DNS query (time and memory used depends on size of hosts file; time is logged in logcat with tag "hostsEnabler")
hosts Enabler uses HPPC: High Performance Primitive Collections for Java library which is distributed under Apache License 2.0.
This mod requires Xposed framework to be set up and hosts Enabler enabled as Xposed module.
Disclaimer: I am not responsible for anything that may happen as a result of using this mod.
Xposed Module Repository page:
For changelog see next post, for download links see downloads section.
hosts Enabler, Xposed for all devices (see above for details)
Xposed Package Name: lv.id.dm.hostsenabler
Current Stable Version: 1.0
Stable Release Date: 2014-08-30
Last Updated 2014-08-31