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
ea738d17
Commit
ea738d17
authored
Apr 24, 2017
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine #1217
parent
915b1a74
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
30 deletions
+13
-30
mobile/src/main/scala/com/github/shadowsocks/BaseService.scala
...e/src/main/scala/com/github/shadowsocks/BaseService.scala
+10
-20
mobile/src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala
.../scala/com/github/shadowsocks/ShadowsocksNatService.scala
+1
-1
mobile/src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
.../scala/com/github/shadowsocks/ShadowsocksVpnService.scala
+2
-9
No files found.
mobile/src/main/scala/com/github/shadowsocks/BaseService.scala
View file @
ea738d17
...
...
@@ -315,13 +315,6 @@ 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
))
...
...
@@ -333,7 +326,10 @@ trait BaseService extends Service {
def
makeDns
(
name
:
String
,
address
:
String
,
edns
:
Boolean
=
true
)
=
{
val
dns
=
new
JSONObject
()
.
put
(
"Name"
,
name
)
.
put
(
"Address"
,
address
+
":53"
)
.
put
(
"Address"
,
(
Utils
.
parseNumericAddress
(
address
)
match
{
case
_:
Inet6Address
=>
'['
+
address
+
']'
case
_
=>
address
})
+
":53"
)
.
put
(
"Timeout"
,
6
)
.
put
(
"EDNSClientSubnet"
,
new
JSONObject
().
put
(
"Policy"
,
"disable"
))
if
(
edns
)
dns
...
...
@@ -342,29 +338,23 @@ trait BaseService extends Service {
else
dns
.
put
(
"Protocol"
,
"udp"
)
dns
}
val
remoteDns
=
new
JSONArray
(
profile
.
remoteDns
.
split
(
","
).
zipWithIndex
.
map
{
case
(
dns
,
i
)
=>
makeDns
(
"UserDef-"
+
i
,
dns
.
trim
)
})
profile
.
route
match
{
case
Acl
.
BYPASS_CHN
|
Acl
.
BYPASS_LAN_CHN
|
Acl
.
GFWLIST
|
Acl
.
CUSTOM_RULES
=>
config
.
put
(
"PrimaryDNS"
,
new
JSONArray
(
Array
(
makeDns
(
"Primary-1"
,
"119.29.29.29"
,
edns
=
false
),
makeDns
(
"Primary-2"
,
"114.114.114.114"
,
edns
=
false
)
)))
.
put
(
"AlternativeDNS"
,
new
JSONArray
(
for
(
remoteDns
<-
profile
.
remoteDns
.
split
(
","
))
yield
makeDns
(
remoteDns
.
trim
,
buildRemoteDns
(
remoteDns
.
trim
)
)))
.
put
(
"AlternativeDNS"
,
remoteDns
)
.
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
(
for
(
remoteDns
<-
profile
.
remoteDns
.
split
(
","
))
yield
makeDns
(
remoteDns
.
trim
,
buildRemoteDns
(
remoteDns
.
trim
)
)))
.
put
(
"AlternativeDNS"
,
remoteDns
)
case
_
=>
config
.
put
(
"PrimaryDNS"
,
new
JSONArray
(
for
(
remoteDns
<-
profile
.
remoteDns
.
split
(
","
))
yield
makeDns
(
remoteDns
.
trim
,
buildRemoteDns
(
remoteDns
.
trim
)
)))
.
put
(
"PrimaryDNS"
,
new
JSONArray
(
remoteDns
))
// no need to setup AlternativeDNS in Acl.ALL/BYPASS_LAN mode
.
put
(
"OnlyPrimaryDNS"
,
true
)
}
...
...
mobile/src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala
View file @
ea738d17
...
...
@@ -74,7 +74,7 @@ class ShadowsocksNatService extends BaseService {
"-t"
,
"10"
,
"-b"
,
"127.0.0.1"
,
"-l"
,
(
profile
.
localPort
+
63
).
toString
,
"-L"
,
profile
.
remoteDns
.
split
(
","
)
(
0
)
.
trim
+
":53"
,
"-L"
,
profile
.
remoteDns
.
split
(
","
)
.
head
.
trim
+
":53"
,
"-c"
,
buildShadowsocksConfig
(
"ss-tunnel-nat.conf"
))
if
(
profile
.
udpdns
)
cmd
.
append
(
"-u"
)
...
...
mobile/src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
View file @
ea738d17
...
...
@@ -22,8 +22,6 @@ 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
...
...
@@ -223,13 +221,8 @@ class ShadowsocksVpnService extends VpnService with BaseService {
val
subnet
=
Subnet
.
fromString
(
cidr
)
builder
.
addRoute
(
subnet
.
address
.
getHostAddress
,
subnet
.
prefixSize
)
})
profile
.
remoteDns
.
split
(
","
).
foreach
(
remoteDns
=>
{
val
addr
=
InetAddress
.
getByName
(
remoteDns
.
trim
)
if
(
addr
.
isInstanceOf
[
Inet6Address
])
builder
.
addRoute
(
addr
,
128
)
else
if
(
addr
.
isInstanceOf
[
InetAddress
])
builder
.
addRoute
(
addr
,
32
)
})
profile
.
remoteDns
.
split
(
","
).
map
(
dns
=>
Utils
.
parseNumericAddress
(
dns
.
trim
)).
foreach
(
dns
=>
builder
.
addRoute
(
dns
,
dns
.
getAddress
.
length
<<
3
))
}
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