Skip to content

Commit

Permalink
update utils/Http
Browse files Browse the repository at this point in the history
  • Loading branch information
tsynik committed Apr 5, 2024
1 parent 197d1f0 commit fe82224
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions app/src/main/java/ru/yourok/torrserve/utils/Http.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ru.yourok.torrserve.utils

import android.net.Uri
import android.os.Build
import info.guardianproject.netcipher.NetCipher
import java.io.IOException
import java.io.InputStream
Expand All @@ -13,6 +14,8 @@ import java.net.HttpURLConnection.HTTP_SEE_OTHER
import java.net.URL
import java.util.Locale
import java.util.zip.GZIPInputStream
import javax.net.ssl.HostnameVerifier
import javax.net.ssl.HttpsURLConnection


/**
Expand Down Expand Up @@ -45,6 +48,15 @@ class Http(url: Uri) {

connection = if (currUrl.startsWith("https"))
NetCipher.getHttpsURLConnection(url)
.also {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
val trustAllHostnames = HostnameVerifier { _, _ ->
true // Just allow them all
}
HttpsURLConnection.setDefaultHostnameVerifier(trustAllHostnames)
HttpsURLConnection.setDefaultSSLSocketFactory(Net.insecureTlsSocketFactory())
}
}
else
NetCipher.getHttpURLConnection(url)
connection!!.connectTimeout = timeout
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.3.0'
classpath 'com.android.tools.build:gradle:8.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}"
classpath 'com.google.gms:google-services:4.4.1'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.9'
Expand Down

0 comments on commit fe82224

Please sign in to comment.