Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

升级xray核心至1.8.0,支持reality协议 #34

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions app_singbox/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ setupAll()
android {
defaultConfig {
applicationId = "moe.matsuri.plugin.singbox"
versionCode = 4
versionName = "v1.2-beta5-2"
splits.abi {
reset()
include("arm64-v8a", "x86_64")
}
versionCode = 6
versionName = "v1.2.0"
}
}
4 changes: 2 additions & 2 deletions app_xray/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ setupAll()
android {
defaultConfig {
applicationId = "moe.matsuri.plugin.xray"
versionCode = 11
versionName = "v1.7.5-1"
versionCode = 13
versionName = "v1.8.0-3"
}
}
11 changes: 8 additions & 3 deletions download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ unzip_singbox() {
}

download_xray() {
VERSION="v1.7.5"
VERSION="v1.8.0"
mkdir_libs "app_xray/libs"

curl -Lso xray.zip "https://github.com/XTLS/Xray-core/releases/download/$VERSION/Xray-android-arm64-v8a.zip"
Expand All @@ -37,10 +37,15 @@ download_xray() {
}

download_singbox() {
VERSION="1.2.0"
mkdir_libs "app_singbox/libs"
curl -Lso singbox.tar.gz "https://github.com/SagerNet/sing-box/releases/download/v1.2-beta5/sing-box-1.2-beta5-android-arm64.tar.gz"
curl -Lso singbox.tar.gz "https://github.com/SagerNet/sing-box/releases/download/v$VERSION/sing-box-$VERSION-android-arm64.tar.gz"
unzip_singbox arm64-v8a
curl -Lso singbox.tar.gz "https://github.com/SagerNet/sing-box/releases/download/v1.2-beta5/sing-box-1.2-beta5-android-amd64.tar.gz"
curl -Lso singbox.tar.gz "https://github.com/SagerNet/sing-box/releases/download/v$VERSION/sing-box-$VERSION-android-armv7.tar.gz"
unzip_singbox armeabi-v7a
curl -Lso singbox.tar.gz "https://github.com/SagerNet/sing-box/releases/download/v$VERSION/sing-box-$VERSION-android-386.tar.gz"
unzip_singbox x86
curl -Lso singbox.tar.gz "https://github.com/SagerNet/sing-box/releases/download/v$VERSION/sing-box-$VERSION-android-amd64.tar.gz"
unzip_singbox x86_64
}

Expand Down
14 changes: 11 additions & 3 deletions js/common/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,17 @@ export var translates = {
"zh_CN": "该配置 (不安全) 能够被检测识别,传输的内容对审查者完全可见,并且无法抵抗中间人篡改通讯内容.",
"": "The configuration (insecure) can be detected and identified, the transmission is fully visible to the censor and is not resistant to man-in-the-middle tampering with the content of the communication.",
},
insecure_xtls: {
"zh_CN": "该配置 (XTLS) 能够被检测识别.",
"": "This configuration (XTLS) can be detected and identified.",
serverUoT: {
"": "UDP over TCP",
},
publicKey: {
"": "PublicKey",
},
shortId: {
"": "ShortId",
},
spiderX: {
"": "SpiderX",
},

// Brook
Expand Down
8 changes: 8 additions & 0 deletions js/plugin_xray/ss2022.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class ss2022Class {
// end of default keys
this.defaultSharedStorage.serverMethod = "2022-blake3-aes-128-gcm"
this.defaultSharedStorage.serverPassword = ""
// UDP over TCP
this.defaultSharedStorage.serverUoT = false

for (var k in this.defaultSharedStorage) {
let v = this.defaultSharedStorage[k]
Expand Down Expand Up @@ -76,6 +78,11 @@ class ss2022Class {
"icon": "ic_baseline_person_24",
"summaryProvider": "PasswordSummaryProvider",
},
{
"type": "SwitchPreference",
"key": "serverUoT",
"icon": "baseline_wrap_text_24",
},
]
}
]
Expand Down Expand Up @@ -142,6 +149,7 @@ class ss2022Class {
"port": args.finalPort,
"method": ss.serverMethod,
"password": ss.serverPassword,
"uot": ss.serverUoT,
}
]
}
Expand Down
100 changes: 58 additions & 42 deletions js/plugin_xray/vless.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class vlessClass {

_initDefaultSharedStorage() {
// start of default keys
this.defaultSharedStorage.jsVersion = 1
this.defaultSharedStorage.jsVersion = 2
this.defaultSharedStorage.insecureHint = ""
this.defaultSharedStorage.name = ""
this.defaultSharedStorage.serverAddress = "127.0.0.1"
Expand All @@ -32,9 +32,12 @@ class vlessClass {
this.defaultSharedStorage.serverSNI = ""
this.defaultSharedStorage.serverALPN = ""
this.defaultSharedStorage.serverCertificates = ""
this.defaultSharedStorage.serverFlow = "xtls-rprx-origin"
this.defaultSharedStorage.serverFlowVision = ""
this.defaultSharedStorage.serverAllowInsecure = false
// reality
this.defaultSharedStorage.publicKey = ""
this.defaultSharedStorage.shortId = ""
this.defaultSharedStorage.spiderX = ""

for (var k in this.defaultSharedStorage) {
let v = this.defaultSharedStorage[k]
Expand All @@ -61,8 +64,6 @@ class vlessClass {
_insecureHint() {
if (this.sharedStorage.serverSecurity == "none") {
return TR("insecure_cleartext")
} else if (this.sharedStorage.serverSecurity == "xtls") {
return TR("insecure_xtls")
}
return ""
}
Expand Down Expand Up @@ -138,16 +139,22 @@ class vlessClass {
}
break
}
case "xtls": {
case "reality": {
if (this.sharedStorage.serverSNI.isNotBlank()) {
builder.searchParams.set("sni", this.sharedStorage.serverSNI)
}
if (this.sharedStorage.serverALPN.isNotBlank()) {
builder.searchParams.set("alpn", this.sharedStorage.serverALPN)
}
if (this.sharedStorage.serverFlow.isNotBlank()) {
builder.searchParams.set("flow", this.sharedStorage.serverFlow)
}
if (this.sharedStorage.publicKey.isNotBlank()) {
builder.searchParams.set("publicKey", this.sharedStorage.publicKey)
}
if (this.sharedStorage.shortId.isNotBlank()) {
builder.searchParams.set("shortId", this.sharedStorage.shortId)
}
if (this.sharedStorage.spiderX.isNotBlank()) {
builder.searchParams.set("spiderX", this.sharedStorage.spiderX)
}
break
}
}
Expand Down Expand Up @@ -233,7 +240,7 @@ class vlessClass {
"entries": {
"none": "none",
"tls": "tls",
"xtls": "xtls",
"reality": "reality",
}
},
{
Expand Down Expand Up @@ -278,25 +285,12 @@ class vlessClass {
"key": "serverCertificates",
"icon": "ic_baseline_vpn_key_24"
},
{
"type": "SimpleMenuPreference",
"key": "serverFlow",
"icon": "ic_baseline_stream_24",
"entries": {
"xtls-rprx-origin": "xtls-rprx-origin",
"xtls-rprx-origin-udp443": "xtls-rprx-origin-udp443",
"xtls-rprx-direct": "xtls-rprx-direct",
"xtls-rprx-direct-udp443": "xtls-rprx-direct-udp443",
"xtls-rprx-splice": "xtls-rprx-splice",
"xtls-rprx-splice-udp443": "xtls-rprx-splice-udp443",
}
},
{
"type": "SimpleMenuPreference",
"key": "serverFlowVision",
"icon": "ic_baseline_stream_24",
"entries": {
"none": "",
"": "",
"xtls-rprx-vision": "xtls-rprx-vision",
"xtls-rprx-vision-udp443": "xtls-rprx-vision-udp443"
}
Expand All @@ -307,8 +301,22 @@ class vlessClass {
"icon": "ic_notification_enhanced_encryption",
"summary": TR("serverAllowInsecure_summary")
},
{
"type": "EditTextPreference",
"key": "publicKey",
"icon": "ic_baseline_vpn_key_24"
},
{
"type": "EditTextPreference",
"key": "shortId",
"icon": "ic_baseline_texture_24"
},
{
"type": "EditTextPreference",
"key": "spiderX",
"icon": "ic_baseline_format_align_left_24"
},
]

}
]
this.common._applyTranslateToPreferenceScreenConfig(sb, TR)
Expand Down Expand Up @@ -414,10 +422,13 @@ class vlessClass {
neko.setPreferenceVisibility("serverSecurityCategory", false)
} else {
neko.setPreferenceVisibility("serverSecurityCategory", true)
let isXTLS = (newValue == "xtls")
neko.setPreferenceVisibility("serverFlow", isXTLS)
neko.setPreferenceVisibility("serverFlowVision", !isXTLS)
neko.setPreferenceVisibility("utlsFingerprint", !isXTLS)
let isREALITY = (newValue == "reality")
neko.setPreferenceVisibility("publicKey", isREALITY)
neko.setPreferenceVisibility("shortId", isREALITY)
neko.setPreferenceVisibility("spiderX", isREALITY)
neko.setPreferenceVisibility("serverALPN", !isREALITY)
neko.setPreferenceVisibility("serverCertificates", !isREALITY)
neko.setPreferenceVisibility("serverAllowInsecure", !isREALITY)
}
}
}
Expand Down Expand Up @@ -467,17 +478,23 @@ class vlessClass {
})
break
}
case "xtls": {
this.sharedStorage.serverSecurity = "xtls"
case "reality": {
this.sharedStorage.serverSecurity = "reality"
util.ifNotNull(url.searchParams.get("sni"), (it) => {
this.sharedStorage.serverSNI = it
})
util.ifNotNull(url.searchParams.get("alpn"), (it) => {
this.sharedStorage.serverALPN = it
})
util.ifNotNull(url.searchParams.get("flow"), (it) => {
this.sharedStorage.serverFlow = it
})
util.ifNotNull(url.searchParams.get("publicKey"), (it) => {
this.sharedStorage.publicKey = it
})
util.ifNotNull(url.searchParams.get("shortId"), (it) => {
this.sharedStorage.shortId = it
})
util.ifNotNull(url.searchParams.get("spiderX"), (it) => {
this.sharedStorage.spiderX = it
})
break
}
}
Expand Down Expand Up @@ -547,10 +564,7 @@ class vlessClass {

let canMux = false
if (ss.serverNetwork == "tcp" || ss.serverNetwork == "ws" || ss.serverNetwork == "h2") {
canMux = true
}
if (ss.serverSecurity == "xtls") {
canMux = false
canMux = ss.serverFlowVision.isBlank()
}

let t0 = {
Expand Down Expand Up @@ -675,14 +689,16 @@ class vlessClass {
t0.outbounds[0].settings.vnext[0].users[0]["flow"] = ss.serverFlowVision
break
}
case "xtls": {
case "reality": {
let t2 = {
"serverName": ss.serverSNI,
"allowInsecure": ss.serverAllowInsecure,
}
if (ss.serverCertificates.isNotBlank()) t2["certificates"] = { "certificate": ss.serverCertificates.lines() }
t0.outbounds[0].streamSettings["xtlsSettings"] = t2
t0.outbounds[0].settings.vnext[0].users[0]["flow"] = ss.serverFlow
if (ss.utlsFingerprint.isNotBlank()) t2["fingerprint"] = ss.utlsFingerprint
if (ss.publicKey.isNotBlank()) t2["publicKey"] = ss.publicKey
if (ss.shortId.isNotBlank()) t2["shortId"] = ss.shortId
if (ss.spiderX.isNotBlank()) t2["spiderX"] = ss.spiderX
t0.outbounds[0].streamSettings["realitySettings"] = t2
t0.outbounds[0].settings.vnext[0].users[0]["flow"] = ss.serverFlowVision
break
}
}
Expand Down
Binary file modified release.keystore
Binary file not shown.