@@ -11,7 +11,6 @@ import io.nekohasekai.sagernet.fmt.LOCALHOST
1111import io.nekohasekai.sagernet.fmt.buildConfig
1212import io.nekohasekai.sagernet.fmt.hysteria.HysteriaBean
1313import io.nekohasekai.sagernet.fmt.hysteria.buildHysteria1Config
14- import io.nekohasekai.sagernet.fmt.hysteria.buildHysteria2SidecarConfig
1514import io.nekohasekai.sagernet.fmt.masterdnsvpn.MasterDnsVpnBean
1615import io.nekohasekai.sagernet.fmt.masterdnsvpn.buildMasterDnsVpnConfig
1716import io.nekohasekai.sagernet.fmt.masterdnsvpn.resolverLines
@@ -82,26 +81,16 @@ abstract class BoxInstance(
8281 }
8382
8483 is HysteriaBean -> {
85- if (bean.protocolVersion == 2 &&
86- bean.hysteria2ObfsType == HysteriaBean .OBFS_GECKO
87- ) {
88- // Gecko obfs: use the bundled official hysteria binary sidecar.
89- // Loopback-only SOCKS5 (no auth), matching the other sidecars
90- // (Mieru/Naive); the sing-box socks outbound dials 127.0.0.1:port.
91- initPlugin(" hysteria2-plugin" )
92- pluginConfigs[port] = profile.type to bean.buildHysteria2SidecarConfig(
93- port,
94- File (app.noBackupFilesDir, " protect_path" ).absolutePath
95- )
96- } else {
97- initPlugin(" hysteria-plugin" )
98- pluginConfigs[port] = profile.type to bean.buildHysteria1Config(port) {
99- File (
100- app.cacheDir, " hysteria_" + SystemClock .elapsedRealtime() + " .ca"
101- ).apply {
102- parentFile?.mkdirs()
103- cacheFiles.add(this )
104- }
84+ // Only reached via the external path (needExternal == !canUseSingBox).
85+ // Hysteria2 (incl. Gecko obfs) runs natively in sing-box now, so the
86+ // external path is Hysteria v1 only.
87+ initPlugin(" hysteria-plugin" )
88+ pluginConfigs[port] = profile.type to bean.buildHysteria1Config(port) {
89+ File (
90+ app.cacheDir, " hysteria_" + SystemClock .elapsedRealtime() + " .ca"
91+ ).apply {
92+ parentFile?.mkdirs()
93+ cacheFiles.add(this )
10594 }
10695 }
10796 }
@@ -199,30 +188,6 @@ abstract class BoxInstance(
199188 processes.start(commands, envMap)
200189 }
201190
202- bean is HysteriaBean && bean.protocolVersion == 2 &&
203- bean.hysteria2ObfsType == HysteriaBean .OBFS_GECKO -> {
204- // Official apernet/hysteria client binary (Gecko obfs sidecar).
205- // viper detects the config format from the .json extension.
206- val configFile = File (
207- cacheDir, " hysteria2_" + SystemClock .elapsedRealtime() + " .json"
208- )
209- configFile.parentFile?.mkdirs()
210- configFile.writeText(config)
211- cacheFiles.add(configFile)
212-
213- val commands = mutableListOf (
214- initPlugin(" hysteria2-plugin" ).path,
215- " --disable-update-check" ,
216- " --config" ,
217- configFile.absolutePath,
218- " --log-level" ,
219- if (DataStore .logLevel > 0 ) " debug" else " warn" ,
220- " client"
221- )
222-
223- processes.start(commands)
224- }
225-
226191 bean is HysteriaBean -> {
227192 val configFile = File (
228193 cacheDir, " hysteria_" + SystemClock .elapsedRealtime() + " .json"
0 commit comments