diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/LocalOnlyHotspotService.kt b/mobile/src/main/java/be/mygod/vpnhotspot/LocalOnlyHotspotService.kt index b34c8285..df79e0c4 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/LocalOnlyHotspotService.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/LocalOnlyHotspotService.kt @@ -54,7 +54,7 @@ class LocalOnlyHotspotService : IpNeighbourMonitoringService() { } else { val routingManager = routingManager if (routingManager == null) { - this.routingManager = LocalOnlyInterfaceManager(iface) + this.routingManager = LocalOnlyInterfaceManager(this, iface) IpNeighbourMonitor.registerCallback(this) } else check(iface == routingManager.downstream) } diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/LocalOnlyInterfaceManager.kt b/mobile/src/main/java/be/mygod/vpnhotspot/LocalOnlyInterfaceManager.kt index 2e1b8892..ff855da9 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/LocalOnlyInterfaceManager.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/LocalOnlyInterfaceManager.kt @@ -6,7 +6,7 @@ import be.mygod.vpnhotspot.widget.SmartSnackbar import timber.log.Timber import java.net.InterfaceAddress -class LocalOnlyInterfaceManager(val downstream: String) { +class LocalOnlyInterfaceManager(val caller: Any, val downstream: String) { private var routing: Routing? = null init { @@ -21,7 +21,7 @@ class LocalOnlyInterfaceManager(val downstream: String) { private fun initRouting(owner: InterfaceAddress? = null) { routing = try { - Routing(downstream, owner).apply { + Routing(caller, downstream, owner).apply { try { ipForward() // local only interfaces need to enable ip_forward forward() diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt b/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt index abaa1638..4d5dab06 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt @@ -282,7 +282,7 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere locked = true binder.group = group check(routingManager == null) - routingManager = LocalOnlyInterfaceManager(group.`interface`!!) + routingManager = LocalOnlyInterfaceManager(this, group.`interface`!!) status = Status.ACTIVE showNotification(group) } diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/TetheringService.kt b/mobile/src/main/java/be/mygod/vpnhotspot/TetheringService.kt index b3095571..1b26c4c3 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/TetheringService.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/TetheringService.kt @@ -67,7 +67,7 @@ class TetheringService : IpNeighbourMonitoringService() { val (downstream, value) = iterator.next() if (value != null) continue try { - routings[downstream] = Routing(downstream).apply { + routings[downstream] = Routing(this, downstream).apply { try { forward() masquerade(Routing.masquerade) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt index d749a9f4..bb90573d 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt @@ -20,7 +20,8 @@ import java.net.* * * Once revert is called, this object no longer serves any purpose. */ -class Routing(val downstream: String, ownerAddress: InterfaceAddress? = null) : IpNeighbourMonitor.Callback { +class Routing(val caller: Any, val downstream: String, ownerAddress: InterfaceAddress? = null) : + IpNeighbourMonitor.Callback { companion object { /** * Since Android 5.0, RULE_PRIORITY_TETHERING = 18000. @@ -289,14 +290,14 @@ class Routing(val downstream: String, ownerAddress: InterfaceAddress? = null) : fun commit(localOnly: Boolean = false) { transaction.commit() - Timber.i("Started routing for $downstream") + Timber.i("Started routing for $downstream by $caller") if (localOnly || masqueradeMode != MasqueradeMode.Netd) DefaultNetworkMonitor.registerCallback(fallbackUpstream) UpstreamMonitor.registerCallback(upstream) IpNeighbourMonitor.registerCallback(this) } fun revert() { stop() - Timber.i("Stopped routing for $downstream") + Timber.i("Stopped routing for $downstream by $caller") TrafficRecorder.update() // record stats before exiting to prevent stats losing clients.values.forEach { it.close() } fallbackUpstream.subrouting?.transaction?.revert()