Browse Source

Refine shadowsocks

世界 3 years ago
parent
commit
e448fb7e2b

+ 1 - 1
.github/workflows/debug.yml

@@ -43,7 +43,7 @@ jobs:
         if: steps.cache.outputs.cache-hit != 'true'
         with:
           stable: false
-          go-version: 1.18.0
+          go-version: 1.18.1
       - name: Native Build
         if: steps.cache.outputs.cache-hit != 'true'
         run: ./run lib core

+ 1 - 1
.github/workflows/release.yml

@@ -46,7 +46,7 @@ jobs:
         if: steps.cache.outputs.cache-hit != 'true'
         with:
           stable: false
-          go-version: 1.18.0
+          go-version: 1.18.1
       - name: Gradle cache
         uses: actions/cache@v2
         if: steps.cache.outputs.cache-hit != 'true'

+ 3 - 3
app/build.gradle.kts

@@ -34,15 +34,15 @@ dependencies {
     compileOnly(project(":library:stub"))
     implementation(project(":library:include"))
 
-    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0")
+    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1")
     implementation("androidx.core:core-ktx:1.7.0")
     implementation("androidx.activity:activity-ktx:1.4.0")
     implementation("androidx.fragment:fragment-ktx:1.4.1")
     implementation("androidx.browser:browser:1.4.0")
     implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
     implementation("androidx.constraintlayout:constraintlayout:2.1.3")
-    implementation("androidx.navigation:navigation-fragment-ktx:2.4.1")
-    implementation("androidx.navigation:navigation-ui-ktx:2.4.1")
+    implementation("androidx.navigation:navigation-fragment-ktx:2.4.2")
+    implementation("androidx.navigation:navigation-ui-ktx:2.4.2")
     implementation("androidx.preference:preference-ktx:1.2.0")
     implementation("androidx.appcompat:appcompat:1.4.1")
     implementation("androidx.work:work-runtime-ktx:2.7.1")

+ 17 - 0
app/src/main/java/io/nekohasekai/sagernet/fmt/ConfigBuilder.kt

@@ -43,6 +43,7 @@ import io.nekohasekai.sagernet.fmt.http.HttpBean
 import io.nekohasekai.sagernet.fmt.internal.BalancerBean
 import io.nekohasekai.sagernet.fmt.internal.ChainBean
 import io.nekohasekai.sagernet.fmt.shadowsocks.ShadowsocksBean
+import io.nekohasekai.sagernet.fmt.shadowsocks.methodsSing
 import io.nekohasekai.sagernet.fmt.shadowsocksr.ShadowsocksRBean
 import io.nekohasekai.sagernet.fmt.socks.SOCKSBean
 import io.nekohasekai.sagernet.fmt.ssh.SSHBean
@@ -720,6 +721,22 @@ fun buildV2RayConfig(
                                     }
 
                                 }
+                            } else if (bean is ShadowsocksBean && bean.method in methodsSing && bean.plugin.isBlank() && !bean.uot) {
+                                protocol = "shadowsocks_sing"
+                                settings = LazyOutboundConfigurationObject(this,
+                                    ShadowsocksSingOutboundConfigurationObject().apply {
+                                        address = bean.serverAddress
+                                        port = bean.serverPort
+                                        method = bean.method
+                                        if (bean.method.startsWith("2022")) {
+                                            key = bean.password
+                                        } else {
+                                            password = bean.password
+                                        }
+                                        if (bean.experimentReducedIvHeadEntropy) {
+                                            reducedIvHeadEntropy = true
+                                        }
+                                    })
                             } else if (bean is ShadowsocksBean || bean is ShadowsocksRBean) {
                                 protocol = "shadowsocks"
                                 settings = LazyOutboundConfigurationObject(this,

+ 13 - 0
app/src/main/java/io/nekohasekai/sagernet/fmt/shadowsocks/ShadowsocksFmt.kt

@@ -33,6 +33,19 @@ import io.nekohasekai.sagernet.ktx.unUrlSafe
 import io.nekohasekai.sagernet.ktx.urlSafe
 import libcore.Libcore
 
+val methodsSing = arrayOf(
+    "none",
+    "none",
+    "aes-128-gcm",
+    "aes-192-gcm",
+    "aes-256-gcm",
+    "chacha20-ietf-poly1305",
+    "xchacha20-ietf-poly1305",
+    "2022-blake3-aes-128-gcm",
+    "2022-blake3-aes-256-gcm",
+    "2022-blake3-chacha20-poly1305"
+)
+
 fun PluginConfiguration.fixInvalidParams() {
 
     if (selected.contains("v2ray") && selected != "v2ray-plugin") {

+ 13 - 0
app/src/main/java/io/nekohasekai/sagernet/fmt/v2ray/V2RayConfig.java

@@ -476,6 +476,8 @@ public class V2RayConfig {
                     return VLESSOutboundConfigurationObject.class;
                 case "shadowsocks":
                     return ShadowsocksOutboundConfigurationObject.class;
+                case "shadowsocks_sing":
+                    return ShadowsocksSingOutboundConfigurationObject.class;
                 case "trojan":
                     return TrojanOutboundConfigurationObject.class;
                 case "loopback":
@@ -610,6 +612,17 @@ public class V2RayConfig {
 
     }
 
+    public static class ShadowsocksSingOutboundConfigurationObject implements OutboundConfigurationObject {
+
+        public String address;
+        public Integer port;
+        public String method;
+        public String password;
+        public String key;
+        public Boolean reducedIvHeadEntropy;
+
+    }
+
     public static class VLESSOutboundConfigurationObject implements OutboundConfigurationObject {
 
         public List<ServerObject> vnext;

+ 1 - 1
external/v2ray-core

@@ -1 +1 @@
-Subproject commit 89175c81b45947994b971350b91a890bd363933b
+Subproject commit 582522c1f550cb69da98af50665f5c39459d2b4d

+ 1 - 1
library/core

@@ -1 +1 @@
-Subproject commit 48a4e4d60f531aeb38ccaabe5658c9f12aa6101c
+Subproject commit bd0c89845eaa1995dd171b26b117709db0e37a49

+ 2 - 2
repositories.gradle.kts

@@ -1,6 +1,6 @@
 rootProject.extra.apply {
-    set("androidPluginVersion", "7.1.2")
-    set("kotlinVersion", "1.6.10")
+    set("androidPluginVersion", "7.1.3")
+    set("kotlinVersion", "1.6.21")
     set("hutoolVersion", "5.7.22")
 }
 

+ 2 - 2
sager.properties

@@ -1,6 +1,6 @@
 PACKAGE_NAME=io.nekohasekai.sagernet
-VERSION_NAME=0.8-beta02
-VERSION_CODE=162
+VERSION_NAME=0.8-beta03
+VERSION_CODE=163
 
 NAIVE_VERSION_NAME=100.0.4896.60-1
 NAIVE_VERSION=14