Skip to content

Commit

Permalink
Update singbox to 1.2-beta5 and add shadowtls-v3 with utls support (#28)
Browse files Browse the repository at this point in the history
* Update singbox to 1.2-beta5 and add shadowtls-v3 with utls support

* Update translate.js
  • Loading branch information
hibobmaster authored Feb 27, 2023
1 parent 1c9346d commit aeae2a6
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app_singbox/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ setupAll()
android {
defaultConfig {
applicationId = "moe.matsuri.plugin.singbox"
versionCode = 2
versionName = "v1.1.2"
versionCode = 3
versionName = "v1.2-beta5"
splits.abi {
reset()
include("arm64-v8a", "x86_64")
Expand Down
4 changes: 2 additions & 2 deletions download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ download_xray() {

download_singbox() {
mkdir_libs "app_singbox/libs"
curl -Lso singbox.tar.gz "https://github.com/SagerNet/sing-box/releases/download/v1.1.2/sing-box-1.1.2-android-arm64.tar.gz"
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"
unzip_singbox arm64-v8a
curl -Lso singbox.tar.gz "https://github.com/SagerNet/sing-box/releases/download/v1.1.2/sing-box-1.1.2-android-amd64.tar.gz"
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"
unzip_singbox x86_64
}

Expand Down
4 changes: 4 additions & 0 deletions js/common/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ export var translates = {
"zh_CN": "服务器名称指示",
"": "SNI",
},
utlsEnabled: {
"zh_CN": "uTLS 开关",
"": "uTLS Enabled",
},
utlsFingerprint: {
"zh_CN": "uTLS 指纹",
"": "uTLS Fingerprint",
Expand Down
77 changes: 76 additions & 1 deletion js/plugin_singbox/shadowtls.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class shadowTlsClass {
this.defaultSharedStorage.shadowTlsServerName = "";
this.defaultSharedStorage.shadowTlsServerPassword = "";
this.defaultSharedStorage.shadowTlsVersion = "2";
this.defaultSharedStorage.utlsEnabled = false;
this.defaultSharedStorage.utlsFingerprint = "chrome";

for (var k in this.defaultSharedStorage) {
let v = this.defaultSharedStorage[k];
Expand Down Expand Up @@ -80,6 +82,7 @@ class shadowTlsClass {
entries: {
1: "1",
2: "2",
3: "3"
},
},
{
Expand All @@ -103,6 +106,31 @@ class shadowTlsClass {
icon: "ic_settings_password",
summaryProvider: "PasswordSummaryProvider",
},
{
type: "SimpleMenuPreference",
key: "utlsEnabled",
icon: "ic_baseline_vpn_key_24",
entries: {
"true": "true",
"false": "false",
},
},
{
type: "SimpleMenuPreference",
key: "utlsFingerprint",
icon: "ic_baseline_fiber_manual_record_24",
entries: {
"chrome": "chrome",
"firefox": "firefox",
"edge": "edge",
"safari": "safari",
"360": "360",
"qq": "qq",
"ios": "ios",
"android": "android",
"random": "random",
}
},
],
},
];
Expand All @@ -122,9 +150,20 @@ class shadowTlsClass {
this.common.setKV(k, this.sharedStorage[k]);
}
}
// 开启设置界面时调用

// 设置界面创建后调用
onPreferenceCreated() { }
onPreferenceCreated() {
let this2 = this

function listenOnPreferenceChangedNow(key) {
neko.listenOnPreferenceChanged(key)
this2._onPreferenceChanged(key, this2.sharedStorage[key])
}

listenOnPreferenceChangedNow("utlsEnabled")
listenOnPreferenceChangedNow("shadowTlsVersion")
}

// 保存时调用(混合编辑后的值)
sharedStorageFromProfileCache() {
Expand All @@ -135,6 +174,26 @@ class shadowTlsClass {
return JSON.stringify(this.sharedStorage);
}

// 用户修改 preference 时调用
onPreferenceChanged(b64Str) {
let args = util.decodeB64Str(b64Str)
this._onPreferenceChanged(args.key, args.newValue)
}

_onPreferenceChanged(key, newValue) {
if (key == "utlsEnabled") {
neko.setPreferenceVisibility("utlsFingerprint", false)
if (newValue == "true") {
neko.setPreferenceVisibility("utlsFingerprint", true)
}
} else if (key == "shadowTlsVersion") {
neko.setPreferenceVisibility("shadowTlsServerPassword", true)
if (newValue == "1") {
neko.setPreferenceVisibility("shadowTlsServerPassword", false)
}
}
}

// Interface

parseShareLink(b64Str) { }
Expand All @@ -144,6 +203,13 @@ class shadowTlsClass {
let args = util.decodeB64Str(b64Str);
let ss = util.decodeB64Str(args.sharedStorage);

// convert string to boolean
if (ss.utlsEnabled === "true"){
ss.utlsEnabled = true
} else {
ss.utlsEnabled = false
}

let t0 = {
log: {
disabled: false,
Expand Down Expand Up @@ -180,11 +246,20 @@ class shadowTlsClass {
tls: {
enabled: true,
server_name: ss.shadowTlsServerName,
utls: {
enabled: ss.utlsEnabled,
fingerprint: ss.utlsFingerprint
}
},
},
],
};

// check shadowTlsVersion if = 1, remove password entity from config
if (ss.shadowTlsVersion == 1) {
delete t0.outbounds[1].password;
}

let v = {};
v.nekoCommands = ["%exe%", "run", "--config", "config.json"];

Expand Down

0 comments on commit aeae2a6

Please sign in to comment.