diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 9a1557c..edec37d 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -3,6 +3,7 @@
package="eu.neilalexander.yggdrasil">
+
{
+ Log.d(TAG, "Connecting...")
+ connect(); START_STICKY
+ }
else -> {
Log.d(TAG, "Starting...")
start(); START_STICKY
@@ -181,6 +188,14 @@ class PacketTunnelProvider: VpnService() {
stopSelf()
}
+ private fun connect() {
+ if (!started.get()) {
+ return
+ }
+ yggdrasil.setMulticastInterfaces(getInterfaces().joinToString("\n"))
+ yggdrasil.connectAnyPeer()
+ }
+
private fun updater() {
updates@ while (started.get()) {
if ((application as GlobalApplication).needUiUpdates()) {
@@ -260,4 +275,26 @@ class PacketTunnelProvider: VpnService() {
readerStream = null
}
}
+
+ private fun getInterfaces(): Array {
+ val result = ArrayList()
+
+ val interfaces: List = try {
+ Collections.list(NetworkInterface.getNetworkInterfaces())
+ } catch (e: java.lang.Exception) {
+ return result.toTypedArray()
+ }
+
+ for (i in interfaces) {
+ if (!i.isUp) continue
+
+ if (i.supportsMulticast() && !i.isPointToPoint) {
+ for (addr in i.inetAddresses) {
+ val a = addr.toString().replace("/", "")
+ result.add("${i.name}|${a}")
+ }
+ }
+ }
+ return result.toTypedArray()
+ }
}
\ No newline at end of file