3
3
4
4
package com.tailscale.ipn.ui.notifier
5
5
6
- import android.util.Log
7
6
import com.tailscale.ipn.App
8
7
import com.tailscale.ipn.ui.model.Empty
9
8
import com.tailscale.ipn.ui.model.Health
10
9
import com.tailscale.ipn.ui.model.Ipn
11
10
import com.tailscale.ipn.ui.model.Ipn.Notify
12
11
import com.tailscale.ipn.ui.model.Netmap
13
12
import com.tailscale.ipn.ui.util.set
13
+ import com.tailscale.ipn.util.TSLog
14
14
import kotlinx.coroutines.CoroutineScope
15
15
import kotlinx.coroutines.Dispatchers
16
16
import kotlinx.coroutines.flow.MutableStateFlow
@@ -19,7 +19,6 @@ import kotlinx.coroutines.launch
19
19
import kotlinx.serialization.ExperimentalSerializationApi
20
20
import kotlinx.serialization.json.Json
21
21
import kotlinx.serialization.json.decodeFromStream
22
- import com.tailscale.ipn.util.TSLog
23
22
24
23
// Notifier is a wrapper around the IPN Bus notifier. It provides a way to watch
25
24
// for changes in various parts of the Tailscale engine. You will typically only use
@@ -69,23 +68,24 @@ object Notifier {
69
68
NotifyWatchOpt .Netmap .value or
70
69
NotifyWatchOpt .Prefs .value or
71
70
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
+ }
89
89
}
90
90
}
91
91
@@ -108,9 +108,10 @@ object Notifier {
108
108
InitialTailFSShares (32 ),
109
109
InitialOutgoingFiles (64 ),
110
110
InitialHealthState (128 ),
111
+ RateLimitNetmaps (256 ),
111
112
}
112
113
113
114
fun setState (newState : Ipn .State ) {
114
115
_state .value = newState
115
- }
116
+ }
116
117
}
0 commit comments