mirror of
https://github.com/MatsuriDayo/NekoBoxForAndroid.git
synced 2025-12-18 22:20:06 +08:00
fixes
This commit is contained in:
parent
962668c6f1
commit
4327f35b51
@ -9,5 +9,4 @@ oneway interface ISagerNetServiceCallback {
|
||||
void routeAlert(int type, String routeName);
|
||||
void cbSpeedUpdate(in SpeedDisplayData stats);
|
||||
void cbTrafficUpdate(in TrafficData stats);
|
||||
void cbLogUpdate(String str);
|
||||
}
|
||||
|
||||
@ -262,20 +262,6 @@ class SagerNet : Application(),
|
||||
|
||||
// nb4a interface
|
||||
|
||||
override fun write(p: ByteArray): Long {
|
||||
// NB4AGuiLogWriter
|
||||
if (isBgProcess) {
|
||||
runOnDefaultDispatcher {
|
||||
DataStore.baseService?.data?.binder?.broadcast {
|
||||
it.cbLogUpdate(String(p))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DataStore.postLogListener?.let { it(String(p)) }
|
||||
}
|
||||
return p.size.toLong()
|
||||
}
|
||||
|
||||
override fun useOfficialAssets(): Boolean {
|
||||
return DataStore.rulesProvider == 0
|
||||
}
|
||||
|
||||
@ -96,14 +96,6 @@ class SagerConnection(
|
||||
}
|
||||
}
|
||||
|
||||
override fun cbLogUpdate(str: String?) {
|
||||
DataStore.postLogListener?.let {
|
||||
if (str != null) {
|
||||
it(str)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private var binder: IBinder? = null
|
||||
|
||||
@ -4,7 +4,7 @@ import io.nekohasekai.sagernet.BuildConfig
|
||||
import io.nekohasekai.sagernet.bg.BaseService
|
||||
import io.nekohasekai.sagernet.database.ProxyEntity
|
||||
import io.nekohasekai.sagernet.ktx.Logs
|
||||
import io.nekohasekai.sagernet.ktx.runOnIoDispatcher
|
||||
import io.nekohasekai.sagernet.ktx.runOnDefaultDispatcher
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import moe.matsuri.nb4a.utils.JavaUtil
|
||||
|
||||
@ -42,7 +42,7 @@ class ProxyInstance(profile: ProxyEntity, var service: BaseService.Interface? =
|
||||
override fun launch() {
|
||||
box.setAsMain()
|
||||
super.launch()
|
||||
runOnIoDispatcher {
|
||||
runOnDefaultDispatcher {
|
||||
looper = service?.let { TrafficLooper(it.data, this) }
|
||||
looper?.start()
|
||||
}
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
package io.nekohasekai.sagernet.bg.proto
|
||||
|
||||
import io.nekohasekai.sagernet.ktx.onIoDispatcher
|
||||
|
||||
class TrafficUpdater(
|
||||
private val box: libcore.BoxInstance,
|
||||
val items: List<TrafficLooperData>, // contain "bypass"
|
||||
@ -28,12 +26,8 @@ class TrafficUpdater(
|
||||
}
|
||||
|
||||
// query
|
||||
var tx = 0L
|
||||
var rx = 0L
|
||||
onIoDispatcher {
|
||||
tx = box.queryStats(item.tag, "uplink")
|
||||
rx = box.queryStats(item.tag, "downlink")
|
||||
}
|
||||
val tx = box.queryStats(item.tag, "uplink")
|
||||
val rx = box.queryStats(item.tag, "downlink")
|
||||
|
||||
// add diff
|
||||
item.rx += rx
|
||||
|
||||
@ -30,9 +30,6 @@ object DataStore : OnPreferenceDataStoreChangeListener {
|
||||
var vpnService: VpnService? = null
|
||||
var baseService: BaseService.Interface? = null
|
||||
|
||||
// only in GUI process
|
||||
var postLogListener: ((String) -> Unit)? = null
|
||||
|
||||
fun currentGroupId(): Long {
|
||||
val currentSelected = configurationStore.getLong(Key.PROFILE_GROUP, -1)
|
||||
if (currentSelected > 0L) return currentSelected
|
||||
|
||||
@ -695,7 +695,7 @@ fun buildConfig(
|
||||
dns.rules.add(
|
||||
DNSRule_DefaultOptions().apply {
|
||||
user_id = uidListDNSRemote.toHashSet().toList()
|
||||
server = "dns-remote"
|
||||
server = if (useFakeDns) "dns-fake" else "dns-remote"
|
||||
}
|
||||
)
|
||||
}
|
||||
@ -703,7 +703,7 @@ fun buildConfig(
|
||||
dns.rules.add(
|
||||
DNSRule_DefaultOptions().apply {
|
||||
makeSingBoxRule(domainListDNSRemote.toHashSet().toList())
|
||||
server = "dns-remote"
|
||||
server = if (useFakeDns) "dns-fake" else "dns-remote"
|
||||
}
|
||||
)
|
||||
}
|
||||
@ -775,7 +775,7 @@ fun buildConfig(
|
||||
tag = "dns-fake"
|
||||
strategy = "ipv4_only"
|
||||
})
|
||||
dns.rules.add(DNSRule_DefaultOptions().apply {
|
||||
dns.rules.add(0, DNSRule_DefaultOptions().apply {
|
||||
auth_user = listOf("fakedns")
|
||||
server = "dns-remote"
|
||||
disable_cache = true
|
||||
|
||||
@ -12,7 +12,6 @@ import android.view.View
|
||||
import android.widget.ScrollView
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import io.nekohasekai.sagernet.R
|
||||
import io.nekohasekai.sagernet.database.DataStore
|
||||
import io.nekohasekai.sagernet.databinding.LayoutLogcatBinding
|
||||
import io.nekohasekai.sagernet.ktx.*
|
||||
import libcore.Libcore
|
||||
@ -38,23 +37,7 @@ class LogcatFragment : ToolbarFragment(R.layout.layout_logcat),
|
||||
}
|
||||
|
||||
reloadSession()
|
||||
|
||||
DataStore.postLogListener = {
|
||||
runOnMainDispatcher {
|
||||
val color = getColorForLine(it)
|
||||
val span = SpannableString(it)
|
||||
span.setSpan(color, 0, it.length, SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
binding.textview.append(span)
|
||||
binding.scroolview.post {
|
||||
binding.scroolview.fullScroll(ScrollView.FOCUS_DOWN)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
DataStore.postLogListener = null
|
||||
super.onDestroy()
|
||||
// TODO new logcat
|
||||
}
|
||||
|
||||
private fun getColorForLine(line: String): ForegroundColorSpan {
|
||||
|
||||
@ -75,8 +75,8 @@ object DNS {
|
||||
domain.plusAssign(it)
|
||||
}
|
||||
}
|
||||
if (ip_cidr?.isEmpty() == true) geosite = null
|
||||
if (geoip?.isEmpty() == true) geosite = null
|
||||
if (ip_cidr?.isEmpty() == true) ip_cidr = null
|
||||
if (geoip?.isEmpty() == true) geoip = null
|
||||
if (geosite?.isEmpty() == true) geosite = null
|
||||
if (domain?.isEmpty() == true) domain = null
|
||||
if (domain_suffix?.isEmpty() == true) domain_suffix = null
|
||||
|
||||
@ -7,7 +7,7 @@ import (
|
||||
var outdated string
|
||||
|
||||
func GetBuildTime() int64 {
|
||||
buildDate := "20230321"
|
||||
buildDate := "20230327"
|
||||
buildTime, _ := time.Parse("20060102", buildDate)
|
||||
return buildTime.Unix()
|
||||
}
|
||||
|
||||
@ -5,12 +5,12 @@ go 1.18
|
||||
require (
|
||||
github.com/codeclysm/extract v2.2.0+incompatible
|
||||
github.com/matsuridayo/libneko v0.0.0-20230315005352-9d7e3f3a79d1
|
||||
github.com/matsuridayo/sing-box-extra v0.0.0-20230325060026-3d1536ef0aa0
|
||||
github.com/matsuridayo/sing-box-extra v0.0.0-20230327081452-742054d97340
|
||||
github.com/miekg/dns v1.1.52
|
||||
github.com/sagernet/sing v0.2.1-0.20230323071235-f8038854d286
|
||||
github.com/sagernet/sing-box v1.2.0
|
||||
github.com/sagernet/sing v0.2.1
|
||||
github.com/sagernet/sing-box v1.2.1
|
||||
github.com/sagernet/sing-dns v0.1.4
|
||||
github.com/sagernet/sing-tun v0.1.3-0.20230323073325-35d565af6515
|
||||
github.com/sagernet/sing-tun v0.1.4-0.20230326080954-8848c0e4cbab
|
||||
github.com/ulikunitz/xz v0.5.10
|
||||
golang.org/x/mobile v0.0.0-20220722155234-aaac322e2105
|
||||
)
|
||||
|
||||
@ -73,8 +73,8 @@ github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczG
|
||||
github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
|
||||
github.com/matsuridayo/libneko v0.0.0-20230315005352-9d7e3f3a79d1 h1:+FflyEuq2hn++MENFuT1/qFHz0KITKK/F6ZHxs23mrg=
|
||||
github.com/matsuridayo/libneko v0.0.0-20230315005352-9d7e3f3a79d1/go.mod h1:IRO07Queptz/rGFvEW+3Hmwpx7MCup6WiDs4p5jMt4g=
|
||||
github.com/matsuridayo/sing-box-extra v0.0.0-20230325060026-3d1536ef0aa0 h1:bYySHCBsxrX1f11PsKRg80pT5NHwLukAebOJnygqQFc=
|
||||
github.com/matsuridayo/sing-box-extra v0.0.0-20230325060026-3d1536ef0aa0/go.mod h1:nIAxi4Ym/52BS2FTBS6s4xejViHryitMO5MuSKoa34M=
|
||||
github.com/matsuridayo/sing-box-extra v0.0.0-20230327081452-742054d97340 h1:TzuCH2vb6eo7BxZ+eMylKKrUGvmamDRCptBLtQSaSgQ=
|
||||
github.com/matsuridayo/sing-box-extra v0.0.0-20230327081452-742054d97340/go.mod h1:E3oztgtA++oubrIDHoLV9BO9/2C8p8BNkbBZRnho9lI=
|
||||
github.com/mholt/acmez v1.1.0 h1:IQ9CGHKOHokorxnffsqDvmmE30mDenO1lptYZ1AYkHY=
|
||||
github.com/mholt/acmez v1.1.0/go.mod h1:zwo5+fbLLTowAX8o8ETfQzbDtwGEXnPhkmGdKIP+bgs=
|
||||
github.com/miekg/dns v1.1.52 h1:Bmlc/qsNNULOe6bpXcUTsuOajd0DzRHwup6D9k1An0c=
|
||||
@ -113,18 +113,18 @@ github.com/sagernet/reality v0.0.0-20230323230523-5fa25e693e7f h1:plVtFF9NVw5Py4
|
||||
github.com/sagernet/reality v0.0.0-20230323230523-5fa25e693e7f/go.mod h1:B8lp4WkQ1PwNnrVMM6KyuFR20pU8jYBD+A4EhJovEXU=
|
||||
github.com/sagernet/sing v0.0.0-20220817130738-ce854cda8522/go.mod h1:QVsS5L/ZA2Q5UhQwLrn0Trw+msNd/NPGEhBKR/ioWiY=
|
||||
github.com/sagernet/sing v0.1.8/go.mod h1:jt1w2u7lJQFFSGLiRrRIs5YWmx4kAPfWuOejuDW9qMk=
|
||||
github.com/sagernet/sing v0.2.1-0.20230323071235-f8038854d286 h1:0Td2b5l1KgrdlOnbRWgFFWsyb0TLoq/tP6j9Lut4JN0=
|
||||
github.com/sagernet/sing v0.2.1-0.20230323071235-f8038854d286/go.mod h1:9uHswk2hITw8leDbiLS/xn0t9nzBcbePxzm9PJhwdlw=
|
||||
github.com/sagernet/sing-box v1.2.0 h1:XFCvwJ4dKP65KeucGVs2zq0GPm0qtuoe1u5TLwsjh3s=
|
||||
github.com/sagernet/sing-box v1.2.0/go.mod h1:7NuAB1wmWMMSCJnOUFnTk69024LeZQLL+xJ9IpKfjQE=
|
||||
github.com/sagernet/sing v0.2.1 h1:r0STYeyfKBBtoAHsBtW1dQonxG+3Qidde7/1VAMhdn8=
|
||||
github.com/sagernet/sing v0.2.1/go.mod h1:9uHswk2hITw8leDbiLS/xn0t9nzBcbePxzm9PJhwdlw=
|
||||
github.com/sagernet/sing-box v1.2.1 h1:87VHHfEH5qW0ZbHv//HkRWb/W4wsak2rqfaoxLCnjpg=
|
||||
github.com/sagernet/sing-box v1.2.1/go.mod h1:htuHAvGxwjL1RdbdR1mlFCd4d+b8fCXs2JqFasnJnGU=
|
||||
github.com/sagernet/sing-dns v0.1.4 h1:7VxgeoSCiiazDSaXXQVcvrTBxFpOePPq/4XdgnUDN+0=
|
||||
github.com/sagernet/sing-dns v0.1.4/go.mod h1:1+6pCa48B1AI78lD+/i/dLgpw4MwfnsSpZo0Ds8wzzk=
|
||||
github.com/sagernet/sing-shadowsocks v0.2.0 h1:ILDWL7pwWfkPLEbviE/MyCgfjaBmJY/JVVY+5jhSb58=
|
||||
github.com/sagernet/sing-shadowsocks v0.2.0/go.mod h1:ysYzszRLpNzJSorvlWRMuzU6Vchsp7sd52q+JNY4axw=
|
||||
github.com/sagernet/sing-shadowtls v0.1.0 h1:05MYce8aR5xfKIn+y7xRFsdKhKt44QZTSEQW+lG5IWQ=
|
||||
github.com/sagernet/sing-shadowtls v0.1.0/go.mod h1:Kn1VUIprdkwCgkS6SXYaLmIpKzQbqBIKJBMY+RvBhYc=
|
||||
github.com/sagernet/sing-tun v0.1.3-0.20230323073325-35d565af6515 h1:r25BJqn3o34g+bDdhoRU65zimKPfGCTv7nHuysyJojo=
|
||||
github.com/sagernet/sing-tun v0.1.3-0.20230323073325-35d565af6515/go.mod h1:1xzFt4zJ7CzXdbgPcy7+Lsg4ypZo0ivDNZ0oQdL3zEY=
|
||||
github.com/sagernet/sing-tun v0.1.4-0.20230326080954-8848c0e4cbab h1:a9oeWuPBuIZ70qMhIIH6RrYhp886xN9jJIwsuu4ZFUo=
|
||||
github.com/sagernet/sing-tun v0.1.4-0.20230326080954-8848c0e4cbab/go.mod h1:4YxIDEkkCjGXDOTMPw1SXpLmCQUFAWuaQN250oo+928=
|
||||
github.com/sagernet/sing-vmess v0.1.3 h1:q/+tsF46dvvapL6CpQBgPHJ6nQrDUZqEtLHCbsjO7iM=
|
||||
github.com/sagernet/sing-vmess v0.1.3/go.mod h1:GVXqAHwe9U21uS+Voh4YBIrADQyE4F9v0ayGSixSQAE=
|
||||
github.com/sagernet/smux v0.0.0-20230312102458-337ec2a5af37 h1:HuE6xSwco/Xed8ajZ+coeYLmioq0Qp1/Z2zczFaV8as=
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package libcore
|
||||
|
||||
import (
|
||||
"io"
|
||||
"libcore/device"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -62,7 +61,7 @@ func InitCore(process, cachePath, internalAssets, externalAssets string,
|
||||
maxLogSizeKb = 50
|
||||
}
|
||||
neko_log.LogWriterDisable = !logEnable
|
||||
neko_log.NB4AGuiLogWriter = iif.(io.Writer)
|
||||
// neko_log.NB4AGuiLogWriter = iif.(io.Writer)
|
||||
neko_log.SetupLog(int(maxLogSizeKb)*1024, filepath.Join(cachePath, "neko.log"))
|
||||
|
||||
// Set up some component
|
||||
|
||||
@ -5,12 +5,7 @@ var intfNB4A NB4AInterface
|
||||
|
||||
var useProcfs bool
|
||||
|
||||
type NB4AGuiLogWriter interface {
|
||||
Write(p []byte) (n int, err error)
|
||||
}
|
||||
|
||||
type NB4AInterface interface {
|
||||
NB4AGuiLogWriter
|
||||
UseOfficialAssets() bool
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user