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
655ef1ee
Commit
655ef1ee
authored
Aug 27, 2016
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine TFO
parent
04be6057
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
8 additions
and
16 deletions
+8
-16
src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala
...scala/com/github/shadowsocks/ShadowsocksApplication.scala
+1
-6
src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala
.../scala/com/github/shadowsocks/ShadowsocksNatService.scala
+1
-1
src/main/scala/com/github/shadowsocks/ShadowsocksSettings.scala
...in/scala/com/github/shadowsocks/ShadowsocksSettings.scala
+2
-5
src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
.../scala/com/github/shadowsocks/ShadowsocksVpnService.scala
+1
-1
src/main/scala/com/github/shadowsocks/utils/TcpFastOpen.scala
...main/scala/com/github/shadowsocks/utils/TcpFastOpen.scala
+3
-3
No files found.
src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala
View file @
655ef1ee
...
...
@@ -112,12 +112,7 @@ class ShadowsocksApplication extends Application {
}
pending
.
setResultCallback
(
callback
,
2
,
TimeUnit
.
SECONDS
)
// TFO
val
tfo
=
settings
.
getBoolean
(
Key
.
tfo
,
false
)
if
(
tfo
&&
!
TcpFastOpen
.
isEnabled
)
{
TcpFastOpen
.
enabled
(
true
)
}
TcpFastOpen
.
enabled
(
settings
.
getBoolean
(
Key
.
tfo
,
false
))
}
def
refreshContainerHolder
{
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala
View file @
655ef1ee
...
...
@@ -105,7 +105,7 @@ class ShadowsocksNatService extends BaseService {
if
(
profile
.
auth
)
cmd
+=
"-A"
if
(
TcpFastOpen
.
is
Enabled
)
cmd
+=
"--fast-open"
if
(
TcpFastOpen
.
send
Enabled
)
cmd
+=
"--fast-open"
if
(
profile
.
route
!=
Route
.
ALL
)
{
cmd
+=
"--acl"
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksSettings.scala
View file @
655ef1ee
...
...
@@ -155,17 +155,14 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
}
switch
.
setChecked
(
BootReceiver
.
getEnabled
(
activity
))
if
(
getPreferenceManager
.
getSharedPreferences
.
getBoolean
(
Key
.
tfo
,
false
)
&&
!
TcpFastOpen
.
isEnabled
)
{
TcpFastOpen
.
enabled
(
true
)
}
val
tfo
=
findPreference
(
Key
.
tfo
).
asInstanceOf
[
SwitchPreference
]
tfo
.
setChecked
(
TcpFastOpen
.
is
Enabled
)
tfo
.
setChecked
(
TcpFastOpen
.
send
Enabled
)
tfo
.
setOnPreferenceChangeListener
((
_
,
v
)
=>
{
val
value
=
v
.
asInstanceOf
[
Boolean
]
val
result
=
TcpFastOpen
.
enabled
(
value
)
if
(
result
!=
null
&&
result
!=
"Success."
)
Snackbar
.
make
(
activity
.
findViewById
(
android
.
R
.
id
.
content
),
result
,
Snackbar
.
LENGTH_LONG
).
show
()
value
==
TcpFastOpen
.
is
Enabled
value
==
TcpFastOpen
.
send
Enabled
})
if
(!
TcpFastOpen
.
supported
)
{
tfo
.
setEnabled
(
false
)
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
View file @
655ef1ee
...
...
@@ -266,7 +266,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
cmd
+=
(
getApplicationInfo
.
dataDir
+
"/acl.list"
)
}
if
(
TcpFastOpen
.
is
Enabled
)
cmd
+=
"--fast-open"
if
(
TcpFastOpen
.
send
Enabled
)
cmd
+=
"--fast-open"
if
(
BuildConfig
.
DEBUG
)
Log
.
d
(
TAG
,
cmd
.
mkString
(
" "
))
...
...
src/main/scala/com/github/shadowsocks/utils/TcpFastOpen.scala
View file @
655ef1ee
...
...
@@ -23,12 +23,12 @@ object TcpFastOpen {
case
_
=>
false
}
def
is
Enabled
=
{
def
send
Enabled
=
{
val
file
=
new
File
(
"/proc/sys/net/ipv4/tcp_fastopen"
)
file
.
canRead
&&
(
Utils
.
readAllLines
(
file
).
toInt
&
1
)
>
0
}
def
enabled
(
value
:
Boolean
)
:
String
=
{
def
enabled
(
value
:
Boolean
)
:
String
=
if
(
sendEnabled
!=
value
)
{
val
res
=
Shell
.
run
(
"su"
,
Array
(
"if echo "
+
(
if
(
value
)
3
else
0
)
+
" > /proc/sys/net/ipv4/tcp_fastopen; then"
,
" echo Success."
,
...
...
@@ -36,5 +36,5 @@ object TcpFastOpen {
" echo Failed."
,
"fi"
),
null
,
true
)
if
(
res
!=
null
)
res
.
asScala
.
mkString
(
"\n"
)
else
null
}
}
else
null
}
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