Fixes the Tor leaks for relays and some image content.

This commit is contained in:
Vitor Pamplona 2025-01-04 17:35:34 -05:00
parent 8a8ae4fb8b
commit 6522d74253
3 changed files with 12 additions and 5 deletions

View File

@ -24,6 +24,7 @@ import android.os.Build
import android.util.Log
import androidx.compose.runtime.Stable
import coil3.SingletonImageLoader
import coil3.annotation.DelicateCoilApi
import coil3.gif.AnimatedImageDecoder
import coil3.gif.GifDecoder
import coil3.network.okhttp.OkHttpNetworkFetcherFactory
@ -88,12 +89,13 @@ class ServiceManager(
start()
}
@OptIn(DelicateCoilApi::class)
private fun start() {
Log.d("ServiceManager", "Pre Starting Relay Services $isStarted $account")
if (isStarted && account != null) {
return
}
Log.d("ServiceManager", "Starting Relay Services")
Log.d("ServiceManager", "Starting Relay Services Tor: ${account?.settings?.torSettings?.torType?.value}")
val myAccount = account
@ -126,7 +128,7 @@ class ServiceManager(
?.security
?.filterSpamFromStrangers ?: true
SingletonImageLoader.setSafe {
SingletonImageLoader.setUnsafe {
Amethyst.instance
.imageLoaderBuilder()
.components {

View File

@ -132,7 +132,7 @@ class Relay(
lastConnectTentative = TimeUtils.now()
socket = socketBuilder.build(url, false, RelayListener(onConnected))
socket = socketBuilder.build(url, forceProxy, RelayListener(onConnected))
socket?.connect()
} catch (e: Exception) {
if (e is CancellationException) throw e

View File

@ -91,7 +91,8 @@ class RelayPool : Relay.Listener {
fun loadRelays(relayList: List<Relay>) {
check(relayList.isNotEmpty()) { "Relay list should never be empty" }
relayList.forEach { addRelay(it) }
relayList.forEach { addRelayInner(it) }
updateStatus()
}
fun unloadRelays() {
@ -142,9 +143,13 @@ class RelayPool : Relay.Listener {
}
fun addRelay(relay: Relay) {
addRelayInner(relay)
updateStatus()
}
private fun addRelayInner(relay: Relay) {
relay.register(this)
relays += relay
updateStatus()
}
fun removeRelay(relay: Relay) {