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
017dd425
Commit
017dd425
authored
Mar 13, 2016
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine #602
parent
04ec29c9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
15 deletions
+15
-15
src/main/scala/com/github/shadowsocks/BaseService.scala
src/main/scala/com/github/shadowsocks/BaseService.scala
+5
-5
src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala
.../scala/com/github/shadowsocks/ShadowsocksNatService.scala
+4
-4
src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
.../scala/com/github/shadowsocks/ShadowsocksVpnService.scala
+6
-6
No files found.
src/main/scala/com/github/shadowsocks/BaseService.scala
View file @
017dd425
...
@@ -63,7 +63,7 @@ trait BaseService extends Service {
...
@@ -63,7 +63,7 @@ trait BaseService extends Service {
private
val
closeReceiver
:
BroadcastReceiver
=
(
context
:
Context
,
intent
:
Intent
)
=>
{
private
val
closeReceiver
:
BroadcastReceiver
=
(
context
:
Context
,
intent
:
Intent
)
=>
{
Toast
.
makeText
(
context
,
R
.
string
.
stopping
,
Toast
.
LENGTH_SHORT
).
show
()
Toast
.
makeText
(
context
,
R
.
string
.
stopping
,
Toast
.
LENGTH_SHORT
).
show
()
stopRunner
()
stopRunner
(
true
)
}
}
var
closeReceiverRegistered
:
Boolean
=
_
var
closeReceiverRegistered
:
Boolean
=
_
...
@@ -106,8 +106,8 @@ trait BaseService extends Service {
...
@@ -106,8 +106,8 @@ trait BaseService extends Service {
override
def
use
(
config
:
Config
)
=
synchronized
(
state
match
{
override
def
use
(
config
:
Config
)
=
synchronized
(
state
match
{
case
State
.
STOPPED
=>
if
(
config
!=
null
)
startRunner
(
config
)
case
State
.
STOPPED
=>
if
(
config
!=
null
)
startRunner
(
config
)
case
State
.
CONNECTED
=>
case
State
.
CONNECTED
=>
if
(
config
==
null
)
stopRunner
()
else
if
(
config
.
profileId
!=
BaseService
.
this
.
config
.
profileId
)
{
if
(
config
==
null
)
stopRunner
(
true
)
else
if
(
config
.
profileId
!=
BaseService
.
this
.
config
.
profileId
)
{
stopRunner
()
stopRunner
(
false
)
startRunner
(
config
)
startRunner
(
config
)
}
}
case
_
=>
Log
.
w
(
BaseService
.
this
.
getClass
.
getSimpleName
,
"Illegal state when invoking use: "
+
state
)
case
_
=>
Log
.
w
(
BaseService
.
this
.
getClass
.
getSimpleName
,
"Illegal state when invoking use: "
+
state
)
...
@@ -132,7 +132,7 @@ trait BaseService extends Service {
...
@@ -132,7 +132,7 @@ trait BaseService extends Service {
}
}
}
}
def
stopRunner
()
{
def
stopRunner
(
stopService
:
Boolean
)
{
// clean up recevier
// clean up recevier
if
(
closeReceiverRegistered
)
{
if
(
closeReceiverRegistered
)
{
unregisterReceiver
(
closeReceiver
)
unregisterReceiver
(
closeReceiver
)
...
@@ -152,7 +152,7 @@ trait BaseService extends Service {
...
@@ -152,7 +152,7 @@ trait BaseService extends Service {
changeState
(
State
.
STOPPED
)
changeState
(
State
.
STOPPED
)
// stop the service if nothing has bound to it
// stop the service if nothing has bound to it
stopSelf
()
if
(
stopService
)
stopSelf
()
}
}
def
updateTrafficTotal
(
tx
:
Long
,
rx
:
Long
)
{
def
updateTrafficTotal
(
tx
:
Long
,
rx
:
Long
)
{
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala
View file @
017dd425
...
@@ -396,7 +396,7 @@ class ShadowsocksNatService extends BaseService {
...
@@ -396,7 +396,7 @@ class ShadowsocksNatService extends BaseService {
}
catch
{
}
catch
{
case
ex
:
Exception
=>
case
ex
:
Exception
=>
changeState
(
State
.
STOPPED
,
getString
(
R
.
string
.
service_failed
))
changeState
(
State
.
STOPPED
,
getString
(
R
.
string
.
service_failed
))
stopRunner
()
stopRunner
(
false
)
this
.
config
=
null
this
.
config
=
null
}
}
}
}
...
@@ -427,13 +427,13 @@ class ShadowsocksNatService extends BaseService {
...
@@ -427,13 +427,13 @@ class ShadowsocksNatService extends BaseService {
notification
=
new
ShadowsocksNotification
(
this
,
config
.
profileName
,
true
)
notification
=
new
ShadowsocksNotification
(
this
,
config
.
profileName
,
true
)
}
else
{
}
else
{
changeState
(
State
.
STOPPED
,
getString
(
R
.
string
.
service_failed
))
changeState
(
State
.
STOPPED
,
getString
(
R
.
string
.
service_failed
))
stopRunner
()
stopRunner
(
false
)
}
}
}
}
}
}
}
}
override
def
stopRunner
()
{
override
def
stopRunner
(
stopService
:
Boolean
)
{
// channge the state
// channge the state
changeState
(
State
.
STOPPING
)
changeState
(
State
.
STOPPING
)
...
@@ -445,7 +445,7 @@ class ShadowsocksNatService extends BaseService {
...
@@ -445,7 +445,7 @@ class ShadowsocksNatService extends BaseService {
// reset NAT
// reset NAT
killProcesses
()
killProcesses
()
super
.
stopRunner
()
super
.
stopRunner
(
stopService
)
}
}
override
def
getTag
=
TAG
override
def
getTag
=
TAG
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
View file @
017dd425
...
@@ -106,10 +106,10 @@ class ShadowsocksVpnService extends VpnService with BaseService {
...
@@ -106,10 +106,10 @@ class ShadowsocksVpnService extends VpnService with BaseService {
}
}
override
def
onRevoke
()
{
override
def
onRevoke
()
{
stopRunner
()
stopRunner
(
false
)
}
}
override
def
stopRunner
()
{
override
def
stopRunner
(
stopService
:
Boolean
)
{
if
(
vpnThread
!=
null
)
{
if
(
vpnThread
!=
null
)
{
vpnThread
.
stopThread
()
vpnThread
.
stopThread
()
...
@@ -132,7 +132,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
...
@@ -132,7 +132,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
conn
=
null
conn
=
null
}
}
super
.
stopRunner
()
super
.
stopRunner
(
stopService
)
}
}
def
getVersionName
:
String
=
{
def
getVersionName
:
String
=
{
...
@@ -193,7 +193,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
...
@@ -193,7 +193,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
}
catch
{
}
catch
{
case
ex
:
Exception
=>
case
ex
:
Exception
=>
changeState
(
State
.
STOPPED
,
getString
(
R
.
string
.
service_failed
))
changeState
(
State
.
STOPPED
,
getString
(
R
.
string
.
service_failed
))
stopRunner
()
stopRunner
(
false
)
this
.
config
=
null
this
.
config
=
null
}
}
}
}
...
@@ -221,7 +221,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
...
@@ -221,7 +221,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
notification
=
new
ShadowsocksNotification
(
this
,
config
.
profileName
)
notification
=
new
ShadowsocksNotification
(
this
,
config
.
profileName
)
}
else
{
}
else
{
changeState
(
State
.
STOPPED
,
getString
(
R
.
string
.
service_failed
))
changeState
(
State
.
STOPPED
,
getString
(
R
.
string
.
service_failed
))
stopRunner
()
stopRunner
(
false
)
}
}
}
}
}
}
...
@@ -386,7 +386,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
...
@@ -386,7 +386,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
}
}
if
(
conn
==
null
)
{
if
(
conn
==
null
)
{
stopRunner
()
stopRunner
(
false
)
return
-
1
return
-
1
}
}
...
...
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