optimize traffic

This commit is contained in:
arm64v8a 2023-06-17 11:52:34 +09:00
parent c5b66e58fa
commit 5d75cbacd4
2 changed files with 8 additions and 3 deletions

View File

@ -44,7 +44,7 @@ class ProxyInstance(profile: ProxyEntity, var service: BaseService.Interface? =
override fun launch() { override fun launch() {
box.setAsMain() box.setAsMain()
super.launch() super.launch() // start box
runOnDefaultDispatcher { runOnDefaultDispatcher {
looper = service?.let { TrafficLooper(it.data, this) } looper = service?.let { TrafficLooper(it.data, this) }
looper?.start() looper?.start()

View File

@ -93,8 +93,11 @@ class TrafficLooper
val itemBypass = TrafficUpdater.TrafficLooperData(tag = TAG_BYPASS) val itemBypass = TrafficUpdater.TrafficLooperData(tag = TAG_BYPASS)
while (sc.isActive) { while (sc.isActive) {
proxy = data.proxy
if (proxy == null) {
delay(delayMs) delay(delayMs)
proxy = data.proxy ?: continue continue
}
if (trafficUpdater == null) { if (trafficUpdater == null) {
if (!proxy.isInitialized()) continue if (!proxy.isInitialized()) continue
@ -175,6 +178,8 @@ class TrafficLooper
data.notification?.apply { data.notification?.apply {
if (listenPostSpeed) postNotificationSpeedUpdate(speed) if (listenPostSpeed) postNotificationSpeedUpdate(speed)
} }
delay(delayMs)
} }
} }
} }