fix: improve QR direct connection reliability and speed
This commit is contained in:
@@ -7,6 +7,38 @@ import java.nio.ByteOrder
|
||||
import java.util.zip.CRC32
|
||||
|
||||
class ProtocolTest {
|
||||
@Test
|
||||
fun routeCandidatesOnlyKeepEndpointsOnTheActiveSubnet() {
|
||||
val endpoints = listOf(
|
||||
"http://192.168.137.1:39393",
|
||||
"http://192.168.49.1:39393",
|
||||
"http://192.168.1.20:39393",
|
||||
"http://10.20.30.40:39393",
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
listOf("http://192.168.1.20:39393"),
|
||||
EndpointRouting.onAnySubnet(endpoints, 39393, listOf("192.168.1.88" to 24)),
|
||||
)
|
||||
assertEquals(
|
||||
listOf("http://10.20.30.40:39393"),
|
||||
EndpointRouting.onAnySubnet(endpoints, 39393, listOf("10.20.99.2" to 16)),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun routeCandidatesRejectWrongPortsAndMalformedAddresses() {
|
||||
val endpoints = listOf(
|
||||
"http://192.168.1.20:39394",
|
||||
"http://192.168.1.999:39393",
|
||||
"http://192.168.1.30:39393",
|
||||
)
|
||||
assertEquals(
|
||||
listOf("http://192.168.1.30:39393"),
|
||||
EndpointRouting.onAnySubnet(endpoints, 39393, listOf("192.168.1.88" to 24)),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parsesPcToPhoneAutomaticDownloadPairing() {
|
||||
val json = """{"v":2,"s":"abcdefghijklmnopqrstuvwxyz012345","n":"DESKTOP-QFT","p":39393,"e":["http://192.168.49.1:39393"],"d":"d","f":"sample.bin","z":42,"h":"${"00".repeat(32)}"}"""
|
||||
|
||||
Reference in New Issue
Block a user