mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-22 02:01:08 +07:00
Some minor refactoring
This commit is contained in:
@@ -8,7 +8,7 @@ import org.amnezia.vpn.util.Log
|
||||
|
||||
private const val TAG = "Prefs"
|
||||
private const val PREFS_FILE = "org.amnezia.vpn.prefs"
|
||||
private const val SECURE_PREFS_FILE = PREFS_FILE + ".secure"
|
||||
private const val SECURE_PREFS_FILE = "$PREFS_FILE.secure"
|
||||
|
||||
object Prefs {
|
||||
fun get(context: Context, appContext: Context = context.applicationContext): SharedPreferences =
|
||||
@@ -19,7 +19,7 @@ object Prefs {
|
||||
MasterKey(appContext)
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Getting Encryption Storage failed, plaintext fallback")
|
||||
Log.e(TAG, "Getting Encryption Storage failed: ${e.message}, plaintext fallback")
|
||||
appContext.getSharedPreferences(PREFS_FILE, Context.MODE_PRIVATE)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -104,7 +104,7 @@ open class Wireguard : Protocol() {
|
||||
parseInetAddress(dns.trim())
|
||||
}?.forEach(::addDnsServer)
|
||||
|
||||
val defRoutes = listOf(
|
||||
val defRoutes = hashSetOf(
|
||||
InetNetwork("0.0.0.0", 0),
|
||||
InetNetwork("::", 0)
|
||||
)
|
||||
@@ -113,7 +113,7 @@ open class Wireguard : Protocol() {
|
||||
InetNetwork.parse(route.trim())
|
||||
}?.forEach(routes::add)
|
||||
// if the allowed IPs list contains at least one non-default route, disable global split tunneling
|
||||
if (!routes.all { defRoutes.contains(it) }) disableSplitTunneling()
|
||||
if (routes.any { it !in defRoutes }) disableSplitTunneling()
|
||||
addRoutes(routes)
|
||||
|
||||
configData["MTU"]?.let { setMtu(it.toInt()) }
|
||||
|
||||
Reference in New Issue
Block a user