Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
735b65c5
Commit
735b65c5
authored
Oct 11, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update DoH implementation
parent
efb1eab3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
15 deletions
+12
-15
Config.kt
app/src/main/java/com/topjohnwu/magisk/core/Config.kt
+1
-1
NetworkingModule.kt
...src/main/java/com/topjohnwu/magisk/di/NetworkingModule.kt
+11
-14
No files found.
app/src/main/java/com/topjohnwu/magisk/core/Config.kt
View file @
735b65c5
...
@@ -128,7 +128,7 @@ object Config : PreferenceModel, DBConfig {
...
@@ -128,7 +128,7 @@ object Config : PreferenceModel, DBConfig {
var
themeOrdinal
by
preference
(
Key
.
THEME_ORDINAL
,
Theme
.
Piplup
.
ordinal
)
var
themeOrdinal
by
preference
(
Key
.
THEME_ORDINAL
,
Theme
.
Piplup
.
ordinal
)
var
suReAuth
by
preference
(
Key
.
SU_REAUTH
,
false
)
var
suReAuth
by
preference
(
Key
.
SU_REAUTH
,
false
)
var
checkUpdate
by
preference
(
Key
.
CHECK_UPDATES
,
true
)
var
checkUpdate
by
preference
(
Key
.
CHECK_UPDATES
,
true
)
var
doh
by
preference
(
Key
.
DOH
,
defaultLocale
.
country
==
"CN"
)
var
doh
by
preference
(
Key
.
DOH
,
false
)
var
magiskHide
by
preference
(
Key
.
MAGISKHIDE
,
true
)
var
magiskHide
by
preference
(
Key
.
MAGISKHIDE
,
true
)
var
showSystemApp
by
preference
(
Key
.
SHOW_SYSTEM_APP
,
false
)
var
showSystemApp
by
preference
(
Key
.
SHOW_SYSTEM_APP
,
false
)
...
...
app/src/main/java/com/topjohnwu/magisk/di/NetworkingModule.kt
View file @
735b65c5
...
@@ -3,6 +3,7 @@ package com.topjohnwu.magisk.di
...
@@ -3,6 +3,7 @@ package com.topjohnwu.magisk.di
import
android.content.Context
import
android.content.Context
import
android.os.Build
import
android.os.Build
import
com.squareup.moshi.Moshi
import
com.squareup.moshi.Moshi
import
com.topjohnwu.magisk.BuildConfig
import
com.topjohnwu.magisk.core.Config
import
com.topjohnwu.magisk.core.Config
import
com.topjohnwu.magisk.core.Const
import
com.topjohnwu.magisk.core.Const
import
com.topjohnwu.magisk.core.Info
import
com.topjohnwu.magisk.core.Info
...
@@ -20,6 +21,7 @@ import okhttp3.Dns
...
@@ -20,6 +21,7 @@ import okhttp3.Dns
import
okhttp3.HttpUrl
import
okhttp3.HttpUrl
import
okhttp3.OkHttpClient
import
okhttp3.OkHttpClient
import
okhttp3.dnsoverhttps.DnsOverHttps
import
okhttp3.dnsoverhttps.DnsOverHttps
import
okhttp3.logging.HttpLoggingInterceptor
import
org.koin.dsl.module
import
org.koin.dsl.module
import
retrofit2.Retrofit
import
retrofit2.Retrofit
import
retrofit2.converter.moshi.MoshiConverterFactory
import
retrofit2.converter.moshi.MoshiConverterFactory
...
@@ -39,8 +41,6 @@ val networkingModule = module {
...
@@ -39,8 +41,6 @@ val networkingModule = module {
private
class
DnsResolver
(
client
:
OkHttpClient
)
:
Dns
{
private
class
DnsResolver
(
client
:
OkHttpClient
)
:
Dns
{
private
var
dohError
=
false
private
val
poisonedHosts
=
listOf
(
"raw.githubusercontent.com"
)
private
val
doh
by
lazy
{
private
val
doh
by
lazy
{
DnsOverHttps
.
Builder
().
client
(
client
)
DnsOverHttps
.
Builder
().
client
(
client
)
.
url
(
HttpUrl
.
get
(
"https://cloudflare-dns.com/dns-query"
))
.
url
(
HttpUrl
.
get
(
"https://cloudflare-dns.com/dns-query"
))
...
@@ -60,16 +60,12 @@ private class DnsResolver(client: OkHttpClient) : Dns {
...
@@ -60,16 +60,12 @@ private class DnsResolver(client: OkHttpClient) : Dns {
}
}
override
fun
lookup
(
hostname
:
String
):
List
<
InetAddress
>
{
override
fun
lookup
(
hostname
:
String
):
List
<
InetAddress
>
{
return
if
(!
dohError
&&
Config
.
doh
&&
poisonedHosts
.
contains
(
hostname
)
)
{
if
(
Config
.
doh
)
{
try
{
try
{
doh
.
lookup
(
hostname
)
return
doh
.
lookup
(
hostname
)
}
catch
(
e
:
UnknownHostException
)
{
}
catch
(
e
:
UnknownHostException
)
{}
dohError
=
true
Dns
.
SYSTEM
.
lookup
(
hostname
)
}
}
else
{
Dns
.
SYSTEM
.
lookup
(
hostname
)
}
}
return
Dns
.
SYSTEM
.
lookup
(
hostname
)
}
}
}
}
...
@@ -77,10 +73,11 @@ private class DnsResolver(client: OkHttpClient) : Dns {
...
@@ -77,10 +73,11 @@ private class DnsResolver(client: OkHttpClient) : Dns {
fun
createOkHttpClient
(
context
:
Context
):
OkHttpClient
{
fun
createOkHttpClient
(
context
:
Context
):
OkHttpClient
{
val
builder
=
OkHttpClient
.
Builder
()
val
builder
=
OkHttpClient
.
Builder
()
// val httpLoggingInterceptor = HttpLoggingInterceptor().apply {
if
(
BuildConfig
.
DEBUG
)
{
// level = HttpLoggingInterceptor.Level.HEADERS
builder
.
addInterceptor
(
HttpLoggingInterceptor
().
apply
{
// }
level
=
HttpLoggingInterceptor
.
Level
.
BASIC
// builder.addInterceptor(httpLoggingInterceptor)
})
}
if
(!
Networking
.
init
(
context
))
{
if
(!
Networking
.
init
(
context
))
{
Info
.
hasGMS
=
false
Info
.
hasGMS
=
false
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment