diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2020-05-16 01:38:36 +0200 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2022-03-18 23:38:55 +0100 |
commit | 48e8dbe5f5083b0905ca0d8062da272d006cdc11 (patch) | |
tree | cb12cf3d6557ee7283cd3e29dc4e8f0be954179b | |
parent | c5c714716e58aee4aa2922eb30d1459a51da4200 (diff) |
WIP fix TunnelManager
-rw-r--r-- | ui/src/main/java/com/wireguard/android/model/TunnelManager.kt | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/ui/src/main/java/com/wireguard/android/model/TunnelManager.kt b/ui/src/main/java/com/wireguard/android/model/TunnelManager.kt index ab0e2e79..77169cc7 100644 --- a/ui/src/main/java/com/wireguard/android/model/TunnelManager.kt +++ b/ui/src/main/java/com/wireguard/android/model/TunnelManager.kt @@ -169,9 +169,8 @@ class TunnelManager(private val configStore: ConfigStore) : BaseObservable() { ======= fun setTunnelUserspaceConfig(tunnel: ObservableTunnel, config: Config): CompletionStage<Config> = getAsyncWorker().supplyAsync { Log.println(Log.INFO, TAG, "Async setTunnelUserspaceConfig " + config); - getBackend().setState(tunnel, tunnel.state, config) - configStore.save(tunnel.name, config) - }.thenApply { getBackend().applyUserspaceConfig(tunnel, it) } + getBackend().applyUserspaceConfig(tunnel, config) + } fun setTunnelName(tunnel: ObservableTunnel, name: String): CompletionStage<String> { >>>>>>> WIP tunnel manager @@ -290,21 +289,28 @@ class TunnelManager(private val configStore: ConfigStore) : BaseObservable() { } private fun configAction(manager: TunnelManager, intent: Intent, action: String) { + Log.println(Log.INFO, TAG, "Config action") val code: ActionCode code = when (action) { "com.wireguard.android.action.SET_TUNNEL_CONFIG" -> ActionCode.SET_CONFIG - "com.wireguard.android.action.SET_USERSPACE_CONFIG" -> ActionCode.SET_USERSPACE_CONFIG + "com.wireguard.android.action.SET_TUNNEL_USERSPACE_CONFIG" -> ActionCode.SET_USERSPACE_CONFIG "com.wireguard.android.action.GET_TUNNEL_CONFIG" -> ActionCode.GET_CONFIG - else -> return + else -> { + Log.println(Log.INFO, TAG, "Unknown action: "+ action) + return + } } val tunnelName = intent.getStringExtra("tunnel") ?: return + Log.println(Log.INFO, TAG, "Tunnel name: "+ tunnelName) manager.tunnels.thenAccept { val tunnel = it[tunnelName] ?: return@thenAccept + Log.println(Log.INFO, TAG, "Tunnel: "+ tunnel) if (code == ActionCode.GET_CONFIG) { val config = manager.getTunnelConfig(tunnel) Log.println(Log.INFO, TAG, "Call getTunnelConfig " + config) // TODO return config } else { + Log.println(Log.INFO, TAG, "Set config action") val strConfig = intent.getStringExtra("config") ?: return@thenAccept val config = Config.parse(BufferedReader(StringReader(strConfig))) when (code) { |