Allow waiting in updating records
This commit is contained in:
@@ -64,7 +64,7 @@ object TrafficRecorder {
|
|||||||
|
|
||||||
private fun doUpdate(timestamp: Long) {
|
private fun doUpdate(timestamp: Long) {
|
||||||
val oldRecords = LongSparseArray<TrafficRecord>()
|
val oldRecords = LongSparseArray<TrafficRecord>()
|
||||||
loop@ for (line in RootSession.use { it.execOutUnjoined("$IPTABLES -nvx -L vpnhotspot_fwd").drop(2) }) {
|
loop@ for (line in RootSession.use { it.execOutUnjoinedWithWait("$IPTABLES -nvx -L vpnhotspot_fwd").drop(2) }) {
|
||||||
val columns = line.split("\\s+".toRegex()).filter { it.isNotEmpty() }
|
val columns = line.split("\\s+".toRegex()).filter { it.isNotEmpty() }
|
||||||
try {
|
try {
|
||||||
check(columns.size >= 9)
|
check(columns.size >= 9)
|
||||||
|
|||||||
@@ -111,6 +111,12 @@ class RootSession : AutoCloseable {
|
|||||||
checkOutput(command, result, false)
|
checkOutput(command, result, false)
|
||||||
return result.out
|
return result.out
|
||||||
}
|
}
|
||||||
|
fun execOutUnjoinedWithWait(command: String): List<String> {
|
||||||
|
val result = execQuiet(command)
|
||||||
|
val message = checkOutput(command, result, false, false)
|
||||||
|
if (result.err.isNotEmpty()) Timber.i(message)
|
||||||
|
return result.out
|
||||||
|
}
|
||||||
fun execOut(command: String): String = execOutUnjoined(command).joinToString("\n")
|
fun execOut(command: String): String = execOutUnjoined(command).joinToString("\n")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user