-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(kotlin): detect network and dns changes
- Loading branch information
Showing
13 changed files
with
146 additions
and
23 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
24 changes: 24 additions & 0 deletions
24
kotlin/android/app/src/main/java/dev/firezone/android/tunnel/NetworkMonitor.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,24 @@ | ||
import android.net.ConnectivityManager | ||
import android.net.LinkProperties | ||
import android.net.Network | ||
import android.net.NetworkCapabilities | ||
import android.util.Log | ||
import com.google.gson.Gson | ||
import com.squareup.moshi.Moshi | ||
import com.squareup.moshi.adapter | ||
import dev.firezone.android.tunnel.ConnlibSession | ||
import dev.firezone.android.tunnel.TunnelService | ||
import java.net.InetAddress | ||
import javax.inject.Inject | ||
|
||
private const val TAG: String = "NetworkMonitor" | ||
|
||
class NetworkMonitor(val connlibSessionPtr: Long) : ConnectivityManager.NetworkCallback() { | ||
@Inject | ||
internal lateinit var moshi: Moshi | ||
|
||
override fun onLinkPropertiesChanged(network: Network, linkProperties: LinkProperties) { | ||
ConnlibSession.networkUpdate(connlibSessionPtr, Gson().toJson(linkProperties.dnsServers)) | ||
super.onLinkPropertiesChanged(network, linkProperties) | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.