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
1041dc37
Commit
1041dc37
authored
Jan 20, 2017
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move non-options to command line options
parent
d734e9fd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
19 deletions
+22
-19
mobile/src/main/scala/com/github/shadowsocks/BaseService.scala
...e/src/main/scala/com/github/shadowsocks/BaseService.scala
+17
-17
mobile/src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
.../scala/com/github/shadowsocks/ShadowsocksVpnService.scala
+5
-2
No files found.
mobile/src/main/scala/com/github/shadowsocks/BaseService.scala
View file @
1041dc37
...
@@ -42,6 +42,8 @@ import okhttp3.{Dns, FormBody, OkHttpClient, Request}
...
@@ -42,6 +42,8 @@ import okhttp3.{Dns, FormBody, OkHttpClient, Request}
import
org.json.JSONObject
import
org.json.JSONObject
import
scala.collection.mutable
import
scala.collection.mutable
import
scala.collection.mutable.ArrayBuffer
import
scala.collection.JavaConversions._
import
scala.util.Random
import
scala.util.Random
trait
BaseService
extends
Service
{
trait
BaseService
extends
Service
{
...
@@ -49,7 +51,7 @@ trait BaseService extends Service {
...
@@ -49,7 +51,7 @@ trait BaseService extends Service {
@volatile
private
var
state
=
State
.
STOPPED
@volatile
private
var
state
=
State
.
STOPPED
@volatile
protected
var
profile
:
Profile
=
_
@volatile
protected
var
profile
:
Profile
=
_
@volatile
private
var
plugin
:
PluginOptions
=
_
@volatile
private
var
plugin
:
PluginOptions
=
_
@volatile
pr
ivate
var
pluginPath
:
String
=
_
@volatile
pr
otected
var
pluginPath
:
String
=
_
case
class
NameNotResolvedException
()
extends
IOException
case
class
NameNotResolvedException
()
extends
IOException
case
class
NullConnectionException
()
extends
NullPointerException
case
class
NullConnectionException
()
extends
NullPointerException
...
@@ -313,24 +315,22 @@ trait BaseService extends Service {
...
@@ -313,24 +315,22 @@ trait BaseService extends Service {
}
}
}
}
protected
def
buildShadowsocksConfig
(
file
:
String
,
localPortOffset
:
Int
=
0
,
vpn
:
Boolean
=
false
)
:
String
=
{
protected
def
buildPluginCommandLine
()
:
ArrayBuffer
[
String
]
=
{
val
result
=
ArrayBuffer
(
pluginPath
)
if
(
TcpFastOpen
.
sendEnabled
)
result
+=
"--fast-open"
result
}
protected
def
buildShadowsocksConfig
(
file
:
String
,
localPortOffset
:
Int
=
0
)
:
String
=
{
val
config
=
new
JSONObject
()
val
config
=
new
JSONObject
()
config
.
put
(
"server"
,
profile
.
host
)
.
put
(
"server"
,
profile
.
host
)
config
.
put
(
"server_port"
,
profile
.
remotePort
)
.
put
(
"server_port"
,
profile
.
remotePort
)
config
.
put
(
"local_port"
,
profile
.
localPort
+
localPortOffset
)
.
put
(
"local_port"
,
profile
.
localPort
+
localPortOffset
)
config
.
put
(
"password"
,
profile
.
password
)
.
put
(
"password"
,
profile
.
password
)
config
.
put
(
"method"
,
profile
.
method
)
.
put
(
"method"
,
profile
.
method
)
if
(
profile
.
auth
)
config
.
put
(
"auth"
,
true
)
if
(
profile
.
auth
)
config
.
put
(
"auth"
,
true
)
if
(
pluginPath
!=
null
)
{
if
(
pluginPath
!=
null
)
config
config
.
put
(
"plugin"
,
pluginPath
)
.
put
(
"plugin"
,
Commandline
.
toString
(
buildPluginCommandLine
()))
val
plugin_opts
=
if
(
vpn
)
{
.
put
(
"plugin_opts"
,
plugin
.
toString
)
"V;P="
+
getApplicationInfo
.
dataDir
+
";"
+
plugin
.
toString
}
else
{
plugin
.
toString
}
Log
.
d
(
"shadowsocks"
,
plugin_opts
)
config
.
put
(
"plugin_opts"
,
plugin_opts
)
}
IOUtils
.
writeString
(
file
,
config
.
toString
)
IOUtils
.
writeString
(
file
,
config
.
toString
)
file
file
}
}
...
...
mobile/src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
View file @
1041dc37
...
@@ -162,12 +162,15 @@ class ShadowsocksVpnService extends VpnService with BaseService {
...
@@ -162,12 +162,15 @@ class ShadowsocksVpnService extends VpnService with BaseService {
}
}
}
}
override
protected
def
buildPluginCommandLine
()
:
ArrayBuffer
[
String
]
=
super
.
buildPluginCommandLine
()
++=
Seq
(
"-V"
,
"-P"
,
getApplicationInfo
.
dataDir
)
def
startShadowsocksDaemon
()
{
def
startShadowsocksDaemon
()
{
val
cmd
=
ArrayBuffer
[
String
](
getApplicationInfo
.
nativeLibraryDir
+
"/libss-local.so"
,
"-V"
val
cmd
=
ArrayBuffer
[
String
](
getApplicationInfo
.
nativeLibraryDir
+
"/libss-local.so"
,
"-V"
,
"-b"
,
"127.0.0.1"
,
"-b"
,
"127.0.0.1"
,
"-t"
,
"600"
,
"-t"
,
"600"
,
"-P"
,
getApplicationInfo
.
dataDir
,
"-P"
,
getApplicationInfo
.
dataDir
,
"-c"
,
buildShadowsocksConfig
(
getApplicationInfo
.
dataDir
+
"/ss-local-vpn.conf"
,
0
,
true
))
,
"-c"
,
buildShadowsocksConfig
(
getApplicationInfo
.
dataDir
+
"/ss-local-vpn.conf"
,
0
))
if
(
profile
.
udpdns
)
cmd
+=
"-u"
if
(
profile
.
udpdns
)
cmd
+=
"-u"
...
@@ -190,7 +193,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
...
@@ -190,7 +193,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
,
"-b"
,
"127.0.0.1"
,
"-b"
,
"127.0.0.1"
,
"-L"
,
if
(
profile
.
remoteDns
==
null
)
"8.8.8.8:53"
else
profile
.
remoteDns
+
":53"
,
"-L"
,
if
(
profile
.
remoteDns
==
null
)
"8.8.8.8:53"
else
profile
.
remoteDns
+
":53"
,
"-P"
,
getApplicationInfo
.
dataDir
,
"-P"
,
getApplicationInfo
.
dataDir
,
"-c"
,
buildShadowsocksConfig
(
getApplicationInfo
.
dataDir
+
"/ss-tunnel-vpn.conf"
,
53
,
true
))
,
"-c"
,
buildShadowsocksConfig
(
getApplicationInfo
.
dataDir
+
"/ss-tunnel-vpn.conf"
,
53
))
if
(
BuildConfig
.
DEBUG
)
Log
.
d
(
TAG
,
Commandline
.
toString
(
cmd
))
if
(
BuildConfig
.
DEBUG
)
Log
.
d
(
TAG
,
Commandline
.
toString
(
cmd
))
sstunnelProcess
=
new
GuardedProcess
(
cmd
).
start
()
sstunnelProcess
=
new
GuardedProcess
(
cmd
).
start
()
}
}
...
...
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