Skip to content

Conversation

@qgjyf2001
Copy link
Contributor

We need to do like this while writing Android VPN Service to protect our socket connection:

val javaNioChannel = SelectorProvider.provider().openSocketChannel()
val res = protect(javaNioChannel.socket())

In addition, VPN services also proxy DNS requests, so we need to directly connect to the DNS server within the proxy server

val dnsResolverGroup = object : DnsAddressResolverGroup(
            DnsNameResolverBuilder()
                .apply {
                    nameServerProvider(
                        SingletonDnsServerAddressStreamProvider(
                            InetSocketAddress("114.114.114.114", 53)
                        )
                    )
                    channelType(NioDatagramChannel::class.java)
                    queryTimeoutMillis(5000)
                    maxQueriesPerResolve(3)
                }
        ) {}

@monkeyWie monkeyWie merged commit a3d0e57 into monkeyWie:master Apr 7, 2025
1 check passed
@monkeyWie
Copy link
Owner

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants