refactor: Singbox's type name

This commit is contained in:
purofle 2023-11-01 23:13:32 +08:00
parent 612d1643d1
commit 3eb688d1e0
No known key found for this signature in database
GPG Key ID: 57DEC1478152D973
3 changed files with 11 additions and 8 deletions

View File

@ -71,6 +71,8 @@ public abstract class StandardV2RayBean extends AbstractBean {
if (JavaUtil.isNullOrBlank(type)) type = "tcp";
else if ("h2".equals(type)) type = "http";
type = type.toLowerCase();
if (JavaUtil.isNullOrBlank(host)) host = "";
if (JavaUtil.isNullOrBlank(path)) path = "";
@ -133,7 +135,7 @@ public abstract class StandardV2RayBean extends AbstractBean {
case "grpc": {
output.writeString(path);
}
case "httpUpgrade": {
case "httpupgrade": {
output.writeString(host);
output.writeString(path);
@ -185,7 +187,7 @@ public abstract class StandardV2RayBean extends AbstractBean {
case "grpc": {
path = input.readString();
}
case "httpUpgrade": {
case "httpupgrade": {
host = input.readString();
path = input.readString();
}

View File

@ -117,7 +117,7 @@ fun parseV2Ray(link: String): StandardV2RayBean {
}
}
"httpUpgrade" -> {
"httpupgrade" -> {
url.queryParameter("path")?.let {
bean.path = it
}
@ -225,7 +225,7 @@ fun StandardV2RayBean.parseDuckSoft(url: HttpUrl) {
}
}
"httpUpgrade" -> {
"httpupgrade" -> {
url.queryParameter("host")?.let {
host = it
}
@ -454,7 +454,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 +583,9 @@ fun buildSingBoxOutboundStreamSettings(bean: StandardV2RayBean): V2RayTransportO
}
}
"httpUpgrade" -> {
"httpupgrade" -> {
return V2RayTransportOptions_HTTPUpgradeOptions().apply {
type = "httpUpgrade"
type = "httpupgrade"
host = bean.host
path = bean.path
}

View File

@ -143,7 +143,7 @@ abstract class StandardV2RaySettingsActivity : ProfileSettingsActivity<StandardV
}
}
fun updateView(network: String) {
private fun updateView(network: String) {
host.preference.isVisible = false
path.preference.isVisible = false
wsCategory.isVisible = false
@ -153,6 +153,7 @@ abstract class StandardV2RaySettingsActivity : ProfileSettingsActivity<StandardV
host.preference.setTitle(R.string.http_host)
path.preference.setTitle(R.string.http_path)
}
"http" -> {
host.preference.setTitle(R.string.http_host)
path.preference.setTitle(R.string.http_path)