File tree Expand file tree Collapse file tree 2 files changed +5
-9
lines changed
core/src/main/java/com/github/shadowsocks/net Expand file tree Collapse file tree 2 files changed +5
-9
lines changed Original file line number Diff line number Diff line change 2121package com.github.shadowsocks.net
2222
2323import com.github.shadowsocks.utils.parseNumericAddress
24- import java.net.Inet4Address
25- import java.net.Inet6Address
2624import java.net.InetAddress
2725
2826class HostsFile (input : String = " " ) {
@@ -36,9 +34,5 @@ class HostsFile(input: String = "") {
3634 }
3735
3836 val configuredHostnames get() = map.size
39- fun resolve (hostname : String , isIpv6 : Boolean ): List <InetAddress > {
40- return (map[hostname] ? : return emptyList()).run {
41- if (isIpv6) filterIsInstance<Inet6Address >() else filterIsInstance<Inet4Address >()
42- }.shuffled()
43- }
37+ fun resolve (hostname : String ) = map[hostname] ? : emptyList<InetAddress >()
4438}
Original file line number Diff line number Diff line change @@ -124,10 +124,12 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd
124124 else -> return @supervisorScope remote.await()
125125 }
126126 val host = question.name.canonicalize().toString(true )
127- val hostsResults = hosts.resolve(host, isIpv6 )
127+ val hostsResults = hosts.resolve(host)
128128 if (hostsResults.isNotEmpty()) {
129129 remote.cancel()
130- return @supervisorScope cookDnsResponse(request, hostsResults)
130+ return @supervisorScope cookDnsResponse(request, hostsResults.run {
131+ if (isIpv6) filterIsInstance<Inet6Address >() else filterIsInstance<Inet4Address >()
132+ }.shuffled())
131133 }
132134 val acl = acl?.await() ? : return @supervisorScope remote.await()
133135 val useLocal = when (acl.shouldBypass(host)) {
You can’t perform that action at this time.
0 commit comments