Skip to content

Commit

Permalink
refactor: Singbox's type name
Browse files Browse the repository at this point in the history
  • Loading branch information
purofle committed Nov 1, 2023
1 parent 612d164 commit 3eb688d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public void initializeDefaultValues() {
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 = "";

Expand Down Expand Up @@ -133,7 +135,7 @@ public void serialize(ByteBufferOutput output) {
case "grpc": {
output.writeString(path);
}
case "httpUpgrade": {
case "httpupgrade": {
output.writeString(host);
output.writeString(path);

Expand Down Expand Up @@ -185,7 +187,7 @@ public void deserialize(ByteBufferInput input) {
case "grpc": {
path = input.readString();
}
case "httpUpgrade": {
case "httpupgrade": {
host = input.readString();
path = input.readString();
}
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/io/nekohasekai/sagernet/fmt/v2ray/V2RayFmt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ fun parseV2Ray(link: String): StandardV2RayBean {
}
}

"httpUpgrade" -> {
"httpupgrade" -> {
url.queryParameter("path")?.let {
bean.path = it
}
Expand Down Expand Up @@ -225,7 +225,7 @@ fun StandardV2RayBean.parseDuckSoft(url: HttpUrl) {
}
}

"httpUpgrade" -> {
"httpupgrade" -> {
url.queryParameter("host")?.let {
host = it
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 3eb688d

Please sign in to comment.