Wtf more debug

This commit is contained in:
Mygod
2019-02-01 21:49:09 +08:00
parent 7248193232
commit 43bb8af522
5 changed files with 9 additions and 8 deletions

View File

@@ -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)
}

View File

@@ -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()

View File

@@ -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)
}

View File

@@ -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)

View File

@@ -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()