mirror of
https://github.com/MatsuriDayo/NekoBoxForAndroid.git
synced 2025-12-19 14:40:06 +08:00
fix
This commit is contained in:
parent
4b0886e9fb
commit
6dec4d058b
@ -612,11 +612,7 @@ fun buildConfig(
|
||||
tag = TAG_DNS_IN
|
||||
listen = bind
|
||||
listen_port = DataStore.localDNSPort
|
||||
override_address = if (!remoteDns.first().isIpAddress()) {
|
||||
"8.8.8.8"
|
||||
} else {
|
||||
remoteDns.first()
|
||||
}
|
||||
override_address = "8.8.8.8"
|
||||
override_port = 53
|
||||
})
|
||||
|
||||
@ -631,23 +627,6 @@ fun buildConfig(
|
||||
directDNS = listOf(LOCAL_DNS_SERVER)
|
||||
}
|
||||
|
||||
// routing for DNS server
|
||||
for (dns in remoteDns) {
|
||||
if (!dns.isIpAddress()) continue
|
||||
route.rules.add(Rule_DefaultOptions().apply {
|
||||
outbound = TAG_PROXY
|
||||
ip_cidr = listOf(dns)
|
||||
})
|
||||
}
|
||||
|
||||
for (dns in directDNS) {
|
||||
if (!dns.isIpAddress()) continue
|
||||
route.rules.add(Rule_DefaultOptions().apply {
|
||||
outbound = TAG_DIRECT
|
||||
ip_cidr = listOf(dns)
|
||||
})
|
||||
}
|
||||
|
||||
// Bypass Lookup for the first profile
|
||||
bypassDNSBeans.forEach {
|
||||
var serverAddr = it.serverAddress
|
||||
@ -680,10 +659,9 @@ fun buildConfig(
|
||||
}
|
||||
|
||||
// remote dns obj
|
||||
remoteDns.firstOrNull()?.apply {
|
||||
val d = this
|
||||
remoteDns.firstOrNull().let {
|
||||
dns.servers.add(DNSServerOptions().apply {
|
||||
address = d
|
||||
address = it ?: throw Exception("No remote DNS, check your settings!")
|
||||
tag = "dns-remote"
|
||||
address_resolver = "dns-direct"
|
||||
applyDNSNetworkSettings(false)
|
||||
@ -691,10 +669,9 @@ fun buildConfig(
|
||||
}
|
||||
|
||||
// add directDNS objects here
|
||||
directDNS.firstOrNull()?.apply {
|
||||
val d = this
|
||||
directDNS.firstOrNull().let {
|
||||
dns.servers.add(DNSServerOptions().apply {
|
||||
address = d
|
||||
address = it ?: throw Exception("No direct DNS, check your settings!")
|
||||
tag = "dns-direct"
|
||||
detour = "direct"
|
||||
address_resolver = "dns-local"
|
||||
@ -774,13 +751,11 @@ fun buildConfig(
|
||||
}
|
||||
}
|
||||
|
||||
// Disable DNS for test
|
||||
if (forTest) {
|
||||
dns.servers.clear()
|
||||
// Disable DNS for test
|
||||
dns.rules.clear()
|
||||
}
|
||||
|
||||
if (!forTest) {
|
||||
} else {
|
||||
// built-in DNS rules
|
||||
route.rules.add(0, Rule_DefaultOptions().apply {
|
||||
inbound = listOf(TAG_DNS_IN)
|
||||
outbound = TAG_DNS_OUT
|
||||
@ -806,6 +781,13 @@ fun buildConfig(
|
||||
server = "dns-block"
|
||||
disable_cache = true
|
||||
})
|
||||
// force bypass
|
||||
if (domainListDNSDirectForce.isNotEmpty()) {
|
||||
dns.rules.add(0, DNSRule_DefaultOptions().apply {
|
||||
makeSingBoxRule(domainListDNSDirectForce.toHashSet().toList())
|
||||
server = "dns-direct"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// fakedns obj
|
||||
@ -825,14 +807,6 @@ fun buildConfig(
|
||||
disable_cache = true
|
||||
})
|
||||
}
|
||||
|
||||
// force bypass
|
||||
if (domainListDNSDirectForce.isNotEmpty()) {
|
||||
dns.rules.add(0, DNSRule_DefaultOptions().apply {
|
||||
makeSingBoxRule(domainListDNSDirectForce.toHashSet().toList())
|
||||
server = "dns-direct"
|
||||
})
|
||||
}
|
||||
}.let {
|
||||
ConfigBuildResult(
|
||||
gson.toJson(it.asMap().apply {
|
||||
|
||||
@ -4,6 +4,7 @@ import com.esotericsoftware.kryo.io.ByteBufferInput;
|
||||
import com.esotericsoftware.kryo.io.ByteBufferOutput;
|
||||
|
||||
import io.nekohasekai.sagernet.fmt.AbstractBean;
|
||||
import io.nekohasekai.sagernet.fmt.trojan.TrojanBean;
|
||||
import moe.matsuri.nb4a.utils.JavaUtil;
|
||||
|
||||
public abstract class StandardV2RayBean extends AbstractBean {
|
||||
@ -63,7 +64,13 @@ public abstract class StandardV2RayBean extends AbstractBean {
|
||||
if (JavaUtil.isNullOrBlank(host)) host = "";
|
||||
if (JavaUtil.isNullOrBlank(path)) path = "";
|
||||
|
||||
if (JavaUtil.isNullOrBlank(security)) security = "none";
|
||||
if (JavaUtil.isNullOrBlank(security)) {
|
||||
if (this instanceof TrojanBean || isVLESS()) {
|
||||
security = "tls";
|
||||
} else {
|
||||
security = "none";
|
||||
}
|
||||
}
|
||||
if (JavaUtil.isNullOrBlank(sni)) sni = "";
|
||||
if (JavaUtil.isNullOrBlank(alpn)) alpn = "";
|
||||
|
||||
|
||||
@ -70,7 +70,7 @@ class BackupFragment : NamedFragment(R.layout.layout_backup) {
|
||||
)
|
||||
onMainDispatcher {
|
||||
startFilesForResult(
|
||||
exportSettings, "matsuri_backup_${Date().toLocaleString()}.json"
|
||||
exportSettings, "nekobox_backup_${Date().toLocaleString()}.json"
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -85,7 +85,7 @@ class BackupFragment : NamedFragment(R.layout.layout_backup) {
|
||||
)
|
||||
app.cacheDir.mkdirs()
|
||||
val cacheFile = File(
|
||||
app.cacheDir, "matsuri_backup_${Date().toLocaleString()}.json"
|
||||
app.cacheDir, "nekobox_backup_${Date().toLocaleString()}.json"
|
||||
)
|
||||
cacheFile.writeText(content)
|
||||
onMainDispatcher {
|
||||
|
||||
@ -45,11 +45,7 @@ abstract class StandardV2RaySettingsActivity : ProfileSettingsActivity<StandardV
|
||||
private val realityShortId = pbm.add(PreferenceBinding(Type.Text, "realityShortId"))
|
||||
|
||||
override fun StandardV2RayBean.init() {
|
||||
if (this is VMessBean) {
|
||||
if (intent?.getBooleanExtra("vless", false) == true) {
|
||||
alterId = -1
|
||||
}
|
||||
} else if (this is TrojanBean) {
|
||||
if (this is TrojanBean) {
|
||||
this@StandardV2RaySettingsActivity.uuid.fieldName = "password"
|
||||
this@StandardV2RaySettingsActivity.password.disable = true
|
||||
}
|
||||
|
||||
@ -4,6 +4,10 @@ import io.nekohasekai.sagernet.fmt.v2ray.VMessBean
|
||||
|
||||
class VMessSettingsActivity : StandardV2RaySettingsActivity() {
|
||||
|
||||
override fun createEntity() = VMessBean()
|
||||
override fun createEntity() = VMessBean().apply {
|
||||
if (intent?.getBooleanExtra("vless", false) == true) {
|
||||
alterId = -1
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user