diff --git a/app/src/full/java/com/celzero/bravedns/NonStoreAppUpdater.kt b/app/src/full/java/com/celzero/bravedns/NonStoreAppUpdater.kt index 15c8fb9e3..c4b08a911 100644 --- a/app/src/full/java/com/celzero/bravedns/NonStoreAppUpdater.kt +++ b/app/src/full/java/com/celzero/bravedns/NonStoreAppUpdater.kt @@ -46,7 +46,7 @@ class NonStoreAppUpdater( Log.i(LOG_TAG_APP_UPDATE, "Beginning update check") val url = baseUrl + BuildConfig.VERSION_CODE - val client = RetrofitManager.okHttpClient(RetrofitManager.Companion.OkHttpDnsType.DEFAULT) + val client = RetrofitManager.okHttpClient(RetrofitManager.Companion.OkHttpDnsType.FALLBACK_DNS) val request = Request.Builder().url(url).build() client diff --git a/app/src/full/java/com/celzero/bravedns/scheduler/PaymentWorker.kt b/app/src/full/java/com/celzero/bravedns/scheduler/PaymentWorker.kt index 0192467a1..b34a77dde 100644 --- a/app/src/full/java/com/celzero/bravedns/scheduler/PaymentWorker.kt +++ b/app/src/full/java/com/celzero/bravedns/scheduler/PaymentWorker.kt @@ -75,7 +75,7 @@ class PaymentWorker(val context: Context, workerParameters: WorkerParameters) : try { val retrofit = RetrofitManager.getTcpProxyBaseBuilder( - RetrofitManager.Companion.OkHttpDnsType.DEFAULT + RetrofitManager.Companion.OkHttpDnsType.FALLBACK_DNS ) .addConverterFactory(GsonConverterFactory.create()) .build() diff --git a/app/src/full/java/com/celzero/bravedns/service/TcpProxyHelper.kt b/app/src/full/java/com/celzero/bravedns/service/TcpProxyHelper.kt index 785417d65..65123ea37 100644 --- a/app/src/full/java/com/celzero/bravedns/service/TcpProxyHelper.kt +++ b/app/src/full/java/com/celzero/bravedns/service/TcpProxyHelper.kt @@ -18,6 +18,9 @@ import com.celzero.bravedns.database.TcpProxyRepository import com.celzero.bravedns.scheduler.PaymentWorker import com.celzero.bravedns.util.LoggerConstants.Companion.LOG_TAG_PROXY import dnsx.Dnsx +import java.text.SimpleDateFormat +import java.util.Locale +import java.util.concurrent.TimeUnit import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -25,9 +28,6 @@ import org.json.JSONObject import org.koin.core.component.KoinComponent import org.koin.core.component.inject import retrofit2.converter.gson.GsonConverterFactory -import java.text.SimpleDateFormat -import java.util.Locale -import java.util.concurrent.TimeUnit object TcpProxyHelper : KoinComponent { @@ -110,7 +110,7 @@ object TcpProxyHelper : KoinComponent { fun isCloudflareIp(ip: String): Boolean { // do not check for cloudflare ips for now - return false + // return false return try { cfIpTrie.hasAny(ip) } catch (e: Exception) { @@ -131,7 +131,7 @@ object TcpProxyHelper : KoinComponent { try { val retrofit = RetrofitManager.getTcpProxyBaseBuilder( - RetrofitManager.Companion.OkHttpDnsType.DEFAULT + RetrofitManager.Companion.OkHttpDnsType.FALLBACK_DNS ) .addConverterFactory(GsonConverterFactory.create()) .build() @@ -157,7 +157,11 @@ object TcpProxyHelper : KoinComponent { Log.w(LOG_TAG_PROXY, "unsuccessful response for ${response?.raw()?.request?.url}") } } catch (e: Exception) { - Log.w(LOG_TAG_PROXY, "publicKeyUsable: exception while checking public key", e) + Log.e( + LOG_TAG_PROXY, + "publicKeyUsable: exception while checking public key: ${e.message}", + e + ) } return works } diff --git a/app/src/full/java/com/celzero/bravedns/service/WireguardManager.kt b/app/src/full/java/com/celzero/bravedns/service/WireguardManager.kt index 57a2cb5aa..b6709ec09 100644 --- a/app/src/full/java/com/celzero/bravedns/service/WireguardManager.kt +++ b/app/src/full/java/com/celzero/bravedns/service/WireguardManager.kt @@ -31,13 +31,6 @@ import com.celzero.bravedns.wireguard.Peer import com.celzero.bravedns.wireguard.WgInterface import ipn.Ipn import ipn.Key -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch -import org.json.JSONObject -import org.koin.core.component.KoinComponent -import org.koin.core.component.inject -import retrofit2.converter.gson.GsonConverterFactory import java.io.ByteArrayInputStream import java.io.File import java.io.InputStream @@ -45,6 +38,13 @@ import java.nio.charset.StandardCharsets import java.util.Locale import java.util.concurrent.locks.ReentrantReadWriteLock import kotlin.concurrent.write +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import org.json.JSONObject +import org.koin.core.component.KoinComponent +import org.koin.core.component.inject +import retrofit2.converter.gson.GsonConverterFactory object WireGuardManager : KoinComponent { @@ -83,13 +83,13 @@ object WireGuardManager : KoinComponent { suspend fun load() { // go through all files in the wireguard directory and load them // parse the files as those are encrypted + // increment the id by 1, as the first config id is 0 + lastAddedConfigId = wgConfigFilesRepository.getLastAddedConfigId() + 1 lock.write { if (configs.isNotEmpty()) { Log.i(LOG_TAG_PROXY, "configs already loaded") return } - // increment the id by 1, as the first config id is 0 - lastAddedConfigId = wgConfigFilesRepository.getLastAddedConfigId() + 1 mappings = wgConfigFilesRepository.getWgConfigs().toMutableSet() mappings.forEach { val path = it.configPath @@ -165,7 +165,6 @@ object WireGuardManager : KoinComponent { } fun getSecWarpConfig(): Config? { - // warp config will always be the first config in the list return configs.firstOrNull { it.getId() == SEC_WARP_ID } } @@ -265,7 +264,7 @@ object WireGuardManager : KoinComponent { val locale = Locale.getDefault().toString() val retrofit = - RetrofitManager.getWarpBaseBuilder(RetrofitManager.Companion.OkHttpDnsType.DEFAULT) + RetrofitManager.getWarpBaseBuilder(RetrofitManager.Companion.OkHttpDnsType.FALLBACK_DNS) .addConverterFactory(GsonConverterFactory.create()) .build() val retrofitInterface = retrofit.create(IWireguardWarp::class.java) @@ -304,7 +303,7 @@ object WireGuardManager : KoinComponent { var works = false try { val retrofit = - RetrofitManager.getWarpBaseBuilder(RetrofitManager.Companion.OkHttpDnsType.DEFAULT) + RetrofitManager.getWarpBaseBuilder(RetrofitManager.Companion.OkHttpDnsType.FALLBACK_DNS) .addConverterFactory(GsonConverterFactory.create()) .build() val retrofitInterface = retrofit.create(IWireguardWarp::class.java)