Skip to content

Commit a10c4ef

Browse files
authored
android/notifier: add ipn bus rate limit flag (#562)
updates corp#24553 Adds the new flag to rate limit netmap updates on the ipnBus to one per 3 second interval. Signed-off-by: Jonathan Nobels <[email protected]>
1 parent 08a062b commit a10c4ef

File tree

1 file changed

+21
-20
lines changed
  • android/src/main/java/com/tailscale/ipn/ui/notifier

1 file changed

+21
-20
lines changed

android/src/main/java/com/tailscale/ipn/ui/notifier/Notifier.kt

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
package com.tailscale.ipn.ui.notifier
55

6-
import android.util.Log
76
import com.tailscale.ipn.App
87
import com.tailscale.ipn.ui.model.Empty
98
import com.tailscale.ipn.ui.model.Health
109
import com.tailscale.ipn.ui.model.Ipn
1110
import com.tailscale.ipn.ui.model.Ipn.Notify
1211
import com.tailscale.ipn.ui.model.Netmap
1312
import com.tailscale.ipn.ui.util.set
13+
import com.tailscale.ipn.util.TSLog
1414
import kotlinx.coroutines.CoroutineScope
1515
import kotlinx.coroutines.Dispatchers
1616
import kotlinx.coroutines.flow.MutableStateFlow
@@ -19,7 +19,6 @@ import kotlinx.coroutines.launch
1919
import kotlinx.serialization.ExperimentalSerializationApi
2020
import kotlinx.serialization.json.Json
2121
import kotlinx.serialization.json.decodeFromStream
22-
import com.tailscale.ipn.util.TSLog
2322

2423
// Notifier is a wrapper around the IPN Bus notifier. It provides a way to watch
2524
// for changes in various parts of the Tailscale engine. You will typically only use
@@ -69,23 +68,24 @@ object Notifier {
6968
NotifyWatchOpt.Netmap.value or
7069
NotifyWatchOpt.Prefs.value or
7170
NotifyWatchOpt.InitialState.value or
72-
NotifyWatchOpt.InitialHealthState.value
73-
manager =
74-
app.watchNotifications(mask.toLong()) { notification ->
75-
val notify = decoder.decodeFromStream<Notify>(notification.inputStream())
76-
notify.State?.let { state.set(Ipn.State.fromInt(it)) }
77-
notify.NetMap?.let(netmap::set)
78-
notify.Prefs?.let(prefs::set)
79-
notify.Engine?.let(engineStatus::set)
80-
notify.TailFSShares?.let(tailFSShares::set)
81-
notify.BrowseToURL?.let(browseToURL::set)
82-
notify.LoginFinished?.let { loginFinished.set(it.property) }
83-
notify.Version?.let(version::set)
84-
notify.OutgoingFiles?.let(outgoingFiles::set)
85-
notify.FilesWaiting?.let(filesWaiting::set)
86-
notify.IncomingFiles?.let(incomingFiles::set)
87-
notify.Health?.let(health::set)
88-
}
71+
NotifyWatchOpt.InitialHealthState.value or
72+
NotifyWatchOpt.RateLimitNetmaps.value
73+
manager =
74+
app.watchNotifications(mask.toLong()) { notification ->
75+
val notify = decoder.decodeFromStream<Notify>(notification.inputStream())
76+
notify.State?.let { state.set(Ipn.State.fromInt(it)) }
77+
notify.NetMap?.let(netmap::set)
78+
notify.Prefs?.let(prefs::set)
79+
notify.Engine?.let(engineStatus::set)
80+
notify.TailFSShares?.let(tailFSShares::set)
81+
notify.BrowseToURL?.let(browseToURL::set)
82+
notify.LoginFinished?.let { loginFinished.set(it.property) }
83+
notify.Version?.let(version::set)
84+
notify.OutgoingFiles?.let(outgoingFiles::set)
85+
notify.FilesWaiting?.let(filesWaiting::set)
86+
notify.IncomingFiles?.let(incomingFiles::set)
87+
notify.Health?.let(health::set)
88+
}
8989
}
9090
}
9191

@@ -108,9 +108,10 @@ object Notifier {
108108
InitialTailFSShares(32),
109109
InitialOutgoingFiles(64),
110110
InitialHealthState(128),
111+
RateLimitNetmaps(256),
111112
}
112113

113114
fun setState(newState: Ipn.State) {
114115
_state.value = newState
115-
}
116+
}
116117
}

0 commit comments

Comments
 (0)