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
a255bc95
Commit
a255bc95
authored
Jan 31, 2020
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine checkConnectivity fallback
parent
fa1a87ec
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
+12
-11
core/src/main/java/com/github/shadowsocks/bg/DnsResolverCompat.kt
.../main/java/com/github/shadowsocks/bg/DnsResolverCompat.kt
+12
-11
No files found.
core/src/main/java/com/github/shadowsocks/bg/DnsResolverCompat.kt
View file @
a255bc95
...
...
@@ -38,8 +38,6 @@ import com.github.shadowsocks.utils.printLog
import
kotlinx.coroutines.*
import
java.io.FileDescriptor
import
java.io.IOException
import
java.net.Inet4Address
import
java.net.Inet6Address
import
java.net.InetAddress
import
java.util.concurrent.Executor
import
java.util.concurrent.Executors
...
...
@@ -73,21 +71,24 @@ sealed class DnsResolverCompat {
socket
.
closeQuietly
()
}
true
}
catch
(
_
:
IOException
)
{
false
}
catch
(
e
:
IOException
)
{
if
((
e
.
cause
as
?
ErrnoException
)
?.
errno
==
OsConstants
.
EPERM
)
checkConnectivity
(
network
,
addr
)
else
false
}
catch
(
_
:
ErrnoException
)
{
false
}
catch
(
e
:
ReflectiveOperationException
)
{
check
(
Build
.
VERSION
.
SDK_INT
<
23
)
printLog
(
e
)
val
addresses
=
Core
.
connectivity
.
getLinkProperties
(
network
)
?.
linkAddresses
true
==
when
(
addr
)
{
is
Inet4Address
->
addresses
?.
any
{
it
.
address
is
Inet4Address
&&
!
it
.
address
.
isLinkLocalAddress
}
is
Inet6Address
->
addresses
?.
any
{
it
.
address
.
run
{
this
is
Inet6Address
&&
!
isLinkLocalAddress
&&
!
isIPv4CompatibleAddress
}
checkConnectivity
(
network
,
addr
)
}
private
fun
checkConnectivity
(
network
:
Network
,
addr
:
InetAddress
):
Boolean
{
return
Core
.
connectivity
.
getLinkProperties
(
network
)
?.
routes
?.
any
{
try
{
it
.
matches
(
addr
)
}
catch
(
e
:
RuntimeException
)
{
printLog
(
e
)
false
}
else
->
error
(
"Unknown address type"
)
}
}
==
true
}
override
fun
bindSocket
(
network
:
Network
,
socket
:
FileDescriptor
)
=
instance
.
bindSocket
(
network
,
socket
)
...
...
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