Skip to content

Commit

Permalink
feat: Add supports for HTTPUpgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
Misaka-blog committed Nov 1, 2023
1 parent a82e5b4 commit e805fe7
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public abstract class StandardV2RayBean extends AbstractBean {

//////// End of VMess & VLESS ////////

// "V2Ray Transport" tcp/http/ws/quic/grpc
// "V2Ray Transport" tcp/http/ws/quic/grpc/httpupgrade
public String type;

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

}
}

output.writeString(security);
Expand Down Expand Up @@ -180,6 +185,10 @@ public void deserialize(ByteBufferInput input) {
case "grpc": {
path = input.readString();
}
case "httpupgrade": {
host = input.readString();
path = input.readString();
}
}

security = input.readString();
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/java/io/nekohasekai/sagernet/fmt/v2ray/V2RayFmt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ fun parseV2Ray(link: String): StandardV2RayBean {
bean.path = it
}
}

"httpupgrade" -> {
url.queryParameter("path")?.let {
bean.path = it
}
url.queryParameter("host")?.let {
bean.host = it
}
}
}
} else {
// also vless format
Expand Down Expand Up @@ -215,6 +224,15 @@ fun StandardV2RayBean.parseDuckSoft(url: HttpUrl) {
path = it
}
}

"httpupgrade" -> {
url.queryParameter("host")?.let {
host = it
}
url.queryParameter("path")?.let {
path = it
}
}
}

// maybe from matsuri vmess exoprt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ abstract class StandardV2RaySettingsActivity : ProfileSettingsActivity<StandardV
path.preference.setTitle(R.string.grpc_service_name)
path.preference.isVisible = true
}
"httpupgrade" -> {
host.preference.setTitle("HTTPUpgrade Host")
path.preference.setTitle("HTTPUpgrade Path")
host.preference.isVisible = true
path.preference.isVisible = true
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/moe/matsuri/nb4a/SingBoxOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -2447,6 +2447,16 @@ public static class V2RayGRPCOptions extends SingBoxOption {

}

public static class V2RayHTTPUpgradeOptions extends SingBoxOption {

public String host;

public String path;

public Map<String, String> headers;

}

public static class VLESSInboundOptions extends SingBoxOption {

// Generate note: nested type ListenOptions
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@
<item>http</item>
<item>quic</item>
<item>grpc</item>
<item>httpupgrade</item>
</string-array>

<string-array name="trojan_go_networks_entry">
Expand Down

0 comments on commit e805fe7

Please sign in to comment.