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