mirror of
https://github.com/openlibrecommunity/olcng.git
synced 2026-07-03 14:05:17 +02:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b92a6cdfac | |||
| 45da2479dd | |||
| 1c936b2b31 | |||
| dbe109eedb | |||
| 7705aded77 | |||
| 4a2d62b671 | |||
| 4acca4e554 | |||
| b875613fb3 | |||
| d9d21061fa | |||
| fc7804fc1e | |||
| 4e9de615a4 | |||
| 7617ce898c | |||
| 8d284fd68a | |||
| 0f28310801 | |||
| a46123aeab |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -125,7 +125,7 @@ object AppConfig {
|
|||||||
|
|
||||||
const val DNS_PROXY = "https://1.1.1.1/dns-query"
|
const val DNS_PROXY = "https://1.1.1.1/dns-query"
|
||||||
const val DNS_DIRECT = "223.5.5.5"
|
const val DNS_DIRECT = "223.5.5.5"
|
||||||
const val DNS_VPN = "https://1.1.1.1/dns-query"
|
const val DNS_VPN = "1.1.1.1"
|
||||||
const val GEOSITE_PRIVATE = "geosite:private"
|
const val GEOSITE_PRIVATE = "geosite:private"
|
||||||
const val GEOSITE_CN = "geosite:cn"
|
const val GEOSITE_CN = "geosite:cn"
|
||||||
const val GEOIP_PRIVATE = "geoip:private"
|
const val GEOIP_PRIVATE = "geoip:private"
|
||||||
|
|||||||
@@ -273,13 +273,22 @@ object AngConfigManager {
|
|||||||
private fun batchSaveConfigs(configs: List<ProfileItem>, subid: String): Map<String, ProfileItem> {
|
private fun batchSaveConfigs(configs: List<ProfileItem>, subid: String): Map<String, ProfileItem> {
|
||||||
val keyToProfile = mutableMapOf<String, ProfileItem>()
|
val keyToProfile = mutableMapOf<String, ProfileItem>()
|
||||||
|
|
||||||
// Read serverList once
|
|
||||||
val serverList = MmkvManager.decodeServerList(subid)
|
val serverList = MmkvManager.decodeServerList(subid)
|
||||||
var needSetSelected = MmkvManager.getSelectServer().isNullOrBlank()
|
var needSetSelected = MmkvManager.getSelectServer().isNullOrBlank()
|
||||||
|
|
||||||
|
val existingProfiles = serverList.mapNotNull { guid ->
|
||||||
|
MmkvManager.decodeServerConfig(guid)?.let { guid to it }
|
||||||
|
}.toMap()
|
||||||
|
|
||||||
configs.forEach { config ->
|
configs.forEach { config ->
|
||||||
|
val existingKey = existingProfiles.entries.firstOrNull { (_, existing) ->
|
||||||
|
existing == config
|
||||||
|
}?.key
|
||||||
|
|
||||||
|
if (existingKey != null) {
|
||||||
|
keyToProfile[existingKey] = config
|
||||||
|
} else {
|
||||||
val key = Utils.getUuid()
|
val key = Utils.getUuid()
|
||||||
// Save profile directly without updating serverList
|
|
||||||
MmkvManager.encodeProfileDirect(key, JsonUtil.toJson(config))
|
MmkvManager.encodeProfileDirect(key, JsonUtil.toJson(config))
|
||||||
|
|
||||||
if (!serverList.contains(key)) {
|
if (!serverList.contains(key)) {
|
||||||
@@ -291,8 +300,8 @@ object AngConfigManager {
|
|||||||
}
|
}
|
||||||
keyToProfile[key] = config
|
keyToProfile[key] = config
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Write serverList once
|
|
||||||
MmkvManager.encodeServerList(serverList, subid)
|
MmkvManager.encodeServerList(serverList, subid)
|
||||||
return keyToProfile
|
return keyToProfile
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -346,7 +346,7 @@ object SettingsManager {
|
|||||||
*/
|
*/
|
||||||
fun getVpnDnsServers(): List<String> {
|
fun getVpnDnsServers(): List<String> {
|
||||||
val vpnDns = MmkvManager.decodeSettingsString(AppConfig.PREF_VPN_DNS) ?: AppConfig.DNS_VPN
|
val vpnDns = MmkvManager.decodeSettingsString(AppConfig.PREF_VPN_DNS) ?: AppConfig.DNS_VPN
|
||||||
return vpnDns.split(",").filter { Utils.isPureIpAddress(it) }
|
return vpnDns.split(",").filter { it.isNotBlank() && Utils.isPureIpAddress(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -94,18 +94,23 @@ object SpeedtestManager {
|
|||||||
var result: String
|
var result: String
|
||||||
var elapsed = -1L
|
var elapsed = -1L
|
||||||
|
|
||||||
val conn = HttpUtil.createProxyConnection(SettingsManager.getDelayTestUrl(), port, 15000, 15000) ?: return Pair(elapsed, "")
|
val testUrl = "https://icanhazip.com"
|
||||||
|
val conn = HttpUtil.createProxyConnection(testUrl, port, 15000, 15000) ?: return Pair(elapsed, "")
|
||||||
try {
|
try {
|
||||||
val start = SystemClock.elapsedRealtime()
|
val start = SystemClock.elapsedRealtime()
|
||||||
val code = conn.responseCode
|
val code = conn.responseCode
|
||||||
|
|
||||||
|
if (code != 200) {
|
||||||
|
throw IOException(context.getString(R.string.connection_test_error_status_code, code))
|
||||||
|
}
|
||||||
|
|
||||||
|
val responseBody = conn.inputStream.bufferedReader().readText().trim()
|
||||||
elapsed = SystemClock.elapsedRealtime() - start
|
elapsed = SystemClock.elapsedRealtime() - start
|
||||||
|
|
||||||
result = when (code) {
|
if (xyz.zarazaex.olc.util.Utils.isPureIpAddress(responseBody)) {
|
||||||
204 -> context.getString(R.string.connection_test_available, elapsed)
|
result = context.getString(R.string.connection_test_available, elapsed)
|
||||||
200 if conn.contentLengthLong == 0L -> context.getString(R.string.connection_test_available, elapsed)
|
} else {
|
||||||
else -> throw IOException(
|
throw IOException("Invalid IP response: $responseBody")
|
||||||
context.getString(R.string.connection_test_error_status_code, code)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
Log.e(AppConfig.TAG, "Connection test IOException", e)
|
Log.e(AppConfig.TAG, "Connection test IOException", e)
|
||||||
|
|||||||
@@ -228,15 +228,15 @@ class V2RayVpnService : VpnService(), ServiceControl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure DNS servers
|
if (MmkvManager.decodeSettingsBool(AppConfig.PREF_LOCAL_DNS_ENABLED) == true) {
|
||||||
//if (MmkvManager.decodeSettingsBool(AppConfig.PREF_LOCAL_DNS_ENABLED) == true) {
|
builder.addDnsServer(vpnConfig.ipv4Router)
|
||||||
// builder.addDnsServer(PRIVATE_VLAN4_ROUTER)
|
} else {
|
||||||
//} else {
|
|
||||||
SettingsManager.getVpnDnsServers().forEach {
|
SettingsManager.getVpnDnsServers().forEach {
|
||||||
if (Utils.isPureIpAddress(it)) {
|
if (Utils.isPureIpAddress(it)) {
|
||||||
builder.addDnsServer(it)
|
builder.addDnsServer(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
builder.setSession(V2RayServiceManager.getRunningServerName())
|
builder.setSession(V2RayServiceManager.getRunningServerName())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,9 +136,17 @@ fun main() {
|
|||||||
)
|
)
|
||||||
println("Добавлена подписка БЕЛЫЕ W: $guid2")
|
println("Добавлена подписка БЕЛЫЕ W: $guid2")
|
||||||
|
|
||||||
|
val guid3 = manager.addSubscription(
|
||||||
|
remarks = "KEY",
|
||||||
|
url = "https://key.zarazaex.xyz/sub",
|
||||||
|
autoUpdate = true
|
||||||
|
)
|
||||||
|
println("Добавлена подписка KEY: $guid3")
|
||||||
|
|
||||||
println("\nОбновление подписок...")
|
println("\nОбновление подписок...")
|
||||||
manager.updateSubscription(guid1, "https://raw.githubusercontent.com/zieng2/wl/refs/heads/main/vless_universal.txt")
|
manager.updateSubscription(guid1, "https://raw.githubusercontent.com/zieng2/wl/refs/heads/main/vless_universal.txt")
|
||||||
manager.updateSubscription(guid2, "https://raw.githubusercontent.com/whoahaow/rjsxrd/refs/heads/main/githubmirror/bypass/bypass-all.txt")
|
manager.updateSubscription(guid2, "https://raw.githubusercontent.com/whoahaow/rjsxrd/refs/heads/main/githubmirror/bypass/bypass-all.txt")
|
||||||
|
manager.updateSubscription(guid3, "https://key.zarazaex.xyz/sub")
|
||||||
|
|
||||||
println("\nПодписки успешно добавлены и обновлены в $mmkvPath")
|
println("\nПодписки успешно добавлены и обновлены в $mmkvPath")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
ТЫ
|
|
||||||
Reference in New Issue
Block a user