Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
YouROK committed Apr 1, 2024
1 parent 9edb9bc commit af13943
Showing 1 changed file with 3 additions and 39 deletions.
42 changes: 3 additions & 39 deletions app/src/main/java/ru/yourok/torrserve/ad/ADManager.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package ru.yourok.torrserve.ad

import android.net.Uri
import com.google.gson.Gson
import org.jsoup.Jsoup
import ru.yourok.torrserve.ad.model.ADData
import ru.yourok.torrserve.app.Consts
import ru.yourok.torrserve.atv.Utils
import ru.yourok.torrserve.utils.Net
import java.text.SimpleDateFormat
import java.util.*
import javax.net.ssl.HostnameVerifier
import javax.net.ssl.HttpsURLConnection
import java.util.Date
import java.util.Locale

object ADManager {
private var addata: ADData? = null
Expand All @@ -32,7 +28,7 @@ object ADManager {
}
try {
val link = Consts.ad_link + "/ad.json"
val buf = getNet(link)
val buf = Net.get(link)
val data = Gson().fromJson(buf, ADData::class.java)
addata = data
return data
Expand All @@ -41,36 +37,4 @@ object ADManager {
}
return null
}

private fun getNet(url: String): String {
val link = Uri.parse(url)
if (link.scheme.equals("https", true)) {
val trustAllHostnames = HostnameVerifier { _, _ ->
true // Just allow them all
}
HttpsURLConnection.setDefaultHostnameVerifier(trustAllHostnames)
}
val conn = Jsoup.connect(url)
.ignoreHttpErrors(true)
.ignoreContentType(true)
.timeout(3000)
if (!Utils.isBrokenTCL)
conn.sslSocketFactory(Net.insecureTlsSocketFactory())

val response = conn.execute()

return when (response.statusCode()) {
200 -> {
response.body()
}

302 -> {
""
}

else -> {
throw Exception(response.statusMessage())
}
}
}
}

0 comments on commit af13943

Please sign in to comment.