Add support for gRPC protocol

Signed-off-by: Teddysun <i@teddysun.com>
This commit is contained in:
Teddysun 2021-05-27 12:59:26 +09:00
parent c6e649c2a3
commit 9605f980e0
No known key found for this signature in database
GPG key ID: 09BD4C080AD6C46D
2 changed files with 7 additions and 1 deletions

View file

@ -50,6 +50,8 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
"websocket-http" -> Pair(null, false) "websocket-http" -> Pair(null, false)
"websocket-tls" -> Pair(null, true) "websocket-tls" -> Pair(null, true)
"quic-tls" -> Pair("quic", false) "quic-tls" -> Pair("quic", false)
"grpc" -> Pair("grpc", false)
"grpc-tls" -> Pair("grpc", true)
else -> { else -> {
check(false) check(false)
Pair(null, false) Pair(null, false)
@ -70,7 +72,9 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
fun onInitializePluginOptions(options: PluginOptions) { fun onInitializePluginOptions(options: PluginOptions) {
mode.value = when { mode.value = when {
options["mode"] ?: "websocket" == "quic" -> "quic-tls" options["mode"] ?: "websocket" == "quic" -> "quic-tls"
"tls" in options -> "websocket-tls" options["mode"] == "websocket-tls" -> "websocket-tls"
options["mode"] == "grpc" -> "grpc"
options["mode"] == "grpc-tls" -> "grpc-tls"
else -> "websocket-http" else -> "websocket-http"
}.also { onPreferenceChange(null, it) } }.also { onPreferenceChange(null, it) }
host.text = options["host"] ?: "cloudfront.com" host.text = options["host"] ?: "cloudfront.com"

View file

@ -4,6 +4,8 @@
<item>websocket-http</item> <item>websocket-http</item>
<item>websocket-tls</item> <item>websocket-tls</item>
<item>quic-tls</item> <item>quic-tls</item>
<item>grpc</item>
<item>grpc-tls</item>
</string-array> </string-array>
<string-array name="loglevels"> <string-array name="loglevels">
<item>debug</item> <item>debug</item>