├── META-INF
└── com
│ └── google
│ └── android
│ ├── updater-script
│ └── update-binary
├── system
└── placeholder
├── module.prop
├── .gitattributes
├── .gitignore
├── common
├── system.prop
├── service.sh
└── post-fs-data.sh
├── README.md
└── install.sh
/META-INF/com/google/android/updater-script:
--------------------------------------------------------------------------------
1 | #MAGISK
2 |
--------------------------------------------------------------------------------
/system/placeholder:
--------------------------------------------------------------------------------
1 | This file will be deleted in Magisk Manager, it is only a placeholder for git
2 |
--------------------------------------------------------------------------------
/module.prop:
--------------------------------------------------------------------------------
1 | id=magisk-google-dns
2 | name=Magisk Google DNS
3 | version=v11
4 | versionCode=11
5 | author=tfae
6 | description=Use Google's DNS servers instead of the provided by the ISP
7 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Declare files that will always have LF line endings on checkout.
2 | META-INF/** text eol=lf
3 | *.prop text eol=lf
4 | *.sh text eol=lf
5 | *.md text eol=lf
6 |
7 | # Denote all files that are truly binary and should not be modified.
8 | system/** binary
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | #
4 |
5 | # If you find yourself ignoring temporary files generated by your text editor
6 |
7 | # or operating system, you probably want to add a global ignore instead:
8 |
9 | # git config --global core.excludesfile '~/.gitignore_global'
10 |
11 |
12 |
13 | # Ignore zipped module
14 |
15 | /*.zip
--------------------------------------------------------------------------------
/common/system.prop:
--------------------------------------------------------------------------------
1 | # This file will be read by resetprop
2 | # Example: Change dpi
3 | # ro.sf.lcd_density=320
4 |
5 | net.eth0.dns1=8.8.8.8
6 | net.eth0.dns2=8.8.4.4
7 |
8 | net.dns1=8.8.8.8
9 | net.dns2=8.8.4.4
10 |
11 | net.ppp0.dns1=8.8.8.8
12 | net.ppp0.dns2=8.8.4.4
13 |
14 | net.rmnet0.dns1=8.8.8.8
15 | net.rmnet0.dns2=8.8.4.4
16 |
17 | net.rmnet1.dns1=8.8.8.8
18 | net.rmnet1.dns2=8.8.4.4
19 |
20 | net.pdpbr1.dns1=8.8.8.8
21 | net.pdpbr1.dns2=8.8.4.4
22 |
--------------------------------------------------------------------------------
/common/service.sh:
--------------------------------------------------------------------------------
1 | #!/system/bin/sh
2 | # Do NOT assume where your module will be located.
3 | # ALWAYS use $MODDIR if you need to know where this script
4 | # and module is placed.
5 | # This will make sure your module will still work
6 | # if Magisk change its mount point in the future
7 | MODDIR=${0%/*}
8 |
9 | # This script will be executed in late_start service mode
10 |
11 | iptables -t nat -A OUTPUT -p tcp --dport 53 -j DNAT --to-destination 8.8.8.8:53
12 | iptables -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to-destination 8.8.4.4:53
13 | iptables -t nat -I OUTPUT -p tcp --dport 53 -j DNAT --to-destination 8.8.8.8:53
14 | iptables -t nat -I OUTPUT -p udp --dport 53 -j DNAT --to-destination 8.8.4.4:53
15 |
--------------------------------------------------------------------------------
/common/post-fs-data.sh:
--------------------------------------------------------------------------------
1 | #!/system/bin/sh
2 | # Do NOT assume where your module will be located.
3 | # ALWAYS use $MODDIR if you need to know where this script
4 | # and module is placed.
5 | # This will make sure your module will still work
6 | # if Magisk change its mount point in the future
7 | MODDIR=${0%/*}
8 |
9 | # This script will be executed in post-fs-data mode
10 |
11 | # Set CF DNS servers address
12 | setprop net.eth0.dns1 8.8.8.8
13 | setprop net.eth0.dns2 8.8.4.4
14 |
15 | setprop net.dns1 8.8.8.8
16 | setprop net.dns2 8.8.4.4
17 |
18 | setprop net.ppp0.dns1 8.8.8.8
19 | setprop net.ppp0.dns2 8.8.4.4
20 |
21 | setprop net.rmnet0.dns1 8.8.8.8
22 | setprop net.rmnet0.dns2 8.8.4.4
23 |
24 | setprop net.rmnet1.dns1 8.8.8.8
25 | setprop net.rmnet1.dns2 8.8.4.4
26 |
27 | setprop net.pdpbr1.dns1 8.8.8.8
28 | setprop net.pdpbr1.dns2 8.8.4.4
29 |
30 |
31 |
32 |
33 | # Edit the resolv conf file if it exist
34 |
35 | if [ -a /system/etc/resolv.conf ]; then
36 | mkdir -p $MODDIR/system/etc/
37 | printf "nameserver 8.8.8.8\nnameserver 8.8.4.4" >> $MODDIR/system/etc/resolv.conf
38 | chmod 644 $MODDIR/system/etc/resolv.conf
39 | fi
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Magisk Google DNS
2 | ==========
3 |
4 | This module makes your device to use Google's DNS servers instead of the provided by the ISP:
5 | * 8.8.8.8
6 | * 8.8.4.4
7 |
8 |
9 | It is not guaranteed to work on cellular networks on all devices. Some users/testers say yes, others say that it doesn't.
10 | On Wi-Fi it always works though.
11 |
12 | If you know how to make it always work on cellular networks and want to contribute, please do!
13 |
14 |
15 | ## Changelog
16 | * v11 (06.05.2019) - Update to Magisk v18100 template
17 | * v10 (20.11.2018) - Remove IPv6: it is not supported on this module
18 | * v9 (18.11.2018) - Add IPv6
19 | * v8 (18.11.2018) - Make the version to be the same as the versionCode
20 | * v2.1.3 (05.09.2018) - Update to Magisk v17000 template
21 | * v2.1.2 (01.06.2018) - Cleanup config.sh
22 | * v2.1.1 (23.03.2018) - Added some clarification about cellular networks and credits to @teohhanhui
23 | * v2.1 (29.12.2017) - Update to Magisk template v1500
24 | * v2.0 (28.12.2017) - Use iptables rules (works on cellular networks on some devices) [thanks @teohhanhui]
25 | * v1.1 (11.12.2017) - Disable not needed Magic Mount (fix bootloops)
26 | * v1.0 (23.11.2017) - Initial release
27 |
28 |
29 | ## Notice
30 | * Take a full backup before installing the module.
31 | * You should use latest Magisk Manager to install this module. If you meet any problem under installation from Magisk Manager, please try to install it from recovery.
32 |
33 |
34 | ## Links
35 | * [](https://forum.xda-developers.com/apps/magisk/magisk-magisk-google-dns-v8-t3868528)
36 | * [](https://forum.xda-developers.com/apps/magisk/official-magisk-v7-universal-systemless-t3473445)
37 |
38 |
39 | ## Credits
40 | * topjohnwu@xda for developing Magisk
41 | * teohhanhui@xda for the iptables rules
42 |
43 |
44 | Copyright (C) 2017-2019 tfae@xda (tfaeusebio@gmail.com)
45 |
--------------------------------------------------------------------------------
/META-INF/com/google/android/update-binary:
--------------------------------------------------------------------------------
1 | #!/sbin/sh
2 |
3 | TMPDIR=/dev/tmp
4 | MOUNTPATH=/dev/magisk_img
5 |
6 | # Default permissions
7 | umask 022
8 |
9 | # Initial cleanup
10 | rm -rf $TMPDIR 2>/dev/null
11 | mkdir -p $TMPDIR
12 |
13 | # echo before loading util_functions
14 | ui_print() { echo "$1"; }
15 |
16 | require_new_magisk() {
17 | ui_print "***********************************"
18 | ui_print " Please install the latest Magisk! "
19 | ui_print "***********************************"
20 | exit 1
21 | }
22 |
23 | imageless_magisk() {
24 | [ $MAGISK_VER_CODE -gt 18100 ]
25 | return $?
26 | }
27 |
28 | ##########################################################################################
29 | # Environment
30 | ##########################################################################################
31 |
32 | OUTFD=$2
33 | ZIPFILE=$3
34 |
35 | mount /data 2>/dev/null
36 |
37 | # Load utility functions
38 | if [ -f /data/adb/magisk/util_functions.sh ]; then
39 | . /data/adb/magisk/util_functions.sh
40 | NVBASE=/data/adb
41 | else
42 | require_new_magisk
43 | fi
44 |
45 | # Preperation for flashable zips
46 | setup_flashable
47 |
48 | # Mount partitions
49 | mount_partitions
50 |
51 | # Detect version and architecture
52 | api_level_arch_detect
53 |
54 | # Setup busybox and binaries
55 | $BOOTMODE && boot_actions || recovery_actions
56 |
57 | ##########################################################################################
58 | # Preparation
59 | ##########################################################################################
60 |
61 | # Extract common files
62 | unzip -oj "$ZIPFILE" module.prop install.sh uninstall.sh 'common/*' -d $TMPDIR >&2
63 |
64 | [ ! -f $TMPDIR/install.sh ] && abort "! Unable to extract zip file!"
65 | # Load install script
66 | . $TMPDIR/install.sh
67 |
68 | if imageless_magisk; then
69 | $BOOTMODE && MODDIRNAME=modules_update || MODDIRNAME=modules
70 | MODULEROOT=$NVBASE/$MODDIRNAME
71 | else
72 | $BOOTMODE && IMGNAME=magisk_merge.img || IMGNAME=magisk.img
73 | IMG=$NVBASE/$IMGNAME
74 | request_zip_size_check "$ZIPFILE"
75 | mount_magisk_img
76 | MODULEROOT=$MOUNTPATH
77 | fi
78 |
79 | MODID=`grep_prop id $TMPDIR/module.prop`
80 | MODPATH=$MODULEROOT/$MODID
81 |
82 | print_modname
83 |
84 | ui_print "******************************"
85 | ui_print "Powered by Magisk (@topjohnwu)"
86 | ui_print "******************************"
87 |
88 | ##########################################################################################
89 | # Install
90 | ##########################################################################################
91 |
92 | # Create mod paths
93 | rm -rf $MODPATH 2>/dev/null
94 | mkdir -p $MODPATH
95 |
96 | on_install
97 |
98 | # Remove placeholder
99 | rm -f $MODPATH/system/placeholder 2>/dev/null
100 |
101 | # Custom uninstaller
102 | [ -f $TMPDIR/uninstall.sh ] && cp -af $TMPDIR/uninstall.sh $MODPATH/uninstall.sh
103 |
104 | # Auto Mount
105 | if imageless_magisk; then
106 | $SKIPMOUNT && touch $MODPATH/skip_mount
107 | else
108 | $SKIPMOUNT || touch $MODPATH/auto_mount
109 | fi
110 |
111 | # prop files
112 | $PROPFILE && cp -af $TMPDIR/system.prop $MODPATH/system.prop
113 |
114 | # Module info
115 | cp -af $TMPDIR/module.prop $MODPATH/module.prop
116 | if $BOOTMODE; then
117 | # Update info for Magisk Manager
118 | if imageless_magisk; then
119 | mktouch $NVBASE/modules/$MODID/update
120 | cp -af $TMPDIR/module.prop $NVBASE/modules/$MODID/module.prop
121 | else
122 | mktouch /sbin/.magisk/img/$MODID/update
123 | cp -af $TMPDIR/module.prop /sbin/.magisk/img/$MODID/module.prop
124 | fi
125 | fi
126 |
127 | # post-fs-data mode scripts
128 | $POSTFSDATA && cp -af $TMPDIR/post-fs-data.sh $MODPATH/post-fs-data.sh
129 |
130 | # service mode scripts
131 | $LATESTARTSERVICE && cp -af $TMPDIR/service.sh $MODPATH/service.sh
132 |
133 | # Handle replace folders
134 | for TARGET in $REPLACE; do
135 | mktouch $MODPATH$TARGET/.replace
136 | done
137 |
138 | ui_print "- Setting permissions"
139 | set_permissions
140 |
141 | ##########################################################################################
142 | # Finalizing
143 | ##########################################################################################
144 |
145 | cd /
146 | imageless_magisk || unmount_magisk_img
147 | $BOOTMODE || recovery_cleanup
148 | rm -rf $TMPDIR $MOUNTPATH
149 |
150 | ui_print "- Done"
151 | exit 0
152 |
--------------------------------------------------------------------------------
/install.sh:
--------------------------------------------------------------------------------
1 | ##########################################################################################
2 | #
3 | # Magisk Module Installer Script
4 | #
5 | ##########################################################################################
6 | ##########################################################################################
7 | #
8 | # Instructions:
9 | #
10 | # 1. Place your files into system folder (delete the placeholder file)
11 | # 2. Fill in your module's info into module.prop
12 | # 3. Configure and implement callbacks in this file
13 | # 4. If you need boot scripts, add them into common/post-fs-data.sh or common/service.sh
14 | # 5. Add your additional or modified system properties into common/system.prop
15 | #
16 | ##########################################################################################
17 |
18 | ##########################################################################################
19 | # Config Flags
20 | ##########################################################################################
21 |
22 | # Set to true if you do *NOT* want Magisk to mount
23 | # any files for you. Most modules would NOT want
24 | # to set this flag to true
25 | SKIPMOUNT=true
26 |
27 | # Set to true if you need to load system.prop
28 | PROPFILE=true
29 |
30 | # Set to true if you need post-fs-data script
31 | POSTFSDATA=true
32 |
33 | # Set to true if you need late_start service script
34 | LATESTARTSERVICE=true
35 |
36 | ##########################################################################################
37 | # Replace list
38 | ##########################################################################################
39 |
40 | # List all directories you want to directly replace in the system
41 | # Check the documentations for more info why you would need this
42 |
43 | # Construct your list in the following format
44 | # This is an example
45 | REPLACE_EXAMPLE="
46 | /system/app/Youtube
47 | /system/priv-app/SystemUI
48 | /system/priv-app/Settings
49 | /system/framework
50 | "
51 |
52 | # Construct your own list here
53 | REPLACE="
54 | "
55 |
56 | ##########################################################################################
57 | #
58 | # Function Callbacks
59 | #
60 | # The following functions will be called by the installation framework.
61 | # You do not have the ability to modify update-binary, the only way you can customize
62 | # installation is through implementing these functions.
63 | #
64 | # When running your callbacks, the installation framework will make sure the Magisk
65 | # internal busybox path is *PREPENDED* to PATH, so all common commands shall exist.
66 | # Also, it will make sure /data, /system, and /vendor is properly mounted.
67 | #
68 | ##########################################################################################
69 | ##########################################################################################
70 | #
71 | # The installation framework will export some variables and functions.
72 | # You should use these variables and functions for installation.
73 | #
74 | # ! DO NOT use any Magisk internal paths as those are NOT public API.
75 | # ! DO NOT use other functions in util_functions.sh as they are NOT public API.
76 | # ! Non public APIs are not guranteed to maintain compatibility between releases.
77 | #
78 | # Available variables:
79 | #
80 | # MAGISK_VER (string): the version string of current installed Magisk
81 | # MAGISK_VER_CODE (int): the version code of current installed Magisk
82 | # BOOTMODE (bool): true if the module is currently installing in Magisk Manager
83 | # MODPATH (path): the path where your module files should be installed
84 | # TMPDIR (path): a place where you can temporarily store files
85 | # ZIPFILE (path): your module's installation zip
86 | # ARCH (string): the architecture of the device. Value is either arm, arm64, x86, or x64
87 | # IS64BIT (bool): true if $ARCH is either arm64 or x64
88 | # API (int): the API level (Android version) of the device
89 | #
90 | # Availible functions:
91 | #
92 | # ui_print
93 | # print to console
94 | # Avoid using 'echo' as it will not display in custom recovery's console
95 | #
96 | # abort
97 | # print error message to console and terminate installation
98 | # Avoid using 'exit' as it will skip the termination cleanup steps
99 | #
100 | # set_perm [context]
101 | # if [context] is empty, it will default to "u:object_r:system_file:s0"
102 | # this function is a shorthand for the following commands
103 | # chown owner.group target
104 | # chmod permission target
105 | # chcon context target
106 | #
107 | # set_perm_recursive [context]
108 | # if [context] is empty, it will default to "u:object_r:system_file:s0"
109 | # for all files in , it will call:
110 | # set_perm file owner group filepermission context
111 | # for all directories in (including itself), it will call:
112 | # set_perm dir owner group dirpermission context
113 | #
114 | ##########################################################################################
115 | ##########################################################################################
116 | # If you need boot scripts, DO NOT use general boot scripts (post-fs-data.d/service.d)
117 | # ONLY use module scripts as it respects the module status (remove/disable) and is
118 | # guaranteed to maintain the same behavior in future Magisk releases.
119 | # Enable boot scripts by setting the flags in the config section above.
120 | ##########################################################################################
121 |
122 | # Set what you want to display when installing your module
123 |
124 | print_modname() {
125 | ui_print "***********************************"
126 | ui_print " Magisk Google DNS v11 "
127 | ui_print " tfae @ XDA "
128 | ui_print "***********************************"
129 | }
130 |
131 | # Copy/extract your module files into $MODPATH in on_install.
132 |
133 | on_install() {
134 | # The following is the default implementation: extract $ZIPFILE/system to $MODPATH
135 | # Extend/change the logic to whatever you want
136 | ui_print "- Extracting module files"
137 | unzip -o "$ZIPFILE" 'system/*' -d $MODPATH >&2
138 | }
139 |
140 | # Only some special files require specific permissions
141 | # This function will be called after on_install is done
142 | # The default permissions should be good enough for most cases
143 |
144 | set_permissions() {
145 | # The following is the default rule, DO NOT remove
146 | set_perm_recursive $MODPATH 0 0 0755 0644
147 |
148 | # Here are some examples:
149 | # set_perm_recursive $MODPATH/system/lib 0 0 0755 0644
150 | # set_perm $MODPATH/system/bin/app_process32 0 2000 0755 u:object_r:zygote_exec:s0
151 | # set_perm $MODPATH/system/bin/dex2oat 0 2000 0755 u:object_r:dex2oat_exec:s0
152 | # set_perm $MODPATH/system/lib/libart.so 0 0 0644
153 | }
154 |
155 | # You can add more functions to assist your custom script code
156 |
157 | # Edit the resolv conf file if it exist
158 | resolve_conf() {
159 | if [ -a /system/etc/resolv.conf ]; then
160 | mkdir -p $MODPATH/system/etc/
161 | printf "nameserver 8.8.8.8\nnameserver 8.8.4.4" >> $MODPATH/system/etc/resolv.conf
162 | touch $MODPATH/auto_mount
163 | fi
164 | }
165 |
--------------------------------------------------------------------------------