Skip to content

Commit 912a066

Browse files
committed
Remove advanced plugin
1 parent 2c3a616 commit 912a066

30 files changed

+111
-1246
lines changed

app/src/main/AndroidManifest.xml

-3
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,6 @@
191191
<activity
192192
android:name="moe.matsuri.nb4a.proxy.anytls.AnyTLSSettingsActivity"
193193
android:configChanges="uiMode" />
194-
<activity
195-
android:name="moe.matsuri.nb4a.proxy.neko.NekoSettingActivity"
196-
android:configChanges="uiMode" />
197194
<activity
198195
android:name="moe.matsuri.nb4a.proxy.config.ConfigSettingActivity"
199196
android:configChanges="uiMode" />

app/src/main/java/io/nekohasekai/sagernet/Constants.kt

-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ object Key {
147147

148148
//
149149

150-
const val NEKO_PLUGIN_MANAGED = "nekoPlugins"
151150
const val APP_TLS_VERSION = "appTLSVersion"
152151
const val ENABLE_CLASH_API = "enableClashAPI"
153152
}

app/src/main/java/io/nekohasekai/sagernet/bg/VpnService.kt

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ import io.nekohasekai.sagernet.fmt.hysteria.HysteriaBean
1616
import io.nekohasekai.sagernet.ktx.*
1717
import io.nekohasekai.sagernet.ui.VpnRequestActivity
1818
import io.nekohasekai.sagernet.utils.Subnet
19-
import libcore.*
20-
import moe.matsuri.nb4a.net.LocalResolverImpl
21-
import moe.matsuri.nb4a.proxy.neko.needBypassRootUid
2219
import android.net.VpnService as BaseVpnService
2320

2421
class VpnService : BaseVpnService(),
@@ -135,7 +132,7 @@ class VpnService : BaseVpnService(),
135132
var bypass = DataStore.bypass
136133
val workaroundSYSTEM = false /* DataStore.tunImplementation == TunImplementation.SYSTEM */
137134
val needBypassRootUid = workaroundSYSTEM || data.proxy!!.config.trafficMap.values.any {
138-
it[0].nekoBean?.needBypassRootUid() == true || it[0].hysteriaBean?.protocol == HysteriaBean.PROTOCOL_FAKETCP
135+
it[0].hysteriaBean?.protocol == HysteriaBean.PROTOCOL_FAKETCP
139136
}
140137

141138
if (proxyApps || needBypassRootUid) {

app/src/main/java/io/nekohasekai/sagernet/bg/proto/BoxInstance.kt

-55
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ import io.nekohasekai.sagernet.plugin.PluginManager
2121
import kotlinx.coroutines.*
2222
import libcore.BoxInstance
2323
import libcore.Libcore
24-
import moe.matsuri.nb4a.plugin.NekoPluginManager
25-
import moe.matsuri.nb4a.proxy.neko.NekoBean
26-
import moe.matsuri.nb4a.proxy.neko.NekoJSInterface
27-
import moe.matsuri.nb4a.proxy.neko.updateAllConfig
28-
import org.json.JSONObject
2924
import java.io.File
3025

3126
abstract class BoxInstance(
@@ -53,7 +48,6 @@ abstract class BoxInstance(
5348
}
5449

5550
protected open suspend fun loadConfig() {
56-
NekoJSInterface.Default.destroyAllJsi()
5751
box = Libcore.newSingBoxInstance(config.config)
5852
}
5953

@@ -88,17 +82,6 @@ abstract class BoxInstance(
8882
}
8983
}
9084
}
91-
92-
is NekoBean -> {
93-
// check if plugin binary can be loaded
94-
initPlugin(bean.plgId)
95-
96-
// build config and check if succeed
97-
bean.updateAllConfig(port)
98-
if (bean.allConfig == null) {
99-
throw NekoPluginManager.PluginInternalException(bean.protocolId)
100-
}
101-
}
10285
}
10386
}
10487
}
@@ -211,44 +194,6 @@ abstract class BoxInstance(
211194

212195
processes.start(commands)
213196
}
214-
215-
bean is NekoBean -> {
216-
// config built from JS
217-
val nekoRunConfigs = bean.allConfig.optJSONArray("nekoRunConfigs")
218-
val configs = mutableMapOf<String, String>()
219-
220-
nekoRunConfigs?.forEach { _, any ->
221-
any as JSONObject
222-
223-
val name = any.getString("name")
224-
val configFile = File(cacheDir, name)
225-
configFile.parentFile?.mkdirs()
226-
val content = any.getString("content")
227-
configFile.writeText(content)
228-
229-
cacheFiles.add(configFile)
230-
configs[name] = configFile.absolutePath
231-
232-
Logs.d(name + "\n\n" + content)
233-
}
234-
235-
val nekoCommands = bean.allConfig.getJSONArray("nekoCommands")
236-
val commands = mutableListOf<String>()
237-
238-
nekoCommands.forEach { _, any ->
239-
if (any is String) {
240-
if (configs.containsKey(any)) {
241-
commands.add(configs[any]!!)
242-
} else if (any == "%exe%") {
243-
commands.add(initPlugin(bean.plgId).path)
244-
} else {
245-
commands.add(any)
246-
}
247-
}
248-
}
249-
250-
processes.start(commands)
251-
}
252197
}
253198
}
254199
}

app/src/main/java/io/nekohasekai/sagernet/database/DataStore.kt

-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ object DataStore : OnPreferenceDataStoreChangeListener {
8181
return groups.find { it.type == GroupType.BASIC }!!.id
8282
}
8383

84-
var nekoPlugins by configurationStore.string(Key.NEKO_PLUGIN_MANAGED)
8584
var appTLSVersion by configurationStore.string(Key.APP_TLS_VERSION)
8685
var enableClashAPI by configurationStore.boolean(Key.ENABLE_CLASH_API)
8786
var showBottomBar by configurationStore.boolean(Key.SHOW_BOTTOM_BAR)

app/src/main/java/io/nekohasekai/sagernet/database/ProxyEntity.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ data class ProxyEntity(
239239
is SSHBean -> false
240240
is WireGuardBean -> false
241241
is ShadowTLSBean -> false
242-
is NekoBean -> nekoBean!!.haveStandardLink()
242+
is NekoBean -> false
243243
is ConfigBean -> false
244244
else -> true
245245
}
@@ -257,7 +257,7 @@ data class ProxyEntity(
257257
is HysteriaBean -> toUri()
258258
is TuicBean -> toUri()
259259
is AnyTLSBean -> toUri()
260-
is NekoBean -> shareLink()
260+
is NekoBean -> ""
261261
else -> toUniversalLink()
262262
}
263263
}
@@ -470,7 +470,6 @@ data class ProxyEntity(
470470
TYPE_SHADOWTLS -> ShadowTLSSettingsActivity::class.java
471471
TYPE_ANYTLS -> AnyTLSSettingsActivity::class.java
472472
TYPE_CHAIN -> ChainSettingsActivity::class.java
473-
TYPE_NEKO -> NekoSettingActivity::class.java
474473
TYPE_CONFIG -> ConfigSettingActivity::class.java
475474
else -> throw IllegalArgumentException()
476475
}

app/src/main/java/io/nekohasekai/sagernet/fmt/v2ray/StandardV2RayBean.java

+13-23
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ public abstract class StandardV2RayBean extends AbstractBean {
5454

5555
public String echConfig;
5656

57-
// sing-box 不再使用
58-
public Boolean enablePqSignature;
59-
60-
public Boolean disabledDRS;
61-
6257
// --------------------------------------- Mux
6358

6459
public Boolean enableMux;
@@ -108,8 +103,6 @@ public void initializeDefaultValues() {
108103

109104
if (enableECH == null) enableECH = false;
110105
if (JavaUtil.isNullOrBlank(echConfig)) echConfig = "";
111-
if (enablePqSignature == null) enablePqSignature = false;
112-
if (disabledDRS == null) disabledDRS = false;
113106

114107
if (enableMux == null) enableMux = false;
115108
if (muxPadding == null) muxPadding = false;
@@ -119,7 +112,7 @@ public void initializeDefaultValues() {
119112

120113
@Override
121114
public void serialize(ByteBufferOutput output) {
122-
output.writeInt(2);
115+
output.writeInt(3);
123116
super.serialize(output);
124117
output.writeString(uuid);
125118
output.writeString(encryption);
@@ -167,11 +160,7 @@ public void serialize(ByteBufferOutput output) {
167160
}
168161

169162
output.writeBoolean(enableECH);
170-
if (enableECH) {
171-
output.writeBoolean(enablePqSignature);
172-
output.writeBoolean(disabledDRS);
173-
output.writeString(echConfig);
174-
}
163+
output.writeString(echConfig);
175164

176165
output.writeInt(packetEncoding);
177166

@@ -229,16 +218,18 @@ public void deserialize(ByteBufferInput input) {
229218
realityShortId = input.readString();
230219
}
231220

232-
if (version >= 1) { // 从老版本升级上来
221+
if (version >= 1) {
233222
enableECH = input.readBoolean();
234-
if (enableECH) {
235-
enablePqSignature = input.readBoolean();
236-
disabledDRS = input.readBoolean();
223+
if (version >= 3) {
237224
echConfig = input.readString();
225+
} else {
226+
if (enableECH) {
227+
input.readBoolean();
228+
input.readBoolean();
229+
echConfig = input.readString();
230+
}
238231
}
239-
}
240-
241-
if (version == 0) {
232+
} else if (version == 0) {
242233
// 从老版本升级上来但是 version == 0, 可能有 enableECH 也可能没有,需要做判断
243234
int position = input.getByteBuffer().position(); // 当前位置
244235

@@ -250,8 +241,8 @@ public void deserialize(ByteBufferInput input) {
250241
if (tmpPacketEncoding != 1 && tmpPacketEncoding != 2) {
251242
enableECH = tmpEnableECH;
252243
if (enableECH) {
253-
enablePqSignature = input.readBoolean();
254-
disabledDRS = input.readBoolean();
244+
input.readBoolean();
245+
input.readBoolean();
255246
echConfig = input.readString();
256247
}
257248
} // 否则后一位就是 packetEncoding
@@ -275,7 +266,6 @@ public void applyFeatureSettings(AbstractBean other) {
275266
bean.utlsFingerprint = utlsFingerprint;
276267
bean.packetEncoding = packetEncoding;
277268
bean.enableECH = enableECH;
278-
bean.disabledDRS = disabledDRS;
279269
bean.echConfig = echConfig;
280270
bean.enableMux = enableMux;
281271
bean.muxPadding = muxPadding;

app/src/main/java/io/nekohasekai/sagernet/fmt/v2ray/VMessBean.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ public void initializeDefaultValues() {
1616
super.initializeDefaultValues();
1717

1818
alterId = alterId != null ? alterId : 0;
19-
encryption = JavaUtil.isNotBlank(encryption) ? encryption : "auto";
19+
20+
if (alterId == -1) {
21+
encryption = JavaUtil.isNotBlank(encryption) ? encryption : "";
22+
} else {
23+
encryption = JavaUtil.isNotBlank(encryption) ? encryption : "auto";
24+
}
2025
}
2126

2227
@NotNull

app/src/main/java/io/nekohasekai/sagernet/ktx/Formats.kt

+1-21
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ import io.nekohasekai.sagernet.fmt.trojan.parseTrojan
1414
import io.nekohasekai.sagernet.fmt.tuic.parseTuic
1515
import io.nekohasekai.sagernet.fmt.trojan_go.parseTrojanGo
1616
import io.nekohasekai.sagernet.fmt.v2ray.parseV2Ray
17-
import moe.matsuri.nb4a.plugin.NekoPluginManager
1817
import moe.matsuri.nb4a.proxy.anytls.parseAnytls
19-
import moe.matsuri.nb4a.proxy.neko.NekoJSInterface
20-
import moe.matsuri.nb4a.proxy.neko.parseShareLink
2118
import moe.matsuri.nb4a.utils.JavaUtil.gson
2219
import moe.matsuri.nb4a.utils.Util
2320
import org.json.JSONArray
@@ -112,7 +109,7 @@ suspend fun parseProxies(text: String): List<AbstractBean> {
112109
val entities = ArrayList<AbstractBean>()
113110
val entitiesByLine = ArrayList<AbstractBean>()
114111

115-
suspend fun String.parseLink(entities: ArrayList<AbstractBean>) {
112+
fun String.parseLink(entities: ArrayList<AbstractBean>) {
116113
if (startsWith("clash://install-config?") || startsWith("sn://subscription?")) {
117114
throw SubscriptionFoundException(this)
118115
}
@@ -211,22 +208,6 @@ suspend fun parseProxies(text: String): List<AbstractBean> {
211208
}.onFailure {
212209
Logs.w(it)
213210
}
214-
} else { // Neko Plugins
215-
NekoPluginManager.getProtocols().forEach { obj ->
216-
obj.protocolConfig.optJSONArray("links")?.forEach { _, any ->
217-
if (any is String && startsWith(any)) {
218-
runCatching {
219-
entities.add(
220-
parseShareLink(
221-
obj.plgId, obj.protocolId, this@parseLink
222-
)
223-
)
224-
}.onFailure {
225-
Logs.w(it)
226-
}
227-
}
228-
}
229-
}
230211
}
231212
}
232213

@@ -246,7 +227,6 @@ suspend fun parseProxies(text: String): List<AbstractBean> {
246227
}
247228
}
248229
}
249-
NekoJSInterface.Default.destroyAllJsi()
250230
return if (entities.size > entitiesByLine.size) entities else entitiesByLine
251231
}
252232

app/src/main/java/io/nekohasekai/sagernet/ui/AboutFragment.kt

+21-11
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,11 @@ class AboutFragment : ToolbarFragment(R.layout.layout_about) {
7575
}
7676

7777
return MaterialAboutList.Builder()
78-
.addCard(MaterialAboutCard.Builder()
78+
.addCard(
79+
MaterialAboutCard.Builder()
7980
.outline(false)
80-
.addItem(MaterialAboutActionItem.Builder()
81+
.addItem(
82+
MaterialAboutActionItem.Builder()
8183
.icon(R.drawable.ic_baseline_update_24)
8284
.text(R.string.app_version)
8385
.subText(versionName)
@@ -87,13 +89,15 @@ class AboutFragment : ToolbarFragment(R.layout.layout_about) {
8789
)
8890
}
8991
.build())
90-
.addItem(MaterialAboutActionItem.Builder()
92+
.addItem(
93+
MaterialAboutActionItem.Builder()
9194
.icon(R.drawable.ic_baseline_layers_24)
9295
.text(getString(R.string.version_x, "sing-box"))
9396
.subText(Libcore.versionBox())
9497
.setOnClickAction { }
9598
.build())
96-
.addItem(MaterialAboutActionItem.Builder()
99+
.addItem(
100+
MaterialAboutActionItem.Builder()
97101
.icon(R.drawable.ic_baseline_card_giftcard_24)
98102
.text(R.string.donate)
99103
.subText(R.string.donate_info)
@@ -107,9 +111,11 @@ class AboutFragment : ToolbarFragment(R.layout.layout_about) {
107111
PackageCache.awaitLoadSync()
108112
for ((_, pkg) in PackageCache.installedPluginPackages) {
109113
try {
110-
val pluginId = pkg.providers?.get(0)?.loadString(Plugins.METADATA_KEY_ID)
111-
if (pluginId.isNullOrBlank() || pluginId.startsWith(Plugins.AUTHORITIES_PREFIX_NEKO_PLUGIN)) continue
112-
addItem(MaterialAboutActionItem.Builder()
114+
val pluginId =
115+
pkg.providers?.get(0)?.loadString(Plugins.METADATA_KEY_ID)
116+
if (pluginId.isNullOrBlank()) continue
117+
addItem(
118+
MaterialAboutActionItem.Builder()
113119
.icon(R.drawable.ic_baseline_nfc_24)
114120
.text(
115121
getString(
@@ -137,7 +143,8 @@ class AboutFragment : ToolbarFragment(R.layout.layout_about) {
137143
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
138144
val pm = app.getSystemService(Context.POWER_SERVICE) as PowerManager
139145
if (!pm.isIgnoringBatteryOptimizations(app.packageName)) {
140-
addItem(MaterialAboutActionItem.Builder()
146+
addItem(
147+
MaterialAboutActionItem.Builder()
141148
.icon(R.drawable.ic_baseline_running_with_errors_24)
142149
.text(R.string.ignore_battery_optimizations)
143150
.subText(R.string.ignore_battery_optimizations_sum)
@@ -154,10 +161,12 @@ class AboutFragment : ToolbarFragment(R.layout.layout_about) {
154161
}
155162
}
156163
.build())
157-
.addCard(MaterialAboutCard.Builder()
164+
.addCard(
165+
MaterialAboutCard.Builder()
158166
.outline(false)
159167
.title(R.string.project)
160-
.addItem(MaterialAboutActionItem.Builder()
168+
.addItem(
169+
MaterialAboutActionItem.Builder()
161170
.icon(R.drawable.ic_baseline_sanitizer_24)
162171
.text(R.string.github)
163172
.setOnClickAction {
@@ -167,7 +176,8 @@ class AboutFragment : ToolbarFragment(R.layout.layout_about) {
167176
)
168177
}
169178
.build())
170-
.addItem(MaterialAboutActionItem.Builder()
179+
.addItem(
180+
MaterialAboutActionItem.Builder()
171181
.icon(R.drawable.ic_qu_shadowsocks_foreground)
172182
.text(R.string.telegram)
173183
.setOnClickAction {

0 commit comments

Comments
 (0)