StaticDnsRuleResolver.kt 881 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
    }
}