Wtf more debug
This commit is contained in:
@@ -54,7 +54,7 @@ class LocalOnlyHotspotService : IpNeighbourMonitoringService() {
|
|||||||
} else {
|
} else {
|
||||||
val routingManager = routingManager
|
val routingManager = routingManager
|
||||||
if (routingManager == null) {
|
if (routingManager == null) {
|
||||||
this.routingManager = LocalOnlyInterfaceManager(iface)
|
this.routingManager = LocalOnlyInterfaceManager(this, iface)
|
||||||
IpNeighbourMonitor.registerCallback(this)
|
IpNeighbourMonitor.registerCallback(this)
|
||||||
} else check(iface == routingManager.downstream)
|
} else check(iface == routingManager.downstream)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import be.mygod.vpnhotspot.widget.SmartSnackbar
|
|||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.net.InterfaceAddress
|
import java.net.InterfaceAddress
|
||||||
|
|
||||||
class LocalOnlyInterfaceManager(val downstream: String) {
|
class LocalOnlyInterfaceManager(val caller: Any, val downstream: String) {
|
||||||
private var routing: Routing? = null
|
private var routing: Routing? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@@ -21,7 +21,7 @@ class LocalOnlyInterfaceManager(val downstream: String) {
|
|||||||
|
|
||||||
private fun initRouting(owner: InterfaceAddress? = null) {
|
private fun initRouting(owner: InterfaceAddress? = null) {
|
||||||
routing = try {
|
routing = try {
|
||||||
Routing(downstream, owner).apply {
|
Routing(caller, downstream, owner).apply {
|
||||||
try {
|
try {
|
||||||
ipForward() // local only interfaces need to enable ip_forward
|
ipForward() // local only interfaces need to enable ip_forward
|
||||||
forward()
|
forward()
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere
|
|||||||
locked = true
|
locked = true
|
||||||
binder.group = group
|
binder.group = group
|
||||||
check(routingManager == null)
|
check(routingManager == null)
|
||||||
routingManager = LocalOnlyInterfaceManager(group.`interface`!!)
|
routingManager = LocalOnlyInterfaceManager(this, group.`interface`!!)
|
||||||
status = Status.ACTIVE
|
status = Status.ACTIVE
|
||||||
showNotification(group)
|
showNotification(group)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class TetheringService : IpNeighbourMonitoringService() {
|
|||||||
val (downstream, value) = iterator.next()
|
val (downstream, value) = iterator.next()
|
||||||
if (value != null) continue
|
if (value != null) continue
|
||||||
try {
|
try {
|
||||||
routings[downstream] = Routing(downstream).apply {
|
routings[downstream] = Routing(this, downstream).apply {
|
||||||
try {
|
try {
|
||||||
forward()
|
forward()
|
||||||
masquerade(Routing.masquerade)
|
masquerade(Routing.masquerade)
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ import java.net.*
|
|||||||
*
|
*
|
||||||
* Once revert is called, this object no longer serves any purpose.
|
* 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 {
|
companion object {
|
||||||
/**
|
/**
|
||||||
* Since Android 5.0, RULE_PRIORITY_TETHERING = 18000.
|
* 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) {
|
fun commit(localOnly: Boolean = false) {
|
||||||
transaction.commit()
|
transaction.commit()
|
||||||
Timber.i("Started routing for $downstream")
|
Timber.i("Started routing for $downstream by $caller")
|
||||||
if (localOnly || masqueradeMode != MasqueradeMode.Netd) DefaultNetworkMonitor.registerCallback(fallbackUpstream)
|
if (localOnly || masqueradeMode != MasqueradeMode.Netd) DefaultNetworkMonitor.registerCallback(fallbackUpstream)
|
||||||
UpstreamMonitor.registerCallback(upstream)
|
UpstreamMonitor.registerCallback(upstream)
|
||||||
IpNeighbourMonitor.registerCallback(this)
|
IpNeighbourMonitor.registerCallback(this)
|
||||||
}
|
}
|
||||||
fun revert() {
|
fun revert() {
|
||||||
stop()
|
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
|
TrafficRecorder.update() // record stats before exiting to prevent stats losing
|
||||||
clients.values.forEach { it.close() }
|
clients.values.forEach { it.close() }
|
||||||
fallbackUpstream.subrouting?.transaction?.revert()
|
fallbackUpstream.subrouting?.transaction?.revert()
|
||||||
|
|||||||
Reference in New Issue
Block a user