VPN Hotspot 2.0: Client+ (#39)
Fix #13, #38. I don't have a lot of confidence that this would work very well for every device. Also here's an SQL command that hopefully somebody could make into the app for me: `SELECT TrafficRecord.mac, SUM(TrafficRecord.sentPackets), SUM(TrafficRecord.sentBytes), SUM(TrafficRecord.receivedPackets), SUM(TrafficRecord.receivedBytes) FROM TrafficRecord LEFT JOIN TrafficRecord AS Next ON TrafficRecord.id = Next.previousId WHERE Next.id IS NULL GROUP BY TrafficRecord.mac;`
This commit is contained in:
@@ -31,8 +31,9 @@ class TetheringService : IpNeighbourMonitoringService(), UpstreamMonitor.Callbac
|
||||
private var dns: List<InetAddress> = emptyList()
|
||||
private var receiverRegistered = false
|
||||
private val receiver = broadcastReceiver { _, intent ->
|
||||
val extras = intent.extras ?: return@broadcastReceiver
|
||||
synchronized(routings) {
|
||||
for (iface in routings.keys - TetheringManager.getTetheredIfaces(intent.extras!!))
|
||||
for (iface in routings.keys - TetheringManager.getTetheredIfaces(extras))
|
||||
routings.remove(iface)?.revert()
|
||||
updateRoutingsLocked()
|
||||
}
|
||||
@@ -65,7 +66,7 @@ class TetheringService : IpNeighbourMonitoringService(), UpstreamMonitor.Callbac
|
||||
val (downstream, value) = iterator.next()
|
||||
if (value != null) if (value.upstream == upstream) continue else value.revert()
|
||||
try {
|
||||
routings[downstream] = Routing(upstream, downstream).apply {
|
||||
routings[downstream] = Routing(this, upstream, downstream).apply {
|
||||
try {
|
||||
if (app.dhcpWorkaround) dhcpWorkaround()
|
||||
// system tethering already has working forwarding rules
|
||||
@@ -73,15 +74,13 @@ class TetheringService : IpNeighbourMonitoringService(), UpstreamMonitor.Callbac
|
||||
rule()
|
||||
// here we always enforce strict mode as fallback is handled by system which we disable
|
||||
forward()
|
||||
if (app.strict) overrideSystemRules()
|
||||
if (app.masquerade) masquerade()
|
||||
if (upstream != null) dnsRedirect(dns)
|
||||
if (disableIpv6) disableIpv6()
|
||||
commit()
|
||||
} catch (e: Exception) {
|
||||
revert()
|
||||
throw e
|
||||
} finally {
|
||||
commit()
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
||||
Reference in New Issue
Block a user