mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-11-10 20:46:42 +01:00
Fixes the Tor leaks for relays and some image content.
This commit is contained in:
@@ -24,6 +24,7 @@ import android.os.Build
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import coil3.SingletonImageLoader
|
import coil3.SingletonImageLoader
|
||||||
|
import coil3.annotation.DelicateCoilApi
|
||||||
import coil3.gif.AnimatedImageDecoder
|
import coil3.gif.AnimatedImageDecoder
|
||||||
import coil3.gif.GifDecoder
|
import coil3.gif.GifDecoder
|
||||||
import coil3.network.okhttp.OkHttpNetworkFetcherFactory
|
import coil3.network.okhttp.OkHttpNetworkFetcherFactory
|
||||||
@@ -88,12 +89,13 @@ class ServiceManager(
|
|||||||
start()
|
start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(DelicateCoilApi::class)
|
||||||
private fun start() {
|
private fun start() {
|
||||||
Log.d("ServiceManager", "Pre Starting Relay Services $isStarted $account")
|
Log.d("ServiceManager", "Pre Starting Relay Services $isStarted $account")
|
||||||
if (isStarted && account != null) {
|
if (isStarted && account != null) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Log.d("ServiceManager", "Starting Relay Services")
|
Log.d("ServiceManager", "Starting Relay Services Tor: ${account?.settings?.torSettings?.torType?.value}")
|
||||||
|
|
||||||
val myAccount = account
|
val myAccount = account
|
||||||
|
|
||||||
@@ -126,7 +128,7 @@ class ServiceManager(
|
|||||||
?.security
|
?.security
|
||||||
?.filterSpamFromStrangers ?: true
|
?.filterSpamFromStrangers ?: true
|
||||||
|
|
||||||
SingletonImageLoader.setSafe {
|
SingletonImageLoader.setUnsafe {
|
||||||
Amethyst.instance
|
Amethyst.instance
|
||||||
.imageLoaderBuilder()
|
.imageLoaderBuilder()
|
||||||
.components {
|
.components {
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ class Relay(
|
|||||||
|
|
||||||
lastConnectTentative = TimeUtils.now()
|
lastConnectTentative = TimeUtils.now()
|
||||||
|
|
||||||
socket = socketBuilder.build(url, false, RelayListener(onConnected))
|
socket = socketBuilder.build(url, forceProxy, RelayListener(onConnected))
|
||||||
socket?.connect()
|
socket?.connect()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
if (e is CancellationException) throw e
|
if (e is CancellationException) throw e
|
||||||
|
|||||||
@@ -91,7 +91,8 @@ class RelayPool : Relay.Listener {
|
|||||||
|
|
||||||
fun loadRelays(relayList: List<Relay>) {
|
fun loadRelays(relayList: List<Relay>) {
|
||||||
check(relayList.isNotEmpty()) { "Relay list should never be empty" }
|
check(relayList.isNotEmpty()) { "Relay list should never be empty" }
|
||||||
relayList.forEach { addRelay(it) }
|
relayList.forEach { addRelayInner(it) }
|
||||||
|
updateStatus()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun unloadRelays() {
|
fun unloadRelays() {
|
||||||
@@ -142,9 +143,13 @@ class RelayPool : Relay.Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun addRelay(relay: Relay) {
|
fun addRelay(relay: Relay) {
|
||||||
|
addRelayInner(relay)
|
||||||
|
updateStatus()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun addRelayInner(relay: Relay) {
|
||||||
relay.register(this)
|
relay.register(this)
|
||||||
relays += relay
|
relays += relay
|
||||||
updateStatus()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun removeRelay(relay: Relay) {
|
fun removeRelay(relay: Relay) {
|
||||||
|
|||||||
Reference in New Issue
Block a user