This commit is contained in:
2dust
2024-02-10 11:59:00 +08:00
parent eb75666c85
commit ce2d1c5e0d

View File

@@ -780,7 +780,8 @@ object AngConfigManager {
dicQuery["reserved"] = Utils.urlEncode(
Utils.removeWhiteSpace(outbound.settings?.reserved?.joinToString())
.toString()
)}
)
}
dicQuery["address"] = Utils.urlEncode(
Utils.removeWhiteSpace((outbound.settings?.address as List<*>).joinToString())
.toString()
@@ -986,23 +987,32 @@ object AngConfigManager {
&& server.contains("outbounds")
&& server.contains("routing")
) {
try {
val gson = GsonBuilder().setPrettyPrinting().create()
val serverList: Array<V2rayConfig> = Gson().fromJson(server, Array<V2rayConfig>::class.java)
if (serverList.size > 0) {
val serverList: Array<V2rayConfig> =
Gson().fromJson(server, Array<V2rayConfig>::class.java)
if (serverList.isNotEmpty()) {
var count = 0
for (srv in serverList) {
if (srv.inbounds != null && srv.outbounds != null && srv.routing != null) {
var config = ServerConfig.create(EConfigType.CUSTOM)
config.remarks = srv.remarks ?: "%04d-".format(count + 1) + System.currentTimeMillis().toString()
val config = ServerConfig.create(EConfigType.CUSTOM)
config.remarks = srv.remarks
?: ("%04d-".format(count + 1) + System.currentTimeMillis()
.toString())
config.subscriptionId = subid
config.fullConfig = srv
var key = MmkvManager.encodeServerConfig("", config)
val key = MmkvManager.encodeServerConfig("", config)
serverRawStorage?.encode(key, gson.toJson(srv))
count = count + 1
count += 1
}
}
return count
} else { // For compatibility
}
} catch (e: Exception) {
e.printStackTrace()
}
// For compatibility
val config = ServerConfig.create(EConfigType.CUSTOM)
config.subscriptionId = subid
config.fullConfig = Gson().fromJson(server, V2rayConfig::class.java)
@@ -1011,7 +1021,6 @@ object AngConfigManager {
val key = MmkvManager.encodeServerConfig("", config)
serverRawStorage?.encode(key, server)
return 1
}
} else {
return 0
}