Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Imre Kristoffer Eilertsen
Nebulo
Commits
823633a8
Commit
823633a8
authored
Jun 03, 2021
by
Daniel Wolf
Browse files
Also use static rules when user has not enabled DNS rules
#285
parent
e1ec8146
Changes
3
Show whitespace changes
Inline
Side-by-side
app/src/main/java/com/frostnerd/smokescreen/service/DnsVpnService.kt
View file @
823633a8
...
...
@@ -1585,11 +1585,11 @@ class DnsVpnService : VpnService(), Runnable, CoroutineScope {
return
dnsCache
}
private
fun
createLocalResolver
():
LocalResolver
?
{
private
fun
createLocalResolver
():
LocalResolver
{
return
if
(
getPreferences
().
dnsRulesEnabled
)
{
DnsRuleResolver
(
applicationContext
)
}
else
{
null
StaticDnsRuleResolver
()
}
}
...
...
app/src/main/java/com/frostnerd/smokescreen/util/proxy/DnsRuleResolver.kt
View file @
823633a8
...
...
@@ -42,10 +42,6 @@ class DnsRuleResolver(context: Context) : LocalResolver(false) {
private
var
cachedWildcardResolved
=
MaxSizeMap
<
Int
,
String
>(
maxWildcardResolvedCacheSize
,
30
)
private
var
cachedNonIncluded
=
HashSet
<
Int
>(
15
)
private
val
staticRules
=
mapOf
<
String
,
List
<
Record
<
*
>>>(
"use-application-dns.net"
to
emptyList
()
)
private
var
previousRefreshJob
:
Job
?
=
null
init
{
...
...
@@ -204,7 +200,7 @@ class DnsRuleResolver(context: Context) : LocalResolver(false) {
}
override
fun
canResolve
(
question
:
Question
):
Boolean
{
if
(
staticRules
.
containsKey
(
question
.
name
?.
toString
()
?.
lowercase
()))
{
if
(
StaticDnsRuleResolver
.
staticRules
.
containsKey
(
question
.
name
?.
toString
()
?.
lowercase
()))
{
return
true
}
return
if
((
ruleCount
==
0
||
(
ruleCount
!=
null
&&
ruleCount
==
whitelistCount
))
||
(
question
.
type
!=
Record
.
TYPE
.
A
&&
question
.
type
!=
Record
.
TYPE
.
AAAA
))
{
...
...
@@ -230,8 +226,8 @@ class DnsRuleResolver(context: Context) : LocalResolver(false) {
}
override
fun
resolve
(
question
:
Question
):
List
<
Record
<
*
>>
{
if
(
staticRules
.
containsKey
(
question
.
name
?.
toString
()
?.
lowercase
()))
{
return
staticRules
[
question
.
name
?.
toString
()
?.
lowercase
()]
!!
if
(
StaticDnsRuleResolver
.
staticRules
.
containsKey
(
question
.
name
?.
toString
()
?.
lowercase
()))
{
return
StaticDnsRuleResolver
.
staticRules
[
question
.
name
?.
toString
()
?.
lowercase
()]
?:
emptyList
()
}
val
result
=
resolveResults
.
remove
(
question
.
hashCode
())
return
result
?.
let
{
...
...
app/src/main/java/com/frostnerd/smokescreen/util/proxy/StaticDnsRuleResolver.kt
0 → 100644
View file @
823633a8
package
com.frostnerd.smokescreen.util.proxy
import
com.frostnerd.dnstunnelproxy.LocalResolver
import
org.minidns.dnsmessage.DnsMessage
import
org.minidns.dnsmessage.Question
import
org.minidns.record.*
// Resolver which does not use user rules.
class
StaticDnsRuleResolver
:
LocalResolver
(
false
)
{
companion
object
{
val
staticRules
=
mapOf
<
String
,
List
<
Record
<
*
>>>(
"use-application-dns.net"
to
emptyList
()
)
}
override
fun
canResolve
(
question
:
Question
):
Boolean
{
return
staticRules
.
containsKey
(
question
.
name
?.
toString
()
?.
lowercase
())
}
override
fun
resolve
(
question
:
Question
):
List
<
Record
<
*
>>
{
return
staticRules
[
question
.
name
?.
toString
()
?.
lowercase
()]
?:
emptyList
()
}
override
fun
cleanup
()
{
}
override
fun
mapResponse
(
message
:
DnsMessage
):
DnsMessage
{
return
message
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
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