mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-04-19 19:14:51 +00:00
App version info for plugins, trust all certs dev setting, latest refs
This commit is contained in:
parent
72bb43f934
commit
a0d6ff912b
11 changed files with 67 additions and 7 deletions
|
@ -33,6 +33,7 @@ import com.futo.platformplayer.stores.FragmentedStorageFileJson
|
|||
import com.futo.platformplayer.views.fields.ButtonField
|
||||
import com.futo.platformplayer.views.fields.FieldForm
|
||||
import com.futo.platformplayer.views.fields.FormField
|
||||
import com.futo.platformplayer.views.fields.FormFieldWarning
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -493,6 +494,17 @@ class SettingsDev : FragmentedStorageFileJson() {
|
|||
}
|
||||
|
||||
|
||||
|
||||
@FormField(R.string.networking, FieldForm.GROUP, -1, 18)
|
||||
var networking = Networking();
|
||||
@Serializable
|
||||
class Networking {
|
||||
@FormField(R.string.allow_all_certificates, FieldForm.TOGGLE, -1, 0)
|
||||
@FormFieldWarning(R.string.allow_all_certificates_warning)
|
||||
var allowAllCertificates: Boolean = false;
|
||||
}
|
||||
|
||||
|
||||
@Contextual
|
||||
@Transient
|
||||
@FormField(R.string.info, FieldForm.GROUP, -1, 19)
|
||||
|
@ -503,6 +515,8 @@ class SettingsDev : FragmentedStorageFileJson() {
|
|||
var channelCacheStartupCount = StateCache.instance.channelCacheStartupCount;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//region BOILERPLATE
|
||||
override fun encode(): String {
|
||||
return Json.encodeToString(this);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.futo.platformplayer.api.http
|
||||
|
||||
import androidx.collection.arrayMapOf
|
||||
import com.futo.platformplayer.SettingsDev
|
||||
import com.futo.platformplayer.constructs.Event1
|
||||
import com.futo.platformplayer.ensureNotMainThread
|
||||
import com.futo.platformplayer.logging.Logger
|
||||
|
@ -13,6 +15,11 @@ import okhttp3.Response
|
|||
import okhttp3.ResponseBody
|
||||
import okhttp3.WebSocket
|
||||
import okhttp3.WebSocketListener
|
||||
import java.security.SecureRandom
|
||||
import java.security.cert.X509Certificate
|
||||
import javax.net.ssl.SSLContext
|
||||
import javax.net.ssl.TrustManager
|
||||
import javax.net.ssl.X509TrustManager
|
||||
import kotlin.system.measureTimeMillis
|
||||
|
||||
open class ManagedHttpClient {
|
||||
|
@ -25,8 +32,29 @@ open class ManagedHttpClient {
|
|||
|
||||
var user_agent = "Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0"
|
||||
|
||||
private val trustAllCerts = arrayOf<TrustManager>(
|
||||
object: X509TrustManager {
|
||||
override fun checkClientTrusted(chain: Array<out X509Certificate>?, authType: String?) { }
|
||||
override fun checkServerTrusted(chain: Array<out X509Certificate>?, authType: String?) { }
|
||||
override fun getAcceptedIssuers(): Array<X509Certificate> {
|
||||
return arrayOf();
|
||||
}
|
||||
}
|
||||
);
|
||||
private fun trustAllCertificates(builder: OkHttpClient.Builder) {
|
||||
val sslContext = SSLContext.getInstance("SSL");
|
||||
sslContext.init(null, trustAllCerts, SecureRandom());
|
||||
builder.sslSocketFactory(sslContext.socketFactory, trustAllCerts[0] as X509TrustManager);
|
||||
builder.hostnameVerifier { a, b ->
|
||||
return@hostnameVerifier true;
|
||||
}
|
||||
Logger.w(TAG, "Creating INSECURE client (TrustAll)");
|
||||
}
|
||||
|
||||
constructor(builder: OkHttpClient.Builder = OkHttpClient.Builder()) {
|
||||
_builderTemplate = builder;
|
||||
if(SettingsDev.instance.developerMode && SettingsDev.instance.networking.allowAllCertificates)
|
||||
trustAllCertificates(builder);
|
||||
client = builder.addNetworkInterceptor { chain ->
|
||||
val request = beforeRequest(chain.request());
|
||||
val response = afterRequest(chain.proceed(request));
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.futo.platformplayer.engine.packages
|
||||
|
||||
import com.caoccao.javet.annotations.V8Function
|
||||
import com.caoccao.javet.annotations.V8Property
|
||||
import com.futo.platformplayer.BuildConfig
|
||||
import com.futo.platformplayer.logging.Logger
|
||||
import com.futo.platformplayer.states.StateDeveloper
|
||||
import com.futo.platformplayer.UIDialogs
|
||||
|
@ -35,6 +37,19 @@ class PackageBridge : V8Package {
|
|||
_clientAuth = plugin.httpClientAuth;
|
||||
}
|
||||
|
||||
|
||||
@V8Property
|
||||
fun buildVersion(): Int {
|
||||
//If debug build, assume max version
|
||||
if(BuildConfig.VERSION_CODE == 1)
|
||||
return Int.MAX_VALUE;
|
||||
return BuildConfig.VERSION_CODE;
|
||||
}
|
||||
@V8Property
|
||||
fun buildFlavor(): String {
|
||||
return BuildConfig.FLAVOR;
|
||||
}
|
||||
|
||||
@V8Function
|
||||
fun toast(str: String) {
|
||||
StateApp.instance.scopeOrNull?.launch(Dispatchers.Main) {
|
||||
|
|
|
@ -347,6 +347,7 @@
|
|||
<string name="get_answers_to_common_questions">Get answers to common questions</string>
|
||||
<string name="give_feedback_on_the_application">Give feedback on the application</string>
|
||||
<string name="info">Info</string>
|
||||
<string name="networking">Networking</string>
|
||||
<string name="gesture_controls">Gesture controls</string>
|
||||
<string name="volume_slider">Volume slider</string>
|
||||
<string name="volume_slider_descr">Enable slide gesture to change volume</string>
|
||||
|
@ -461,6 +462,8 @@
|
|||
<string name="deletes_all_ongoing_downloads">Deletes all ongoing downloads</string>
|
||||
<string name="deletes_all_unresolved_source_files">Deletes all unresolved source files</string>
|
||||
<string name="developer_mode">Developer Mode</string>
|
||||
<string name="allow_all_certificates">Allow All Certificates</string>
|
||||
<string name="allow_all_certificates_warning">This risks exposing all your Grayjay network traffic.</string>
|
||||
<string name="development_server">Development Server</string>
|
||||
<string name="experimental">Experimental</string>
|
||||
<string name="cache">Cache</string>
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 611f692ced94bac637907b105170a4143580281a
|
||||
Subproject commit b518be4dd5e162e67e9ca64e09be3fe574fccdb7
|
|
@ -1 +1 @@
|
|||
Subproject commit cee1fda4e875a46315a9d4492e2e3b541d98f39f
|
||||
Subproject commit 5b1919934d20f8c53de9959b04bdb66e0c6af3e9
|
|
@ -1 +1 @@
|
|||
Subproject commit 37e2ed94384ff82f4cb67a2250877cb1e8e03c57
|
||||
Subproject commit c23302da76fc706faf02f7d9331ed28baed04607
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
|
||||
<application android:networkSecurityConfig="@xml/network_security_config">
|
||||
<application>
|
||||
<receiver android:name=".receivers.InstallReceiver" />
|
||||
|
||||
<activity android:name=".activities.MainActivity">
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 611f692ced94bac637907b105170a4143580281a
|
||||
Subproject commit b518be4dd5e162e67e9ca64e09be3fe574fccdb7
|
|
@ -1 +1 @@
|
|||
Subproject commit cee1fda4e875a46315a9d4492e2e3b541d98f39f
|
||||
Subproject commit 5b1919934d20f8c53de9959b04bdb66e0c6af3e9
|
|
@ -1 +1 @@
|
|||
Subproject commit d0cca1ac04a1812414ee633a08585dc896701a32
|
||||
Subproject commit c23302da76fc706faf02f7d9331ed28baed04607
|
Loading…
Add table
Reference in a new issue