style: Make the code more beautiful

This commit is contained in:
purofle 2023-11-01 22:52:33 +08:00
parent f839b26ff3
commit 5370f815ec
No known key found for this signature in database
GPG Key ID: 57DEC1478152D973
6 changed files with 31 additions and 13 deletions

View File

@ -14,7 +14,7 @@ public abstract class StandardV2RayBean extends AbstractBean {
//////// End of VMess & VLESS ////////
// "V2Ray Transport" tcp/http/ws/quic/grpc/httpupgrade
// "V2Ray Transport" tcp/http/ws/quic/grpc/httpUpgrade
public String type;
public String host;
@ -133,7 +133,7 @@ public abstract class StandardV2RayBean extends AbstractBean {
case "grpc": {
output.writeString(path);
}
case "httpupgrade": {
case "httpUpgrade": {
output.writeString(host);
output.writeString(path);
@ -185,7 +185,7 @@ public abstract class StandardV2RayBean extends AbstractBean {
case "grpc": {
path = input.readString();
}
case "httpupgrade": {
case "httpUpgrade": {
host = input.readString();
path = input.readString();
}

View File

@ -5,7 +5,19 @@ import com.google.gson.Gson
import io.nekohasekai.sagernet.fmt.http.HttpBean
import io.nekohasekai.sagernet.fmt.trojan.TrojanBean
import io.nekohasekai.sagernet.ktx.*
import moe.matsuri.nb4a.SingBoxOptions.*
import moe.matsuri.nb4a.SingBoxOptions.Outbound
import moe.matsuri.nb4a.SingBoxOptions.OutboundRealityOptions
import moe.matsuri.nb4a.SingBoxOptions.OutboundTLSOptions
import moe.matsuri.nb4a.SingBoxOptions.OutboundUTLSOptions
import moe.matsuri.nb4a.SingBoxOptions.Outbound_HTTPOptions
import moe.matsuri.nb4a.SingBoxOptions.Outbound_TrojanOptions
import moe.matsuri.nb4a.SingBoxOptions.Outbound_VLESSOptions
import moe.matsuri.nb4a.SingBoxOptions.Outbound_VMessOptions
import moe.matsuri.nb4a.SingBoxOptions.V2RayTransportOptions
import moe.matsuri.nb4a.SingBoxOptions.V2RayTransportOptions_GRPCOptions
import moe.matsuri.nb4a.SingBoxOptions.V2RayTransportOptions_HTTPOptions
import moe.matsuri.nb4a.SingBoxOptions.V2RayTransportOptions_HTTPUpgradeOptions
import moe.matsuri.nb4a.SingBoxOptions.V2RayTransportOptions_WebsocketOptions
import moe.matsuri.nb4a.utils.NGUtil
import moe.matsuri.nb4a.utils.listByLineOrComma
import okhttp3.HttpUrl
@ -117,7 +129,7 @@ fun parseV2Ray(link: String): StandardV2RayBean {
}
}
"httpupgrade" -> {
"httpUpgrade" -> {
url.queryParameter("path")?.let {
bean.path = it
}
@ -225,7 +237,7 @@ fun StandardV2RayBean.parseDuckSoft(url: HttpUrl) {
}
}
"httpupgrade" -> {
"httpUpgrade" -> {
url.queryParameter("host")?.let {
host = it
}
@ -454,7 +466,7 @@ fun StandardV2RayBean.toUriVMessVLESSTrojan(isTrojan: Boolean): String {
when (type) {
"tcp" -> {}
"ws", "http", "httpupgrade" -> {
"ws", "http", "httpUpgrade" -> {
if (host.isNotBlank()) {
builder.addQueryParameter("host", host)
}
@ -583,9 +595,9 @@ fun buildSingBoxOutboundStreamSettings(bean: StandardV2RayBean): V2RayTransportO
}
}
"httpupgrade" -> {
"httpUpgrade" -> {
return V2RayTransportOptions_HTTPUpgradeOptions().apply {
type = "httpupgrade"
type = "httpUpgrade"
host = bean.host
path = bean.path
}

View File

@ -166,13 +166,15 @@ abstract class StandardV2RaySettingsActivity : ProfileSettingsActivity<StandardV
path.preference.isVisible = true
wsCategory.isVisible = true
}
"grpc" -> {
path.preference.setTitle(R.string.grpc_service_name)
path.preference.isVisible = true
}
"httpupgrade" -> {
host.preference.setTitle("HTTPUpgrade Host")
path.preference.setTitle("HTTPUpgrade Path")
"httpUpgrade" -> {
host.preference.setTitle(R.string.http_upgrade_host)
path.preference.setTitle(R.string.http_upgrade_path)
host.preference.isVisible = true
path.preference.isVisible = true
}

View File

@ -485,4 +485,6 @@
<string name="dynamic_record_sizing_disabled">禁用TLS记录的自适应调整大小</string>
<string name="dynamic_record_sizing_sum">如果启用将始终使用最大可能的TLS记录大小。当禁用时TLS记录的大小可能会进行调整以尝试提高延迟。</string>
<string name="ech_config">ECH 配置</string>
<string name="http_upgrade_host">HTTPUpgrade 主机</string>
<string name="http_upgrade_path">HTTPUpgrade 端口</string>
</resources>

View File

@ -263,7 +263,7 @@
<item>http</item>
<item>quic</item>
<item>grpc</item>
<item>httpupgrade</item>
<item>httpUpgrade</item>
</string-array>
<string-array name="trojan_go_networks_entry">

View File

@ -526,5 +526,7 @@ Anyone can write advanced plugins, which can control NekoBox. please download an
<string name="dynamic_record_sizing_disabled">Disables adaptive sizing of TLS records</string>
<string name="ech_config">ECH Config</string>
<string name="dynamic_record_sizing_sum">If enable, the largest possible TLS record size is always used. When disable, the size of TLS records may be adjusted in an attempt to improve latency.</string>
<string name="http_upgrade_host">HTTPUpgrade Host</string>
<string name="http_upgrade_path">HTTPUpgrade Path</string>
</resources>