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
fb4ac8dc
Commit
fb4ac8dc
authored
Jul 09, 2020
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine PTR compat
parent
8f8847b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
core/src/main/java/com/github/shadowsocks/net/DnsResolverCompat.kt
...main/java/com/github/shadowsocks/net/DnsResolverCompat.kt
+7
-5
No files found.
core/src/main/java/com/github/shadowsocks/net/DnsResolverCompat.kt
View file @
fb4ac8dc
...
@@ -108,9 +108,9 @@ sealed class DnsResolverCompat {
...
@@ -108,9 +108,9 @@ sealed class DnsResolverCompat {
}
}
override
suspend
fun
resolve
(
network
:
Network
,
host
:
String
)
=
override
suspend
fun
resolve
(
network
:
Network
,
host
:
String
)
=
GlobalScope
.
async
(
unboundedIO
)
{
network
.
getAllByName
(
host
)
}.
await
()
withContext
(
unboundedIO
)
{
network
.
getAllByName
(
host
)
}
override
suspend
fun
resolveOnActiveNetwork
(
host
:
String
)
=
override
suspend
fun
resolveOnActiveNetwork
(
host
:
String
)
=
GlobalScope
.
async
(
unboundedIO
)
{
InetAddress
.
getAllByName
(
host
)
}.
await
()
withContext
(
unboundedIO
)
{
InetAddress
.
getAllByName
(
host
)
}
private
suspend
fun
resolveRaw
(
query
:
ByteArray
,
networkSpecified
:
Boolean
=
true
,
private
suspend
fun
resolveRaw
(
query
:
ByteArray
,
networkSpecified
:
Boolean
=
true
,
hostResolver
:
suspend
(
String
)
->
Array
<
InetAddress
>):
ByteArray
{
hostResolver
:
suspend
(
String
)
->
Array
<
InetAddress
>):
ByteArray
{
...
@@ -128,16 +128,18 @@ sealed class DnsResolverCompat {
...
@@ -128,16 +128,18 @@ sealed class DnsResolverCompat {
Type
.
A
->
false
Type
.
A
->
false
Type
.
AAAA
->
true
Type
.
AAAA
->
true
Type
.
PTR
->
{
Type
.
PTR
->
{
/
/ Android does not provide a PTR lookup API for Network prior to Android 10
/
* Android does not provide a PTR lookup API for Network prior to Android 10 */
if
(
networkSpecified
)
throw
IOException
(
UnsupportedOperationException
(
"Network unspecified"
))
if
(
networkSpecified
)
throw
IOException
(
UnsupportedOperationException
(
"Network unspecified"
))
val
ip
=
try
{
val
ip
=
try
{
ReverseMap
.
fromName
(
question
.
name
)
ReverseMap
.
fromName
(
question
.
name
)
}
catch
(
e
:
IOException
)
{
}
catch
(
e
:
IOException
)
{
throw
UnsupportedOperationException
(
e
)
// unrecognized PTR name
throw
UnsupportedOperationException
(
e
)
// unrecognized PTR name
}
}
val
hostname
=
Name
.
fromString
(
GlobalScope
.
async
(
unboundedIO
)
{
ip
.
hostName
}.
await
())
val
hostname
=
withContext
(
unboundedIO
)
{
ip
.
hostName
}.
let
{
hostname
->
if
(
hostname
==
ip
.
hostAddress
)
null
else
Name
.
fromString
(
"$hostname."
)
}
return
prepareDnsResponse
(
request
).
apply
{
return
prepareDnsResponse
(
request
).
apply
{
addRecord
(
PTRRecord
(
question
.
name
,
DClass
.
IN
,
TTL
,
hostname
),
Section
.
ANSWER
)
hostname
?.
let
{
addRecord
(
PTRRecord
(
question
.
name
,
DClass
.
IN
,
TTL
,
it
),
Section
.
ANSWER
)
}
}.
toWire
()
}.
toWire
()
}
}
else
->
throw
UnsupportedOperationException
(
"Unsupported query type $type"
)
else
->
throw
UnsupportedOperationException
(
"Unsupported query type $type"
)
...
...
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