diff --git a/app/src/main/java/io/nekohasekai/sfa/bg/VPNService.kt b/app/src/main/java/io/nekohasekai/sfa/bg/VPNService.kt index 9817e95..4973c70 100644 --- a/app/src/main/java/io/nekohasekai/sfa/bg/VPNService.kt +++ b/app/src/main/java/io/nekohasekai/sfa/bg/VPNService.kt @@ -77,7 +77,7 @@ class VPNService : VpnService(), PlatformInterfaceWrapper { } if (options.autoRoute) { - builder.addDnsServer(options.dnsServerAddress) + builder.addDnsServer(options.dnsServerAddress.value) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { val inet4RouteAddress = options.inet4RouteAddress diff --git a/app/src/main/java/io/nekohasekai/sfa/ktx/Wrappers.kt b/app/src/main/java/io/nekohasekai/sfa/ktx/Wrappers.kt index 1fc7ad1..bd8b2f6 100644 --- a/app/src/main/java/io/nekohasekai/sfa/ktx/Wrappers.kt +++ b/app/src/main/java/io/nekohasekai/sfa/ktx/Wrappers.kt @@ -4,9 +4,16 @@ import android.net.IpPrefix import android.os.Build import androidx.annotation.RequiresApi import io.nekohasekai.libbox.RoutePrefix +import io.nekohasekai.libbox.StringBox import io.nekohasekai.libbox.StringIterator import java.net.InetAddress +val StringBox?.unwrap: String + get() { + if (this == null) return "" + return value + } + fun Iterable.toStringIterator(): StringIterator { return object : StringIterator { val iterator = iterator() diff --git a/app/src/main/java/io/nekohasekai/sfa/ui/profile/EditProfileContentActivity.kt b/app/src/main/java/io/nekohasekai/sfa/ui/profile/EditProfileContentActivity.kt index 7beacdf..df762eb 100644 --- a/app/src/main/java/io/nekohasekai/sfa/ui/profile/EditProfileContentActivity.kt +++ b/app/src/main/java/io/nekohasekai/sfa/ui/profile/EditProfileContentActivity.kt @@ -14,6 +14,7 @@ import io.nekohasekai.sfa.database.Profile import io.nekohasekai.sfa.database.ProfileManager import io.nekohasekai.sfa.databinding.ActivityEditProfileContentBinding import io.nekohasekai.sfa.ktx.errorDialogBuilder +import io.nekohasekai.sfa.ktx.unwrap import io.nekohasekai.sfa.ui.shared.AbstractActivity import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay @@ -84,7 +85,7 @@ class EditProfileContentActivity : AbstractActivity { lifecycleScope.launch(Dispatchers.IO) { runCatching { - val content = Libbox.formatConfig(binding.editor.text.toString()) + val content = Libbox.formatConfig(binding.editor.text.toString()).unwrap if (binding.editor.text.toString() != content) { withContext(Dispatchers.Main) { binding.editor.setTextContent(content) diff --git a/app/src/main/java/io/nekohasekai/sfa/utils/HTTPClient.kt b/app/src/main/java/io/nekohasekai/sfa/utils/HTTPClient.kt index 7223472..baab03f 100644 --- a/app/src/main/java/io/nekohasekai/sfa/utils/HTTPClient.kt +++ b/app/src/main/java/io/nekohasekai/sfa/utils/HTTPClient.kt @@ -2,6 +2,7 @@ package io.nekohasekai.sfa.utils import io.nekohasekai.libbox.Libbox import io.nekohasekai.sfa.BuildConfig +import io.nekohasekai.sfa.ktx.unwrap import java.io.Closeable class HTTPClient : Closeable { @@ -30,7 +31,7 @@ class HTTPClient : Closeable { request.setUserAgent(userAgent) request.setURL(url) val response = request.execute() - return response.contentString + return response.content.unwrap } override fun close() {