Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
7356eded
Commit
7356eded
authored
Apr 09, 2017
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #1197
parent
1268376b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
5 deletions
+23
-5
mobile/src/main/scala/com/github/shadowsocks/BaseService.scala
...e/src/main/scala/com/github/shadowsocks/BaseService.scala
+15
-3
mobile/src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
.../scala/com/github/shadowsocks/ShadowsocksVpnService.scala
+8
-2
No files found.
mobile/src/main/scala/com/github/shadowsocks/BaseService.scala
View file @
7356eded
...
...
@@ -25,6 +25,8 @@ import java.net.InetAddress
import
java.util
import
java.util.concurrent.TimeUnit
import
java.util.
{
Timer
,
TimerTask
}
import
java.net.InetAddress
import
java.net.Inet6Address
import
android.app.Service
import
android.content.
{
BroadcastReceiver
,
Context
,
Intent
,
IntentFilter
}
...
...
@@ -330,6 +332,13 @@ trait BaseService extends Service {
file
}
private
final
def
buildRemoteDns
(
remoteDns
:
String
)
:
String
=
{
val
addr
=
InetAddress
.
getByName
(
remoteDns
)
if
(
addr
.
isInstanceOf
[
Inet6Address
])
return
"["
+
remoteDns
+
"]"
remoteDns
}
protected
final
def
buildOvertureConfig
(
file
:
String
)
:
String
=
{
val
config
=
new
JSONObject
()
.
put
(
"BindAddress"
,
":"
+
(
profile
.
localPort
+
53
))
...
...
@@ -356,14 +365,17 @@ trait BaseService extends Service {
makeDns
(
"Primary-1"
,
"119.29.29.29"
,
edns
=
false
),
makeDns
(
"Primary-2"
,
"114.114.114.114"
,
edns
=
false
)
)))
.
put
(
"AlternativeDNS"
,
new
JSONArray
().
put
(
makeDns
(
"Alternative"
,
profile
.
remoteDns
)))
.
put
(
"AlternativeDNS"
,
new
JSONArray
().
put
(
makeDns
(
"Alternative"
,
buildRemoteDns
(
profile
.
remoteDns
.
trim
))))
.
put
(
"IPNetworkFile"
,
"china_ip_list.txt"
)
.
put
(
"DomainFile"
,
"gfwlist.txt"
)
case
Acl
.
CHINALIST
=>
config
.
put
(
"PrimaryDNS"
,
new
JSONArray
().
put
(
makeDns
(
"Primary"
,
"119.29.29.29"
)))
.
put
(
"AlternativeDNS"
,
new
JSONArray
().
put
(
makeDns
(
"Alternative"
,
profile
.
remoteDns
)))
.
put
(
"AlternativeDNS"
,
new
JSONArray
().
put
(
makeDns
(
"Alternative"
,
buildRemoteDns
(
profile
.
remoteDns
.
trim
))))
case
_
=>
config
.
put
(
"PrimaryDNS"
,
new
JSONArray
().
put
(
makeDns
(
"Primary"
,
profile
.
remoteDns
)))
.
put
(
"PrimaryDNS"
,
new
JSONArray
().
put
(
makeDns
(
"Primary"
,
buildRemoteDns
(
profile
.
remoteDns
.
trim
))))
.
put
(
"AlternativeDNS"
,
new
JSONArray
().
put
(
makeDns
(
"Alternative"
,
"208.67.222.222"
)))
}
IOUtils
.
writeString
(
new
File
(
getFilesDir
,
file
),
config
.
toString
)
...
...
mobile/src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
View file @
7356eded
...
...
@@ -22,6 +22,8 @@ package com.github.shadowsocks
import
java.io.File
import
java.util.Locale
import
java.net.InetAddress
import
java.net.Inet6Address
import
android.content._
import
android.content.pm.PackageManager.NameNotFoundException
...
...
@@ -189,7 +191,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
.
setMtu
(
VPN_MTU
)
.
addAddress
(
PRIVATE_VLAN
.
formatLocal
(
Locale
.
ENGLISH
,
"1"
),
24
)
builder
.
addDnsServer
(
profile
.
remoteDns
.
trim
)
builder
.
addDnsServer
(
"8.8.8.8"
)
// It's fake DNS for tun2socks, not the real remote DNS
if
(
profile
.
ipv6
)
{
builder
.
addAddress
(
PRIVATE_VLAN6
.
formatLocal
(
Locale
.
ENGLISH
,
"1"
),
126
)
...
...
@@ -221,7 +223,11 @@ class ShadowsocksVpnService extends VpnService with BaseService {
val
subnet
=
Subnet
.
fromString
(
cidr
)
builder
.
addRoute
(
subnet
.
address
.
getHostAddress
,
subnet
.
prefixSize
)
})
builder
.
addRoute
(
profile
.
remoteDns
.
trim
,
32
)
val
addr
=
InetAddress
.
getByName
(
profile
.
remoteDns
.
trim
)
if
(
addr
.
isInstanceOf
[
Inet6Address
])
builder
.
addRoute
(
addr
,
128
)
else
if
(
addr
.
isInstanceOf
[
InetAddress
])
builder
.
addRoute
(
addr
,
32
)
}
conn
=
builder
.
establish
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment