[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [Git][tpo/applications/firefox-android][firefox-android-115.2.1-13.5-1] fixup! Add Tor integration and UI



Title: GitLab

Dan Ballard pushed to branch firefox-android-115.2.1-13.5-1 at The Tor Project / Applications / firefox-android

Commits:

  • 8cc03c8e
    by Dan Ballard at 2024-04-17T14:08:42-07:00
    fixup! Add Tor integration and UI
    
    Bug 42486: Fixing controller use of TorSettings so cleanupSettings doesn't reject partial states
    

1 changed file:

Changes:

  • fenix/app/src/main/java/org/mozilla/fenix/tor/TorControllerGV.kt
    ... ... @@ -88,15 +88,21 @@ class TorControllerGV(
    88 88
             return getTorIntegration().getSettings()
    
    89 89
         }
    
    90 90
     
    
    91
    +
    
    92
    +    // Bridges Enabled is a cache variable. The TorController interface we are locked into at the
    
    93
    +    // moment to support the TAS backend calls setting `bridgesEnabled = true` and setting
    
    94
    +    // the bridge type seperately so to support that,
    
    95
    +    // while at the same time it being invalid states to not submit them together to the TorSettings
    
    96
    +    // backend where TorSettings.sys.mjs's #cleanupSettings will remove a lone bridgeEnabled
    
    97
    +    // we thus have to hold it here to support the UI but not submit to the backend until
    
    98
    +    // bridgeTransport is also set (below)
    
    99
    +    private var _bridgesEnabled: Boolean? = null
    
    91 100
         override var bridgesEnabled: Boolean
    
    92 101
             get() {
    
    93
    -            return getTorSettings()?.bridgesEnabled ?: false
    
    102
    +            return _bridgesEnabled ?: getTorSettings()?.bridgesEnabled ?: false
    
    94 103
             }
    
    95 104
             set(value) {
    
    96
    -            getTorSettings()?.let {
    
    97
    -                it.bridgesEnabled = value
    
    98
    -                getTorIntegration().setSettings(it, true, true)
    
    99
    -            }
    
    105
    +            _bridgesEnabled = value
    
    100 106
             }
    
    101 107
     
    
    102 108
     
    
    ... ... @@ -119,9 +125,13 @@ class TorControllerGV(
    119 125
             }
    
    120 126
             set(value) {
    
    121 127
                 getTorSettings()?.let {
    
    128
    +                it.bridgesEnabled = true
    
    122 129
                     if (value == TorBridgeTransportConfig.USER_PROVIDED) {
    
    123
    -                    it.bridgesSource = BridgeSource.BuiltIn
    
    130
    +                    // NOOP: all settings will be set in call to set userProvidedBridges and submited
    
    131
    +                    // at the same time to clear TorSettings.sys.mjs #cleanupSettings
    
    132
    +                    return
    
    124 133
                     } else {
    
    134
    +                    it.bridgesSource = BridgeSource.BuiltIn
    
    125 135
                         val bbt: BridgeBuiltinType = when (value) {
    
    126 136
                             TorBridgeTransportConfig.BUILTIN_OBFS4 -> BridgeBuiltinType.Obfs4
    
    127 137
                             TorBridgeTransportConfig.BUILTIN_MEEK_AZURE -> BridgeBuiltinType.MeekAzure
    
    ... ... @@ -135,12 +145,16 @@ class TorControllerGV(
    135 145
             }
    
    136 146
     
    
    137 147
     
    
    148
    +    // Currently the UI takes a user provided string and sets this in one step so there is where we
    
    149
    +    // actually set it.bridgesSource = BridgeSource.UserProvided, not above, as TorSettings.sys.mjs #cleanupSettings
    
    150
    +    // could reject BridgeSource.UserProvided with no bridge strings
    
    138 151
         override var userProvidedBridges: String?
    
    139 152
             get() {
    
    140 153
                 return getTorSettings()?.bridgeBridgeStrings?.joinToString("\r\n")
    
    141 154
             }
    
    142 155
             set(value) {
    
    143 156
                 getTorSettings()?.let {
    
    157
    +                it.bridgesSource = BridgeSource.UserProvided
    
    144 158
                     it.bridgeBridgeStrings = value?.split("\r\n")?.toTypedArray() ?: arrayOf<String>()
    
    145 159
                     getTorIntegration().setSettings(it, true, true)
    
    146 160
                 }
    

  • _______________________________________________
    tor-commits mailing list
    tor-commits@xxxxxxxxxxxxxxxxxxxx
    https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits