Commit 3e61fdb7 authored by Mygod's avatar Mygod

Fix race condition when receiving a packet from unexpected host

parent 7c4ca94b
......@@ -159,7 +159,7 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd
check(channel.send(remoteDns.udpWrap(packet), proxy) > 0)
monitor.wait(channel, SelectionKey.OP_READ)
val result = remoteDns.udpReceiveBuffer(UDP_PACKET_SIZE)
check(channel.receive(result) == proxy)
while (channel.receive(result) != proxy) result.clear()
result.flip()
remoteDns.udpUnwrap(result)
result
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment