enforce dedicated Wi-Fi for direct QR pairing
This commit is contained in:
@@ -4,6 +4,32 @@ import java.net.URI
|
||||
|
||||
/** Pure IPv4 routing helpers kept Android-free so candidate selection is testable. */
|
||||
object EndpointRouting {
|
||||
/**
|
||||
* A dedicated QFT Wi-Fi must never reuse QR/LAN adapter addresses. Its only
|
||||
* direct candidates are gateways supplied by Android for that exact Network.
|
||||
* Current-LAN fallback mode may additionally use advertised same-subnet IPs.
|
||||
*/
|
||||
fun afterConnection(
|
||||
dedicatedWifi: Boolean,
|
||||
gatewayEndpoints: List<String>,
|
||||
routedAdvertisedEndpoints: List<String>,
|
||||
): List<String> = if (dedicatedWifi) {
|
||||
gatewayEndpoints.distinct()
|
||||
} else {
|
||||
(gatewayEndpoints + routedAdvertisedEndpoints).distinct()
|
||||
}
|
||||
|
||||
/** Same isolation rule for retry/recovery after the first gateway probe. */
|
||||
fun forRecovery(
|
||||
dedicatedWifi: Boolean,
|
||||
discoveredEndpoint: String?,
|
||||
gatewayEndpoints: List<String>,
|
||||
advertisedEndpoints: List<String>,
|
||||
): List<String> {
|
||||
val candidates = listOfNotNull(discoveredEndpoint) + gatewayEndpoints
|
||||
return (candidates + if (dedicatedWifi) emptyList() else advertisedEndpoints).distinct()
|
||||
}
|
||||
|
||||
fun onAnySubnet(
|
||||
endpoints: List<String>,
|
||||
expectedPort: Int,
|
||||
|
||||
Reference in New Issue
Block a user