diff --git a/src/main/res/values/arrays.xml b/src/main/res/values/arrays.xml
new file mode 100644
index 00000000..08fb0cb3
--- /dev/null
+++ b/src/main/res/values/arrays.xml
@@ -0,0 +1,892 @@
+
+
+
+
+ - 0.0.0.0/7
+ - 10.0.0.0/8
+ - 14.0.0.0/8
+ - 27.0.0.0/8
+ - 36.0.0.0/8
+ - 39.0.0.0/8
+ - 42.0.0.0/7
+ - 49.0.0.0/8
+ - 58.0.0.0/7
+ - 60.0.0.0/7
+ - 101.0.0.0/8
+ - 103.0.0.0/8
+ - 106.0.0.0/8
+ - 110.0.0.0/7
+ - 112.0.0.0/4
+ - 134.128.0.0/9
+ - 139.0.0.0/9
+ - 139.128.0.0/9
+ - 140.0.0.0/9
+ - 140.128.0.0/9
+ - 144.0.0.0/9
+ - 144.128.0.0/9
+ - 150.0.0.0/8
+ - 153.0.0.0/8
+ - 157.0.0.0/9
+ - 157.128.0.0/9
+ - 159.128.0.0/9
+ - 161.128.0.0/9
+ - 162.0.0.0/9
+ - 163.0.0.0/8
+ - 166.0.0.0/9
+ - 167.128.0.0/9
+ - 168.128.0.0/9
+ - 171.0.0.0/8
+ - 172.0.0.0/12
+ - 175.0.0.0/8
+ - 180.0.0.0/8
+ - 182.0.0.0/7
+ - 192.112.0.0/12
+ - 192.128.0.0/9
+ - 202.0.0.0/7
+ - 210.0.0.0/7
+ - 218.0.0.0/7
+ - 220.0.0.0/6
+
+
+
+ - 1.33
+ - 4.28
+ - 4.53
+ - 5.9
+ - 5.226
+ - 8.5
+ - 8.12
+ - 8.14
+ - 8.18
+ - 8.23
+ - 8.26
+ - 8.29
+ - 8.254
+ - 12.69
+ - 12.130
+ - 14.102
+ - 14.199
+ - 23.8
+ - 23.19
+ - 23.21
+ - 23.23
+ - 23.34
+ - 23.62
+ - 24.173
+ - 27.34
+ - 27.98
+ - 27.121
+ - 27.124
+ - 31.131
+ - 31.170
+ - 31.186
+ - 31.192
+ - 31.222
+ - 37.208
+ - 37.235
+ - 37.247
+ - 38.99
+ - 38.101
+ - 38.103
+ - 38.110
+ - 38.113
+ - 38.117
+ - 38.118
+ - 38.121
+ - 38.123
+ - 38.127
+ - 38.229
+ - 46.4
+ - 46.20
+ - 46.51
+ - 46.105
+ - 46.137
+ - 46.163
+ - 46.165
+ - 46.229
+ - 46.236
+ - 49.212
+ - 49.213
+ - 49.247
+ - 50.6
+ - 50.7
+ - 50.16
+ - 50.17
+ - 50.18
+ - 50.19
+ - 50.22
+ - 50.23
+ - 50.28
+ - 50.31
+ - 50.56
+ - 50.57
+ - 50.62
+ - 50.63
+ - 50.87
+ - 50.93
+ - 50.97
+ - 50.112
+ - 50.116
+ - 50.117
+ - 50.194
+ - 54.225
+ - 54.235
+ - 54.236
+ - 54.240
+ - 54.243
+ - 54.248
+ - 54.249
+ - 54.251
+ - 54.252
+ - 58.1
+ - 58.64
+ - 58.176
+ - 59.105
+ - 59.106
+ - 59.120
+ - 59.124
+ - 59.149
+ - 59.152
+ - 59.188
+ - 60.51
+ - 60.199
+ - 60.244
+ - 60.248
+ - 60.249
+ - 60.250
+ - 60.251
+ - 61.31
+ - 61.60
+ - 61.63
+ - 61.67
+ - 61.92
+ - 61.111
+ - 61.115
+ - 61.147
+ - 61.152
+ - 61.201
+ - 61.219
+ - 61.238
+ - 62.27
+ - 62.77
+ - 62.80
+ - 62.116
+ - 62.212
+ - 62.219
+ - 63.156
+ - 63.217
+ - 63.226
+ - 63.247
+ - 64.4
+ - 64.8
+ - 64.12
+ - 64.13
+ - 64.14
+ - 64.22
+ - 64.26
+ - 64.29
+ - 64.31
+ - 64.50
+ - 64.62
+ - 64.71
+ - 64.74
+ - 64.78
+ - 64.85
+ - 64.88
+ - 64.90
+ - 64.93
+ - 64.95
+ - 64.111
+ - 64.120
+ - 64.145
+ - 64.150
+ - 64.151
+ - 64.182
+ - 64.202
+ - 64.210
+ - 64.224
+ - 64.229
+ - 64.237
+ - 65.39
+ - 65.49
+ - 65.55
+ - 65.60
+ - 65.75
+ - 65.182
+ - 65.254
+ - 66.6
+ - 66.7
+ - 66.28
+ - 66.33
+ - 66.39
+ - 66.55
+ - 66.85
+ - 66.96
+ - 66.115
+ - 66.147
+ - 66.151
+ - 66.155
+ - 66.175
+ - 66.180
+ - 66.197
+ - 66.212
+ - 66.215
+ - 66.218
+ - 66.226
+ - 66.228
+ - 66.231
+ - 66.232
+ - 66.252
+ - 66.254
+ - 67.18
+ - 67.20
+ - 67.21
+ - 67.23
+ - 67.55
+ - 67.192
+ - 67.195
+ - 67.202
+ - 67.205
+ - 67.207
+ - 67.213
+ - 67.214
+ - 67.220
+ - 67.222
+ - 67.227
+ - 67.228
+ - 68.68
+ - 68.71
+ - 68.169
+ - 68.178
+ - 68.180
+ - 68.233
+ - 68.234
+ - 69.10
+ - 69.16
+ - 69.25
+ - 69.26
+ - 69.28
+ - 69.43
+ - 69.44
+ - 69.53
+ - 69.56
+ - 69.58
+ - 69.60
+ - 69.65
+ - 69.72
+ - 69.73
+ - 69.85
+ - 69.89
+ - 69.93
+ - 69.147
+ - 69.161
+ - 69.163
+ - 69.164
+ - 69.167
+ - 69.171
+ - 69.172
+ - 69.175
+ - 69.181
+ - 69.191
+ - 69.195
+ - 69.197
+ - 70.32
+ - 70.37
+ - 70.38
+ - 70.39
+ - 70.86
+ - 70.87
+ - 70.99
+ - 71.18
+ - 71.245
+ - 72.3
+ - 72.8
+ - 72.9
+ - 72.10
+ - 72.12
+ - 72.20
+ - 72.21
+ - 72.26
+ - 72.29
+ - 72.32
+ - 72.34
+ - 72.41
+ - 72.47
+ - 72.51
+ - 72.52
+ - 72.167
+ - 72.232
+ - 72.233
+ - 72.249
+ - 74.3
+ - 74.50
+ - 74.52
+ - 74.53
+ - 74.54
+ - 74.55
+ - 74.63
+ - 74.80
+ - 74.81
+ - 74.86
+ - 74.112
+ - 74.113
+ - 74.115
+ - 74.117
+ - 74.120
+ - 74.121
+ - 74.122
+ - 74.124
+ - 74.125
+ - 74.200
+ - 74.201
+ - 74.206
+ - 74.207
+ - 74.208
+ - 74.220
+ - 74.222
+ - 75.98
+ - 75.101
+ - 75.119
+ - 75.125
+ - 75.126
+ - 76.12
+ - 76.73
+ - 76.74
+ - 76.163
+ - 76.191
+ - 77.87
+ - 77.235
+ - 77.238
+ - 77.247
+ - 78.46
+ - 78.47
+ - 78.109
+ - 78.129
+ - 78.138
+ - 78.140
+ - 78.152
+ - 79.99
+ - 79.125
+ - 79.170
+ - 79.175
+ - 80.68
+ - 80.69
+ - 80.179
+ - 80.237
+ - 81.19
+ - 81.88
+ - 81.169
+ - 82.98
+ - 82.129
+ - 82.195
+ - 82.208
+ - 83.138
+ - 83.169
+ - 83.222
+ - 84.16
+ - 84.20
+ - 84.45
+ - 85.10
+ - 85.17
+ - 85.25
+ - 85.214
+ - 85.233
+ - 85.252
+ - 86.59
+ - 87.106
+ - 87.118
+ - 87.248
+ - 88.80
+ - 88.86
+ - 88.190
+ - 88.198
+ - 88.208
+ - 88.212
+ - 89.31
+ - 89.45
+ - 89.151
+ - 89.187
+ - 89.238
+ - 89.250
+ - 91.102
+ - 91.121
+ - 91.123
+ - 91.193
+ - 91.196
+ - 91.207
+ - 91.221
+ - 91.226
+ - 91.227
+ - 91.228
+ - 91.250
+ - 93.46
+ - 93.88
+ - 93.95
+ - 93.170
+ - 93.185
+ - 94.23
+ - 94.75
+ - 94.76
+ - 94.102
+ - 94.136
+ - 94.174
+ - 94.198
+ - 94.242
+ - 95.140
+ - 95.174
+ - 95.211
+ - 96.0
+ - 96.30
+ - 96.31
+ - 96.44
+ - 96.45
+ - 96.46
+ - 96.125
+ - 96.126
+ - 96.127
+ - 97.74
+ - 97.107
+ - 98.124
+ - 98.126
+ - 98.129
+ - 98.130
+ - 98.137
+ - 98.138
+ - 98.139
+ - 98.142
+ - 98.143
+ - 99.192
+ - 99.231
+ - 100.43
+ - 101.78
+ - 101.101
+ - 103.11
+ - 103.23
+ - 106.10
+ - 106.187
+ - 107.6
+ - 107.14
+ - 107.20
+ - 107.21
+ - 107.22
+ - 107.23
+ - 108.59
+ - 108.61
+ - 108.62
+ - 108.162
+ - 108.163
+ - 108.166
+ - 108.168
+ - 108.170
+ - 109.104
+ - 109.201
+ - 109.233
+ - 110.34
+ - 110.45
+ - 111.92
+ - 111.221
+ - 113.196
+ - 113.208
+ - 114.32
+ - 114.108
+ - 114.110
+ - 114.111
+ - 114.141
+ - 115.30
+ - 116.90
+ - 116.251
+ - 117.18
+ - 118.21
+ - 118.139
+ - 118.142
+ - 118.143
+ - 118.173
+ - 118.244
+ - 119.160
+ - 119.246
+ - 120.194
+ - 121.50
+ - 121.52
+ - 121.119
+ - 122.115
+ - 122.147
+ - 122.152
+ - 122.209
+ - 122.212
+ - 122.224
+ - 122.248
+ - 123.242
+ - 124.83
+ - 124.150
+ - 124.219
+ - 124.244
+ - 125.6
+ - 127.0
+ - 128.100
+ - 128.241
+ - 131.84
+ - 132.174
+ - 133.242
+ - 140.109
+ - 140.112
+ - 140.123
+ - 140.211
+ - 141.0
+ - 141.8
+ - 141.101
+ - 142.4
+ - 142.234
+ - 144.198
+ - 145.58
+ - 149.47
+ - 149.174
+ - 154.35
+ - 157.55
+ - 158.255
+ - 159.33
+ - 159.174
+ - 160.68
+ - 163.29
+ - 165.83
+ - 168.144
+ - 169.207
+ - 170.140
+ - 170.149
+ - 173.192
+ - 173.193
+ - 173.194
+ - 173.199
+ - 173.201
+ - 173.203
+ - 173.224
+ - 173.230
+ - 173.231
+ - 173.234
+ - 173.236
+ - 173.245
+ - 173.246
+ - 173.247
+ - 173.249
+ - 173.252
+ - 173.254
+ - 173.255
+ - 174.34
+ - 174.36
+ - 174.37
+ - 174.120
+ - 174.121
+ - 174.122
+ - 174.127
+ - 174.129
+ - 174.132
+ - 174.133
+ - 174.136
+ - 174.139
+ - 174.143
+ - 175.28
+ - 175.45
+ - 175.99
+ - 175.182
+ - 176.9
+ - 176.32
+ - 176.34
+ - 178.32
+ - 178.33
+ - 178.63
+ - 180.37
+ - 180.149
+ - 180.188
+ - 180.210
+ - 180.222
+ - 180.233
+ - 180.235
+ - 182.239
+ - 183.81
+ - 183.179
+ - 184.22
+ - 184.72
+ - 184.73
+ - 184.82
+ - 184.85
+ - 184.105
+ - 184.106
+ - 184.107
+ - 184.154
+ - 184.164
+ - 184.168
+ - 184.169
+ - 184.172
+ - 184.173
+ - 185.9
+ - 187.31
+ - 188.40
+ - 188.65
+ - 188.93
+ - 188.121
+ - 188.165
+ - 188.190
+ - 188.227
+ - 188.241
+ - 190.93
+ - 192.31
+ - 192.64
+ - 192.69
+ - 192.104
+ - 192.155
+ - 192.168
+ - 192.204
+ - 193.34
+ - 193.111
+ - 193.235
+ - 194.9
+ - 194.55
+ - 194.71
+ - 194.90
+ - 194.145
+ - 195.14
+ - 195.20
+ - 195.24
+ - 195.81
+ - 195.92
+ - 195.110
+ - 195.191
+ - 195.234
+ - 195.242
+ - 198.1
+ - 198.20
+ - 198.23
+ - 198.61
+ - 198.65
+ - 198.74
+ - 198.105
+ - 198.211
+ - 198.244
+ - 199.15
+ - 199.27
+ - 199.34
+ - 199.47
+ - 199.58
+ - 199.59
+ - 199.66
+ - 199.83
+ - 199.85
+ - 199.96
+ - 199.127
+ - 199.175
+ - 199.187
+ - 199.193
+ - 199.223
+ - 199.233
+ - 199.255
+ - 202.27
+ - 202.32
+ - 202.39
+ - 202.55
+ - 202.60
+ - 202.67
+ - 202.81
+ - 202.82
+ - 202.85
+ - 202.123
+ - 202.125
+ - 202.145
+ - 202.153
+ - 202.155
+ - 202.157
+ - 202.172
+ - 202.177
+ - 202.181
+ - 202.213
+ - 202.214
+ - 202.215
+ - 202.218
+ - 203.2
+ - 203.27
+ - 203.62
+ - 203.69
+ - 203.80
+ - 203.84
+ - 203.85
+ - 203.105
+ - 203.113
+ - 203.131
+ - 203.141
+ - 203.171
+ - 203.174
+ - 203.175
+ - 203.188
+ - 203.189
+ - 204.1
+ - 204.9
+ - 204.14
+ - 204.15
+ - 204.69
+ - 204.74
+ - 204.77
+ - 204.107
+ - 204.145
+ - 204.152
+ - 204.179
+ - 204.197
+ - 204.223
+ - 204.232
+ - 204.244
+ - 204.245
+ - 204.246
+ - 205.134
+ - 205.164
+ - 205.178
+ - 205.186
+ - 205.188
+ - 205.196
+ - 205.204
+ - 206.46
+ - 206.108
+ - 206.125
+ - 206.190
+ - 206.214
+ - 207.7
+ - 207.58
+ - 207.97
+ - 207.192
+ - 207.199
+ - 207.200
+ - 207.241
+ - 208.34
+ - 208.43
+ - 208.51
+ - 208.69
+ - 208.73
+ - 208.75
+ - 208.78
+ - 208.79
+ - 208.80
+ - 208.82
+ - 208.85
+ - 208.86
+ - 208.87
+ - 208.88
+ - 208.90
+ - 208.91
+ - 208.92
+ - 208.94
+ - 208.95
+ - 208.96
+ - 208.97
+ - 208.99
+ - 208.101
+ - 208.109
+ - 208.113
+ - 208.115
+ - 208.131
+ - 208.167
+ - 209.15
+ - 209.17
+ - 209.20
+ - 209.50
+ - 209.54
+ - 209.62
+ - 209.85
+ - 209.116
+ - 209.135
+ - 209.172
+ - 209.197
+ - 209.200
+ - 209.202
+ - 209.222
+ - 209.237
+ - 209.240
+ - 209.246
+ - 209.251
+ - 210.0
+ - 210.3
+ - 210.17
+ - 210.48
+ - 210.59
+ - 210.64
+ - 210.69
+ - 210.71
+ - 210.155
+ - 210.163
+ - 210.172
+ - 210.200
+ - 210.242
+ - 210.243
+ - 210.244
+ - 210.251
+ - 211.13
+ - 211.20
+ - 211.75
+ - 211.144
+ - 211.233
+ - 212.7
+ - 212.27
+ - 212.44
+ - 212.58
+ - 212.64
+ - 212.118
+ - 212.159
+ - 213.52
+ - 213.83
+ - 213.139
+ - 213.163
+ - 213.171
+ - 213.186
+ - 216.8
+ - 216.14
+ - 216.15
+ - 216.18
+ - 216.21
+ - 216.24
+ - 216.35
+ - 216.40
+ - 216.45
+ - 216.55
+ - 216.67
+ - 216.69
+ - 216.70
+ - 216.74
+ - 216.75
+ - 216.92
+ - 216.97
+ - 216.98
+ - 216.115
+ - 216.120
+ - 216.131
+ - 216.139
+ - 216.157
+ - 216.172
+ - 216.176
+ - 216.178
+ - 216.185
+ - 216.187
+ - 216.218
+ - 216.224
+ - 216.230
+ - 216.239
+ - 216.240
+ - 216.251
+ - 217.70
+ - 217.114
+ - 217.118
+ - 217.160
+ - 218.48
+ - 218.145
+ - 218.188
+ - 218.211
+ - 218.213
+ - 219.85
+ - 219.87
+ - 219.94
+ - 219.122
+ - 220.105
+ - 220.130
+ - 220.213
+ - 220.216
+ - 220.228
+ - 220.232
+ - 222.122
+ - 222.239
+ - 223.27
+
+
\ No newline at end of file
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 574a0d74..b0803fb7 100755
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -78,52 +78,5 @@
here:\ngithub.com/shadowsocks
-
-
- - 0.0.0.0/7
- - 10.0.0.0/8
- - 14.0.0.0/8
- - 27.0.0.0/8
- - 36.0.0.0/8
- - 39.0.0.0/8
- - 42.0.0.0/7
- - 49.0.0.0/8
- - 58.0.0.0/7
- - 60.0.0.0/7
- - 101.0.0.0/8
- - 103.0.0.0/8
- - 106.0.0.0/8
- - 110.0.0.0/7
- - 112.0.0.0/4
- - 134.128.0.0/9
- - 139.0.0.0/9
- - 139.128.0.0/9
- - 140.0.0.0/9
- - 140.128.0.0/9
- - 144.0.0.0/9
- - 144.128.0.0/9
- - 150.0.0.0/8
- - 153.0.0.0/8
- - 157.0.0.0/9
- - 157.128.0.0/9
- - 159.128.0.0/9
- - 161.128.0.0/9
- - 162.0.0.0/9
- - 163.0.0.0/8
- - 166.0.0.0/9
- - 167.128.0.0/9
- - 168.128.0.0/9
- - 171.0.0.0/8
- - 172.0.0.0/12
- - 175.0.0.0/8
- - 180.0.0.0/8
- - 182.0.0.0/7
- - 192.112.0.0/12
- - 192.128.0.0/9
- - 202.0.0.0/7
- - 210.0.0.0/7
- - 218.0.0.0/7
- - 220.0.0.0/6
-
diff --git a/src/main/scala/com/github/shadowsocks/ShadowVpnService.scala b/src/main/scala/com/github/shadowsocks/ShadowVpnService.scala
index 8316d513..3d473182 100644
--- a/src/main/scala/com/github/shadowsocks/ShadowVpnService.scala
+++ b/src/main/scala/com/github/shadowsocks/ShadowVpnService.scala
@@ -56,6 +56,7 @@ import java.net.Inet6Address
import java.net.InetAddress
import java.net.UnknownHostException
import android.net.VpnService
+import org.apache.http.conn.util.InetAddressUtils
object ShadowVpnService {
def isServiceStarted: Boolean = {
@@ -229,7 +230,6 @@ class ShadowVpnService extends VpnService {
def startVpn() {
- val prefix = appHost.substring(0, appHost.indexOf('.')).toInt
val builder = new Builder()
builder
.setSession(getString(R.string.app_name))
@@ -237,9 +237,21 @@ class ShadowVpnService extends VpnService {
.addAddress("172.16.0.1", 24)
.addDnsServer("8.8.8.8")
- for (i <- 1 to 254) {
- if (i != prefix && i != 127
- && i != 172 && i != 192 && i != 10) builder.addRoute(i + ".0.0.0", 8)
+ if (InetAddressUtils.isIPv6Address(appHost)) {
+ builder.addRoute("0.0.0.0", 0)
+ } else if (isGFWList) {
+ val gfwList = getResources.getStringArray(R.array.gfw_list)
+ val address = appHost.split('.')
+ val prefix = address(0) + "." + address(1)
+ gfwList.foreach(addr =>
+ if (addr != prefix) builder.addRoute(prefix + ".0.0", 16)
+ )
+ } else {
+ val prefix = appHost.split('.')(0).toInt
+ for (i <- 1 to 254) {
+ if (i != prefix && i != 127
+ && i != 172 && i != 192 && i != 10) builder.addRoute(i + ".0.0.0", 8)
+ }
}
conn = builder.establish()
diff --git a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala
index 967b3fc4..e69e2792 100644
--- a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+++ b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala
@@ -313,6 +313,28 @@ class Shadowsocks extends UnifiedSherlockPreferenceActivity with CompoundButton.
}
}.start()
}
+
+ if (isServiceStarted) {
+ switchButton.setChecked(true)
+ if (ShadowVpnService.isServiceStarted) {
+ val style = new Style.Builder()
+ .setBackgroundColorValue(Style.holoBlueLight)
+ .setDuration(Style.DURATION_INFINITE)
+ .build()
+ switchButton.setEnabled(false)
+ Crouton.makeText(Shadowsocks.this, R.string.vpn_status, style).show()
+ }
+ } else {
+ switchButton.setChecked(false)
+ if (settings.getBoolean("isRunning", false)) {
+ new Thread {
+ override def run() {
+ crash_recovery()
+ handler.sendEmptyMessage(MSG_CRASH_RECOVER)
+ }
+ }.start()
+ }
+ }
}
override def onCreateOptionsMenu(menu: Menu): Boolean = {
@@ -362,29 +384,6 @@ class Shadowsocks extends UnifiedSherlockPreferenceActivity with CompoundButton.
protected override def onResume() {
super.onResume()
val settings: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
- if (getIntent.getAction != Shadowsocks.REQUEST_CONNECT) {
- if (isServiceStarted) {
- switchButton.setChecked(true)
- if (ShadowVpnService.isServiceStarted) {
- val style = new Style.Builder()
- .setBackgroundColorValue(Style.holoBlueLight)
- .setDuration(Style.DURATION_INFINITE)
- .build()
- switchButton.setEnabled(false)
- Crouton.makeText(Shadowsocks.this, R.string.vpn_status, style).show()
- }
- } else {
- switchButton.setChecked(false)
- if (settings.getBoolean("isRunning", false)) {
- new Thread {
- override def run() {
- crash_recovery()
- handler.sendEmptyMessage(MSG_CRASH_RECOVER)
- }
- }.start()
- }
- }
- }
setPreferenceEnabled()
switchButton.setOnCheckedChangeListener(this)
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this)