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
7cd4ecc7
Commit
7cd4ecc7
authored
Jan 20, 2019
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Always write something on protect failure
parent
c9550442
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
21 deletions
+18
-21
core/src/main/java/com/github/shadowsocks/bg/VpnService.kt
core/src/main/java/com/github/shadowsocks/bg/VpnService.kt
+18
-21
No files found.
core/src/main/java/com/github/shadowsocks/bg/VpnService.kt
View file @
7cd4ecc7
...
@@ -39,6 +39,7 @@ import com.github.shadowsocks.utils.Key
...
@@ -39,6 +39,7 @@ import com.github.shadowsocks.utils.Key
import
com.github.shadowsocks.utils.Subnet
import
com.github.shadowsocks.utils.Subnet
import
com.github.shadowsocks.utils.parseNumericAddress
import
com.github.shadowsocks.utils.parseNumericAddress
import
com.github.shadowsocks.utils.printLog
import
com.github.shadowsocks.utils.printLog
import
java.io.Closeable
import
java.io.File
import
java.io.File
import
java.io.FileDescriptor
import
java.io.FileDescriptor
import
java.io.IOException
import
java.io.IOException
...
@@ -74,36 +75,32 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
...
@@ -74,36 +75,32 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
.
build
()
.
build
()
}
}
class
CloseableFd
(
val
fd
:
FileDescriptor
)
:
Closeable
{
override
fun
close
()
=
Os
.
close
(
fd
)
}
private
inner
class
ProtectWorker
:
LocalSocketListener
(
"ShadowsocksVpnThread"
)
{
private
inner
class
ProtectWorker
:
LocalSocketListener
(
"ShadowsocksVpnThread"
)
{
override
val
socketFile
:
File
=
File
(
Core
.
deviceStorage
.
noBackupFilesDir
,
"protect_path"
)
override
val
socketFile
:
File
=
File
(
Core
.
deviceStorage
.
noBackupFilesDir
,
"protect_path"
)
override
fun
accept
(
socket
:
LocalSocket
)
{
override
fun
accept
(
socket
:
LocalSocket
)
=
try
{
try
{
socket
.
inputStream
.
read
()
socket
.
inputStream
.
read
()
val
fd
=
socket
.
ancillaryFileDescriptors
!!
.
single
()
!!
val
fd
=
socket
.
ancillaryFileDescriptors
!!
.
single
()
!!
socket
.
outputStream
.
write
(
if
(
try
{
CloseableFd
(
fd
).
use
{
val
network
=
underlyingNetwork
socket
.
outputStream
.
write
(
if
(
underlyingNetwork
.
let
{
network
->
if
(
network
!=
null
&&
Build
.
VERSION
.
SDK_INT
>=
23
)
{
if
(
network
!=
null
&&
Build
.
VERSION
.
SDK_INT
>=
23
)
try
{
try
{
network
.
bindSocket
(
fd
)
network
.
bindSocket
(
fd
)
}
catch
(
e
:
SocketException
)
{
// silently ignore ENONET (Machine is not on the network)
if
((
e
.
cause
as
?
ErrnoException
)
?.
errno
==
64
)
e
.
printStackTrace
()
else
throw
e
}
true
true
}
catch
(
e
:
IOException
)
{
// suppress ENONET (Machine is not on the network)
if
((
e
.
cause
as
?
ErrnoException
)
?.
errno
!=
64
)
printLog
(
e
)
false
}
else
protect
(
getInt
.
invoke
(
fd
)
as
Int
)
}
else
protect
(
getInt
.
invoke
(
fd
)
as
Int
)
}
finally
{
try
{
Os
.
close
(
fd
)
}
catch
(
e
:
ErrnoException
)
{
printLog
(
e
)
}
})
0
else
1
)
})
0
else
1
)
}
}
catch
(
e
:
IOException
)
{
}
catch
(
e
:
IOException
)
{
printLog
(
e
)
printLog
(
e
)
}
}
}
}
}
inner
class
NullConnectionException
:
NullPointerException
()
{
inner
class
NullConnectionException
:
NullPointerException
()
{
override
fun
getLocalizedMessage
()
=
getString
(
R
.
string
.
reboot_required
)
override
fun
getLocalizedMessage
()
=
getString
(
R
.
string
.
reboot_required
)
}
}
...
...
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