Skip to content
This repository was archived by the owner on Dec 18, 2022. It is now read-only.

Commit 4ccfd8e

Browse files
authored
Merge pull request #73 from 05nelsonm/mn/bug-fix/port-info-not-being-broadcast
Bug Fix: PortInfo not being broadcast on network state change
2 parents 96fb493 + ebc291c commit 4ccfd8e

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

topl-service/src/main/java/io/matthewnelson/topl_service/service/components/onionproxy/ServiceEventBroadcaster.kt

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,14 @@ internal class ServiceEventBroadcaster(private val torService: BaseService): Eve
217217
@Volatile
218218
private var transPort: String? = null
219219

220+
private fun setAllPortsNull() {
221+
controlPort = null
222+
dnsPort = null
223+
httpTunnelPort = null
224+
socksPort = null
225+
transPort = null
226+
}
227+
220228
override fun broadcastNotice(msg: String) {
221229

222230
when {
@@ -401,11 +409,7 @@ internal class ServiceEventBroadcaster(private val torService: BaseService): Eve
401409
override fun broadcastTorState(@TorState state: String, @TorNetworkState networkState: String) {
402410
if (torState == TorState.ON && state != torState) {
403411
bootstrapProgress = ""
404-
controlPort = null
405-
dnsPort = null
406-
httpTunnelPort = null
407-
socksPort = null
408-
transPort = null
412+
setAllPortsNull()
409413
updateAppEventBroadcasterWithPortInfo()
410414
torService.removeNotificationActions()
411415
}
@@ -417,13 +421,20 @@ internal class ServiceEventBroadcaster(private val torService: BaseService): Eve
417421
torState = state
418422

419423
if (networkState == TorNetworkState.DISABLED) {
424+
if (isBootstrappingComplete()) {
425+
setAllPortsNull()
426+
updateAppEventBroadcasterWithPortInfo()
427+
}
428+
420429
// Update torNetworkState _before_ setting the icon to `disabled` so bandwidth won't
421430
// overwrite the icon with an update
422431
torNetworkState = networkState
423432
torService.updateNotificationIcon(NotificationImage.DISABLED)
424433
} else {
425-
if (isBootstrappingComplete())
434+
if (isBootstrappingComplete()) {
435+
updateAppEventBroadcasterWithPortInfo()
426436
torService.updateNotificationIcon(NotificationImage.ENABLED)
437+
}
427438

428439
// Update torNetworkState _after_ setting the icon to `enabled` so bandwidth changes
429440
// occur afterwards and this won't overwrite ImageState.DATA

0 commit comments

Comments
 (0)