Skip to content

Commit

Permalink
update target IPs if available in the summary
Browse files Browse the repository at this point in the history
  • Loading branch information
hussainmohd-a committed Sep 9, 2024
1 parent 1323ce0 commit df5cfd8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package com.celzero.bravedns.database

import androidx.lifecycle.LiveData
import com.celzero.bravedns.RethinkDnsApplication
import com.celzero.bravedns.RethinkDnsApplication.Companion.DEBUG
import com.celzero.bravedns.data.ConnectionSummary
import com.celzero.bravedns.data.DataUsage
Expand All @@ -37,12 +36,9 @@ class ConnectionTrackerRepository(private val connectionTrackerDAO: ConnectionTr
}

suspend fun updateBatch(summary: List<ConnectionSummary>) {
val d = Logger.LoggerType.fromId(persistentState.goLoggerLevel.toInt())
val debug = d.isLessThan(Logger.LoggerType.INFO) // debug, verbose, very verbose

summary.forEach {
// update the flag and target ip if in debug mode
if (debug && !it.targetIp.isNullOrEmpty()) {
if (!it.targetIp.isNullOrEmpty()) {
val flag = it.flag ?: ""
connectionTrackerDAO.updateSummary(
it.connId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ package com.celzero.bravedns.service
import Logger.LOG_BATCH_LOGGER
import android.content.Context
import android.util.Log
import backend.Backend
import backend.DNSSummary
import com.celzero.bravedns.RethinkDnsApplication
import com.celzero.bravedns.RethinkDnsApplication.Companion.DEBUG
import com.celzero.bravedns.data.ConnTrackerMetaData
import com.celzero.bravedns.data.ConnectionSummary
Expand Down Expand Up @@ -161,12 +163,10 @@ internal constructor(

fun updateIpSummary(summary: ConnectionSummary) {
if (!persistentState.logsEnabled) return
val d = Logger.LoggerType.fromId(persistentState.goLoggerLevel.toInt())
val debug = d.isLessThan(Logger.LoggerType.INFO) // debug, verbose, very verbose

serializer("updateIpSmm", looper) {
val s =
if (debug && summary.targetIp?.isNotEmpty() == true) {
if (summary.targetIp?.isNotEmpty() == true) {
ipdb.makeSummaryWithTarget(summary)
} else {
summary
Expand All @@ -184,7 +184,7 @@ internal constructor(

serializer("updateRethinkSmm", looper) {
val s =
if (DEBUG && summary.targetIp?.isNotEmpty() == true) {
if (summary.targetIp?.isNotEmpty() == true) {
ipdb.makeSummaryWithTarget(summary)
} else {
summary
Expand Down

0 comments on commit df5cfd8

Please sign in to comment.