-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add tunnel details screen and handshake monitoring
Adds details screen which display details of tunnel configuration as well as last handshake and rx/tx of peer. Adds last handshake monitoring with statuses and thresholds. Adds handshake/connection notifications based on last successful handshake. Adds status LED next to tunnel on main screen. Fixes bug where first click on QR code could result in nothing happening if QR code module is being downloaded. Now shows message to user. Fixes bug where changes made after editing tunnel were not propagated to settings if that tunnel was configured as the default tunnel. Fixes bug causing crash if wrong config file selected Update README Closes #7, Closes #6
- Loading branch information
1 parent
0c45558
commit 68b0902
Showing
28 changed files
with
612 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
app/src/main/java/com/zaneschepke/wireguardautotunnel/receiver/NotificationActionReceiver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.zaneschepke.wireguardautotunnel.receiver | ||
|
||
import android.content.BroadcastReceiver | ||
import android.content.Context | ||
import android.content.Intent | ||
import com.zaneschepke.wireguardautotunnel.R | ||
import com.zaneschepke.wireguardautotunnel.repository.Repository | ||
import com.zaneschepke.wireguardautotunnel.service.foreground.Action | ||
import com.zaneschepke.wireguardautotunnel.service.foreground.ServiceTracker | ||
import com.zaneschepke.wireguardautotunnel.service.foreground.WireGuardTunnelService | ||
import com.zaneschepke.wireguardautotunnel.service.tunnel.model.Settings | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.SupervisorJob | ||
import kotlinx.coroutines.cancel | ||
import kotlinx.coroutines.delay | ||
import kotlinx.coroutines.launch | ||
import javax.inject.Inject | ||
|
||
@AndroidEntryPoint | ||
class NotificationActionReceiver : BroadcastReceiver() { | ||
|
||
@Inject | ||
lateinit var settingsRepo : Repository<Settings> | ||
override fun onReceive(context: Context, intent: Intent?) { | ||
CoroutineScope(SupervisorJob()).launch { | ||
try { | ||
val settings = settingsRepo.getAll() | ||
if (!settings.isNullOrEmpty()) { | ||
val setting = settings.first() | ||
if (setting.defaultTunnel != null) { | ||
ServiceTracker.actionOnService( | ||
Action.STOP, context, | ||
WireGuardTunnelService::class.java, | ||
mapOf( | ||
context.resources.getString(R.string.tunnel_extras_key) to | ||
setting.defaultTunnel!! | ||
) | ||
) | ||
delay(1000) | ||
ServiceTracker.actionOnService( | ||
Action.START, context, | ||
WireGuardTunnelService::class.java, | ||
mapOf( | ||
context.resources.getString(R.string.tunnel_extras_key) to | ||
setting.defaultTunnel!! | ||
) | ||
) | ||
} | ||
} | ||
} finally { | ||
cancel() | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.