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
16672a1d
Commit
16672a1d
authored
May 22, 2018
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove TCP resolving of hostnames
parent
daa9d9f8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
2 additions
and
79 deletions
+2
-79
mobile/build.gradle
mobile/build.gradle
+0
-1
mobile/src/main/java/com/github/shadowsocks/bg/BaseService.kt
...le/src/main/java/com/github/shadowsocks/bg/BaseService.kt
+2
-6
mobile/src/main/java/com/github/shadowsocks/bg/Dns.kt
mobile/src/main/java/com/github/shadowsocks/bg/Dns.kt
+0
-72
No files found.
mobile/build.gradle
View file @
16672a1d
...
@@ -74,7 +74,6 @@ dependencies {
...
@@ -74,7 +74,6 @@ dependencies {
implementation
'com.squareup.okhttp3:okhttp:3.10.0'
implementation
'com.squareup.okhttp3:okhttp:3.10.0'
implementation
"com.takisoft.fix:preference-v7-simplemenu:$takisoftFixVersion"
implementation
"com.takisoft.fix:preference-v7-simplemenu:$takisoftFixVersion"
implementation
'com.twofortyfouram:android-plugin-api-for-locale:1.0.2'
implementation
'com.twofortyfouram:android-plugin-api-for-locale:1.0.2'
implementation
'dnsjava:dnsjava:2.1.8'
implementation
'eu.chainfire:libsuperuser:1.0.0.201704021214'
implementation
'eu.chainfire:libsuperuser:1.0.0.201704021214'
implementation
'net.glxn.qrgen:android:2.0'
implementation
'net.glxn.qrgen:android:2.0'
implementation
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
implementation
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
...
...
mobile/src/main/java/com/github/shadowsocks/bg/BaseService.kt
View file @
16672a1d
...
@@ -50,7 +50,7 @@ import okhttp3.Request
...
@@ -50,7 +50,7 @@ import okhttp3.Request
import
org.json.JSONObject
import
org.json.JSONObject
import
java.io.File
import
java.io.File
import
java.io.IOException
import
java.io.IOException
import
java.net.
UnknownHostException
import
java.net.
*
import
java.security.MessageDigest
import
java.security.MessageDigest
import
java.util.*
import
java.util.*
import
java.util.concurrent.TimeUnit
import
java.util.concurrent.TimeUnit
...
@@ -364,10 +364,6 @@ object BaseService {
...
@@ -364,10 +364,6 @@ object BaseService {
try
{
try
{
if
(
profile
.
host
==
"198.199.101.152"
)
{
if
(
profile
.
host
==
"198.199.101.152"
)
{
val
client
=
OkHttpClient
.
Builder
()
val
client
=
OkHttpClient
.
Builder
()
.
dns
{
listOf
((
Dns
.
resolve
(
it
,
false
)
?:
throw
UnknownHostException
())
.
parseNumericAddress
())
}
.
connectTimeout
(
10
,
TimeUnit
.
SECONDS
)
.
connectTimeout
(
10
,
TimeUnit
.
SECONDS
)
.
writeTimeout
(
10
,
TimeUnit
.
SECONDS
)
.
writeTimeout
(
10
,
TimeUnit
.
SECONDS
)
.
readTimeout
(
30
,
TimeUnit
.
SECONDS
)
.
readTimeout
(
30
,
TimeUnit
.
SECONDS
)
...
@@ -402,7 +398,7 @@ object BaseService {
...
@@ -402,7 +398,7 @@ object BaseService {
killProcesses
()
killProcesses
()
if
(!
profile
.
host
.
isNumericAddress
())
if
(!
profile
.
host
.
isNumericAddress
())
profile
.
host
=
Dns
.
resolve
(
profile
.
host
,
true
)
?:
throw
UnknownHostException
()
profile
.
host
=
InetAddress
.
getByName
(
profile
.
host
).
hostAddress
?:
throw
UnknownHostException
()
startNativeProcesses
()
startNativeProcesses
()
...
...
mobile/src/main/java/com/github/shadowsocks/bg/Dns.kt
deleted
100644 → 0
View file @
daa9d9f8
/*******************************************************************************
* *
* Copyright (C) 2017 by Max Lv <max.c.lv@gmail.com> *
* Copyright (C) 2017 by Mygod Studio <contact-shadowsocks-android@mygod.be> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
*******************************************************************************/
package
com.github.shadowsocks.bg
import
android.util.Log
import
com.github.shadowsocks.App.Companion.app
import
com.github.shadowsocks.BuildConfig
import
org.xbill.DNS.*
import
java.io.IOException
import
java.net.*
object
Dns
{
private
const
val
TAG
=
"Dns"
private
val
hasIPv6Support
get
()
=
try
{
val
result
=
NetworkInterface
.
getNetworkInterfaces
().
asSequence
().
flatMap
{
it
.
inetAddresses
.
asSequence
()
}
.
any
{
it
is
Inet6Address
&&
!
it
.
isLoopbackAddress
&&
!
it
.
isLinkLocalAddress
}
if
(
result
&&
BuildConfig
.
DEBUG
)
Log
.
d
(
TAG
,
"IPv6 address detected"
)
result
}
catch
(
ex
:
SocketException
)
{
Log
.
e
(
TAG
,
"Failed to get interfaces' addresses."
,
ex
)
app
.
track
(
ex
)
false
}
private
fun
resolve
(
host
:
String
,
addrType
:
Int
):
String
?
{
try
{
val
lookup
=
Lookup
(
host
,
addrType
)
val
resolver
=
SimpleResolver
(
"208.67.220.220"
)
resolver
.
setTCP
(
true
)
resolver
.
setPort
(
443
)
resolver
.
setTimeout
(
5
)
lookup
.
setResolver
(
resolver
)
val
records
=
(
lookup
.
run
()
?:
return
null
).
toMutableList
()
records
.
shuffle
()
for
(
r
in
records
)
{
when
(
addrType
)
{
Type
.
A
->
return
(
r
as
ARecord
).
address
.
hostAddress
Type
.
AAAA
->
return
(
r
as
AAAARecord
).
address
.
hostAddress
}
}
}
catch
(
_
:
IOException
)
{
}
return
null
}
private
fun
resolve
(
host
:
String
):
String
?
=
try
{
InetAddress
.
getByName
(
host
).
hostAddress
}
catch
(
_
:
UnknownHostException
)
{
null
}
fun
resolve
(
host
:
String
,
enableIPv6
:
Boolean
):
String
?
=
(
if
(
enableIPv6
&&
hasIPv6Support
)
resolve
(
host
,
Type
.
AAAA
)
else
null
)
?:
resolve
(
host
,
Type
.
A
)
?:
resolve
(
host
)
}
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