@@ -21,6 +21,7 @@
|
||||
package com.github.shadowsocks
|
||||
|
||||
import android.app.backup.{BackupAgentHelper, FileBackupHelper, SharedPreferencesBackupHelper}
|
||||
import com.github.shadowsocks.acl.Acl
|
||||
import com.github.shadowsocks.database.DBHelper
|
||||
|
||||
class ShadowsocksBackupAgent extends BackupAgentHelper {
|
||||
@@ -38,6 +39,7 @@ class ShadowsocksBackupAgent extends BackupAgentHelper {
|
||||
override def onCreate() {
|
||||
val helper = new SharedPreferencesBackupHelper(this, PREFS_DISPLAY)
|
||||
addHelper(MY_PREFS_BACKUP_KEY, helper)
|
||||
addHelper(DATABASE, new FileBackupHelper(this, "../databases/" + DBHelper.PROFILE))
|
||||
addHelper(DATABASE, new FileBackupHelper(this, "../databases/" + DBHelper.PROFILE,
|
||||
"../" + Acl.CUSTOM_RULES + ".acl"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,15 +51,15 @@ class Acl {
|
||||
bypass = other.bypass
|
||||
this
|
||||
}
|
||||
def fromSource(value: Source): Acl = {
|
||||
def fromSource(value: Source, defaultBypass: Boolean = false): Acl = {
|
||||
bypassHostnames.clear()
|
||||
proxyHostnames.clear()
|
||||
this.subnets.clear()
|
||||
bypass = false
|
||||
bypass = defaultBypass
|
||||
lazy val bypassSubnets = new mutable.SortedList[Subnet]()
|
||||
lazy val proxySubnets = new mutable.SortedList[Subnet]()
|
||||
var hostnames: mutable.SortedList[String] = bypassHostnames
|
||||
var subnets: mutable.SortedList[Subnet] = bypassSubnets
|
||||
var hostnames: mutable.SortedList[String] = if (defaultBypass) proxyHostnames else bypassHostnames
|
||||
var subnets: mutable.SortedList[Subnet] = if (defaultBypass) proxySubnets else bypassSubnets
|
||||
for (line <- value.getLines()) (line.indexOf('#') match {
|
||||
case -1 => line
|
||||
case index => line.substring(0, index) // trim comments
|
||||
|
||||
Reference in New Issue
Block a user