Add more debugLog to investigate check failure
This commit is contained in:
@@ -2,6 +2,7 @@ package be.mygod.vpnhotspot.net.monitor
|
|||||||
|
|
||||||
import android.util.LongSparseArray
|
import android.util.LongSparseArray
|
||||||
import androidx.core.os.postDelayed
|
import androidx.core.os.postDelayed
|
||||||
|
import be.mygod.vpnhotspot.debugLog
|
||||||
import be.mygod.vpnhotspot.net.Routing.Companion.IPTABLES
|
import be.mygod.vpnhotspot.net.Routing.Companion.IPTABLES
|
||||||
import be.mygod.vpnhotspot.room.AppDatabase
|
import be.mygod.vpnhotspot.room.AppDatabase
|
||||||
import be.mygod.vpnhotspot.room.TrafficRecord
|
import be.mygod.vpnhotspot.room.TrafficRecord
|
||||||
@@ -16,6 +17,7 @@ import java.net.InetAddress
|
|||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
object TrafficRecorder {
|
object TrafficRecorder {
|
||||||
|
private const val TAG = "TrafficRecorder"
|
||||||
private const val ANYWHERE = "0.0.0.0/0"
|
private const val ANYWHERE = "0.0.0.0/0"
|
||||||
|
|
||||||
private var scheduled = false
|
private var scheduled = false
|
||||||
@@ -31,12 +33,14 @@ object TrafficRecorder {
|
|||||||
downstream = downstream)
|
downstream = downstream)
|
||||||
AppDatabase.instance.trafficRecordDao.insert(record)
|
AppDatabase.instance.trafficRecordDao.insert(record)
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
|
debugLog(TAG, "Registering ($ip, $upstream, $downstream)")
|
||||||
check(records.put(Triple(ip, upstream, downstream), record) == null)
|
check(records.put(Triple(ip, upstream, downstream), record) == null)
|
||||||
scheduleUpdateLocked()
|
scheduleUpdateLocked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fun unregister(ip: InetAddress, upstream: String?, downstream: String) = synchronized(this) {
|
fun unregister(ip: InetAddress, upstream: String?, downstream: String) = synchronized(this) {
|
||||||
update() // flush stats before removing
|
update() // flush stats before removing
|
||||||
|
debugLog(TAG, "Unregistering ($ip, $upstream, $downstream)")
|
||||||
if (records.remove(Triple(ip, upstream, downstream)) == null) Timber.w(
|
if (records.remove(Triple(ip, upstream, downstream)) == null) Timber.w(
|
||||||
"Failed to find traffic record for ($ip, $downstream, $upstream).")
|
"Failed to find traffic record for ($ip, $downstream, $upstream).")
|
||||||
}
|
}
|
||||||
@@ -141,6 +145,7 @@ object TrafficRecorder {
|
|||||||
fun clean() = synchronized(this) {
|
fun clean() = synchronized(this) {
|
||||||
update()
|
update()
|
||||||
unscheduleUpdateLocked()
|
unscheduleUpdateLocked()
|
||||||
|
debugLog(TAG, "Cleaning records")
|
||||||
records.clear()
|
records.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user