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
5b1432e4
Commit
5b1432e4
authored
Aug 28, 2016
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle stdout/stderr of GuardedProcess properly
parent
7ca4e4ec
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
19 deletions
+30
-19
kcptun/kcptun
kcptun/kcptun
+1
-1
src/main/jni/pdnsd
src/main/jni/pdnsd
+1
-1
src/main/scala/com/github/shadowsocks/GuardedProcess.scala
src/main/scala/com/github/shadowsocks/GuardedProcess.scala
+20
-7
src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala
.../scala/com/github/shadowsocks/ShadowsocksNatService.scala
+4
-5
src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
.../scala/com/github/shadowsocks/ShadowsocksVpnService.scala
+4
-5
No files found.
kcptun
@
c4054b07
Subproject commit
e613b5ad610cd1f51dd40fe378daaba224df5009
Subproject commit
c4054b07a6b493f48d4e9c35c6c1a4a047462325
pdnsd
@
7a769627
Subproject commit
b51fd4f65cfe2d9765a6599c9ea509c767b652bf
Subproject commit
7a769627959ab2e27f0eadafcc89aed14d364ffd
src/main/scala/com/github/shadowsocks/GuardedProcess.scala
View file @
5b1432e4
...
...
@@ -39,18 +39,33 @@
package
com.github.shadowsocks
import
java.io.
{
IOException
,
InputStream
,
OutputStream
}
import
java.io.
_
import
java.lang.System.currentTimeMillis
import
java.util.concurrent.Semaphore
import
android.util.Log
import
scala.collection.JavaConversions._
import
scala.collection.immutable.Stream
import
scala.util.control.Exception._
class
StreamLogger
(
is
:
InputStream
,
tag
:
String
)
extends
Thread
{
def
withCloseable
[
T
<:
Closeable
,
R
](
t
:
T
)(
f
:
T
=>
R
)
:
R
=
{
allCatch
.
andFinally
{
t
.
close
}
apply
{
f
(
t
)
}
}
override
def
run
()
{
withCloseable
(
new
BufferedReader
(
new
InputStreamReader
(
is
)))
{
br
=>
Stream
.
continually
(
br
.
readLine
()).
takeWhile
(
_
!=
null
).
foreach
(
Log
.
i
(
tag
,
_
))
}
}
}
/**
* @author ayanamist@gmail.com
*/
class
GuardedProcess
(
cmd
:
Seq
[
String
])
extends
Process
{
class
GuardedProcess
(
cmd
:
Seq
[
String
])
{
private
val
TAG
=
classOf
[
GuardedProcess
].
getSimpleName
@volatile
private
var
guardThread
:
Thread
=
_
...
...
@@ -72,6 +87,9 @@ class GuardedProcess(cmd: Seq[String]) extends Process {
process
=
new
ProcessBuilder
(
cmd
).
redirectErrorStream
(
true
).
start
val
is
=
process
.
getInputStream
new
StreamLogger
(
is
,
TAG
).
start
if
(
callback
==
null
)
callback
=
onRestartCallback
else
callback
()
semaphore
.
release
...
...
@@ -118,11 +136,6 @@ class GuardedProcess(cmd: Seq[String]) extends Process {
process
.
destroy
()
}
def
exitValue
:
Int
=
throw
new
UnsupportedOperationException
def
getErrorStream
:
InputStream
=
throw
new
UnsupportedOperationException
def
getInputStream
:
InputStream
=
throw
new
UnsupportedOperationException
def
getOutputStream
:
OutputStream
=
throw
new
UnsupportedOperationException
@throws
(
classOf
[
InterruptedException
])
def
waitFor
=
{
guardThread
.
join
()
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala
View file @
5b1432e4
...
...
@@ -40,7 +40,6 @@
package
com.github.shadowsocks
import
java.io.File
import
java.lang.Process
import
java.net.
{
Inet6Address
,
InetAddress
}
import
java.util.Locale
...
...
@@ -65,10 +64,10 @@ class ShadowsocksNatService extends BaseService {
private
var
notification
:
ShadowsocksNotification
=
_
val
myUid
=
android
.
os
.
Process
.
myUid
()
var
sslocalProcess
:
Process
=
_
var
sstunnelProcess
:
Process
=
_
var
redsocksProcess
:
Process
=
_
var
pdnsdProcess
:
Process
=
_
var
sslocalProcess
:
Guarded
Process
=
_
var
sstunnelProcess
:
Guarded
Process
=
_
var
redsocksProcess
:
Guarded
Process
=
_
var
pdnsdProcess
:
Guarded
Process
=
_
var
su
:
Shell.Interactive
=
_
def
startShadowsocksDaemon
()
{
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
View file @
5b1432e4
...
...
@@ -40,7 +40,6 @@
package
com.github.shadowsocks
import
java.io.File
import
java.lang.Process
import
java.util.Locale
import
android.content._
...
...
@@ -63,10 +62,10 @@ class ShadowsocksVpnService extends VpnService with BaseService {
var
vpnThread
:
ShadowsocksVpnThread
=
_
private
var
notification
:
ShadowsocksNotification
=
_
var
sslocalProcess
:
Process
=
_
var
sstunnelProcess
:
Process
=
_
var
pdnsdProcess
:
Process
=
_
var
tun2socksProcess
:
Process
=
_
var
sslocalProcess
:
Guarded
Process
=
_
var
sstunnelProcess
:
Guarded
Process
=
_
var
pdnsdProcess
:
Guarded
Process
=
_
var
tun2socksProcess
:
Guarded
Process
=
_
override
def
onBind
(
intent
:
Intent
)
:
IBinder
=
{
val
action
=
intent
.
getAction
...
...
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