Skip to content

Commit

Permalink
fix: ignore range test messages when module disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
andrekir committed Oct 9, 2023
1 parent 7c56c33 commit 85564ca
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions app/src/main/java/com/geeksville/mesh/service/MeshService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ class MeshService : Service(), Logging {
nodeDBbyNodeNum.getOrPut(n) { NodeInfo(n) }

private val hexIdRegex = """\!([0-9A-Fa-f]+)""".toRegex()
private val rangeTestRegex = Regex("seq (\\d{1,10})")

/// Map a userid to a node/ node num, or throw an exception if not found
/// We prefer to find nodes based on their assigned IDs, but if no ID has been assigned to a node, we can also find it based on node number
Expand Down Expand Up @@ -611,12 +612,17 @@ class MeshService : Service(), Logging {
var shouldBroadcast = !fromUs

when (data.portnumValue) {
Portnums.PortNum.TEXT_MESSAGE_APP_VALUE ->
if (!fromUs) {
debug("Received CLEAR_TEXT from $fromId")
rememberDataPacket(dataPacket)
updateMessageNotification(dataPacket)
}
Portnums.PortNum.TEXT_MESSAGE_APP_VALUE -> {
if (fromUs) return

// TODO temporary solution to Range Test spam, may be removed in the future
val isRangeTest = rangeTestRegex.matches(data.payload.toStringUtf8())
if (!moduleConfig.rangeTest.enabled && isRangeTest) return

debug("Received CLEAR_TEXT from $fromId")
rememberDataPacket(dataPacket)
updateMessageNotification(dataPacket)
}

Portnums.PortNum.WAYPOINT_APP_VALUE -> {
val u = MeshProtos.Waypoint.parseFrom(data.payload)
Expand Down

0 comments on commit 85564ca

Please sign in to comment.