Commit ac0fa240 authored by sheteng's avatar sheteng

Merge remote-tracking branch 'origin/cc-dev' into cc-dev

parents aed7ddca 238d78cb
...@@ -16,5 +16,6 @@ data class GameInfo( ...@@ -16,5 +16,6 @@ data class GameInfo(
val imgs: String, val imgs: String,
val introduction: String, val introduction: String,
val packageName: String, val packageName: String,
val boosterPackageName :String val boosterPackageName :String,
val proxyRules: String,
) )
\ No newline at end of file
...@@ -155,9 +155,6 @@ object AcceleratorUtils : TencentLocationListener { ...@@ -155,9 +155,6 @@ object AcceleratorUtils : TencentLocationListener {
fun startAccelerator(xPageFragment: XPageFragment) { fun startAccelerator(xPageFragment: XPageFragment) {
game?.let { game?.let {
initAuthProfile(xPageFragment) initAuthProfile(xPageFragment)
val serverPort = it.boosterServer.split(":")
DataStore.pingAccHost = serverPort[0]
DataStore.pingAccPort = serverPort[1].toInt()
} }
} }
...@@ -192,6 +189,7 @@ object AcceleratorUtils : TencentLocationListener { ...@@ -192,6 +189,7 @@ object AcceleratorUtils : TencentLocationListener {
private fun initAuthProfile(xPageFragment: XPageFragment) { private fun initAuthProfile(xPageFragment: XPageFragment) {
xPageFragment.lifecycleScope.launch(Dispatchers.IO) { xPageFragment.lifecycleScope.launch(Dispatchers.IO) {
val game = AcceleratorUtils.game
val profileId = 1L val profileId = 1L
val profile = ProfileManager.getProfile(profileId) ?: Profile() val profile = ProfileManager.getProfile(profileId) ?: Profile()
profile.proxyApps = true profile.proxyApps = true
...@@ -202,13 +200,19 @@ object AcceleratorUtils : TencentLocationListener { ...@@ -202,13 +200,19 @@ object AcceleratorUtils : TencentLocationListener {
"com.activision.callofduty.shooter", "com.activision.callofduty.shooter",
"com.pubg.krmobile", "com.pubg.krmobile",
) )
game?.packageName?.let { proxyGames.add(it) } if (game != null) {
game?.boosterPackageName?.split(",")?.forEach { proxyGames.add(game.packageName)
if (!StringUtils.isEmpty(it)) { game.boosterPackageName.split(",").forEach {
proxyGames.add(it) if (!StringUtils.isEmpty(it)) {
proxyGames.add(it)
}
} }
DataStore.proxyRules = game.proxyRules
val serverPort = game.boosterServer.split(":")
DataStore.pingAccHost = serverPort[0]
DataStore.pingAccPort = serverPort[1].toInt()
} }
// proxyGames.addAll(profile.individual.split("\n"))
profile.individual = proxyGames.joinToString("\n") profile.individual = proxyGames.joinToString("\n")
profile.route = Acl.BYPASS_LAN profile.route = Acl.BYPASS_LAN
profile.password = "barfoo!" profile.password = "barfoo!"
......
...@@ -2,6 +2,7 @@ package com.ccnet.acc ...@@ -2,6 +2,7 @@ package com.ccnet.acc
import android.content.Context import android.content.Context
import com.github.shadowsocks.database.Profile import com.github.shadowsocks.database.Profile
import com.github.shadowsocks.preference.DataStore
import timber.log.Timber import timber.log.Timber
import java.io.File import java.io.File
...@@ -14,6 +15,7 @@ object AccVpn { ...@@ -14,6 +15,7 @@ object AccVpn {
} }
fun writeConfig(context: Context, tunFd: Int, profile: Profile) { fun writeConfig(context: Context, tunFd: Int, profile: Profile) {
val proxyRules = DataStore.proxyRules
val configContent = """ val configContent = """
[General] [General]
loglevel = trace loglevel = trace
...@@ -23,7 +25,8 @@ object AccVpn { ...@@ -23,7 +25,8 @@ object AccVpn {
Direct = direct Direct = direct
SS = ss, ${profile.host}, ${profile.remotePort}, encrypt-method=chacha20-ietf-poly1305, password=123456, auth_timeout=${profile.authTimeout}, beats_interval=${profile.beatsInterval}, retry_limit=${profile.retryLimit}, token=${profile.token} SS = ss, ${profile.host}, ${profile.remotePort}, encrypt-method=chacha20-ietf-poly1305, password=123456, auth_timeout=${profile.authTimeout}, beats_interval=${profile.beatsInterval}, retry_limit=${profile.retryLimit}, token=${profile.token}
[Rule] [Rule]
FINAL, SS $proxyRules
FINAL, Direct
""" """
val configFile = configFile(context) val configFile = configFile(context)
Timber.d("writeConfig ${configFile.absolutePath}") Timber.d("writeConfig ${configFile.absolutePath}")
......
...@@ -90,7 +90,7 @@ class TrafficMonitor(statFile: File?) { ...@@ -90,7 +90,7 @@ class TrafficMonitor(statFile: File?) {
if (!cont) { if (!cont) {
bindNetwork = NetworkAdapter.bindNetwork bindNetwork = NetworkAdapter.bindNetwork
} }
return cont return cont && running
} }
} }
) )
......
...@@ -131,4 +131,7 @@ object DataStore : OnPreferenceDataStoreChangeListener { ...@@ -131,4 +131,7 @@ object DataStore : OnPreferenceDataStoreChangeListener {
var pingNetReachableHost: String var pingNetReachableHost: String
get() = privateStore.getString(Key.pingNetReachableHost) ?: "baidu.com" get() = privateStore.getString(Key.pingNetReachableHost) ?: "baidu.com"
set(value) = privateStore.putString(Key.pingNetReachableHost, value) set(value) = privateStore.putString(Key.pingNetReachableHost, value)
var proxyRules: String
get() = privateStore.getString(Key.proxyRules) ?: ""
set(value) = privateStore.putString(Key.proxyRules, value)
} }
...@@ -79,6 +79,8 @@ object Key { ...@@ -79,6 +79,8 @@ object Key {
const val pingAccPort = "pingAccPort" const val pingAccPort = "pingAccPort"
const val pingNetReachableHost = "pingNetReachableHost" const val pingNetReachableHost = "pingNetReachableHost"
const val proxyRules = "proxyRules"
// TV specific values // TV specific values
const val controlStats = "control.stats" const val controlStats = "control.stats"
const val controlImport = "control.import" const val controlImport = "control.import"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment