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
9855fcbb
Commit
9855fcbb
authored
May 06, 2013
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix warnings by scalac
parent
a7dab5cf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
19 deletions
+41
-19
src/main/scala/com/github/shadowsocks/ShadowVpnService.scala
src/main/scala/com/github/shadowsocks/ShadowVpnService.scala
+4
-2
src/main/scala/com/github/shadowsocks/ShadowsocksService.scala
...ain/scala/com/github/shadowsocks/ShadowsocksService.scala
+37
-17
No files found.
src/main/scala/com/github/shadowsocks/ShadowVpnService.scala
View file @
9855fcbb
...
...
@@ -126,9 +126,9 @@ class ShadowVpnService extends VpnService {
val
records
=
lookup
.
run
()
for
(
r
<-
records
)
{
addrType
match
{
case
org
.
xbill
.
DNS
.
Type
.
A
=>
case
Type
.
A
=>
return
Some
(
r
.
asInstanceOf
[
ARecord
].
getAddress
.
getHostAddress
)
case
org
.
xbill
.
DNS
.
Type
.
AAAA
=>
case
Type
.
AAAA
=>
return
Some
(
r
.
asInstanceOf
[
AAAARecord
].
getAddress
.
getHostAddress
)
}
}
...
...
@@ -192,6 +192,7 @@ class ShadowVpnService extends VpnService {
appHost
=
host
resolved
=
true
}
case
None
=>
}
}
if
(!
resolved
)
{
...
...
@@ -200,6 +201,7 @@ class ShadowVpnService extends VpnService {
appHost
=
host
resolved
=
true
}
case
None
=>
}
}
}
else
{
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksService.scala
View file @
9855fcbb
...
...
@@ -66,6 +66,8 @@ import java.net.InetAddress
import
java.net.UnknownHostException
import
org.apache.http.conn.util.InetAddressUtils
import
scala.collection._
import
org.xbill.DNS._
import
scala.Some
object
ShadowsocksService
{
def
isServiceStarted
:
Boolean
=
{
...
...
@@ -162,6 +164,23 @@ class ShadowsocksService extends Service {
version
}
def
resolve
(
host
:
String
,
addrType
:
Int
)
:
Option
[
String
]
=
{
val
lookup
=
new
Lookup
(
host
,
addrType
)
val
resolver
=
new
SimpleResolver
(
"8.8.8.8"
)
resolver
.
setTimeout
(
5
)
lookup
.
setResolver
(
resolver
)
val
records
=
lookup
.
run
()
for
(
r
<-
records
)
{
addrType
match
{
case
Type
.
A
=>
return
Some
(
r
.
asInstanceOf
[
ARecord
].
getAddress
.
getHostAddress
)
case
Type
.
AAAA
=>
return
Some
(
r
.
asInstanceOf
[
AAAARecord
].
getAddress
.
getHostAddress
)
}
}
None
}
def
handleCommand
(
intent
:
Intent
)
{
if
(
intent
==
null
)
{
stopSelf
()
...
...
@@ -198,28 +217,29 @@ class ShadowsocksService extends Service {
def
run
()
{
handler
.
sendEmptyMessage
(
MSG_CONNECT_START
)
var
resolved
:
Boolean
=
false
if
(
appHost
!=
null
)
{
var
addr
:
InetAddress
=
null
val
isIPv6Support
:
Boolean
=
Utils
.
isIPv6Support
try
{
val
addrs
=
InetAddress
.
getAllByName
(
appHost
)
for
(
a
<-
addrs
)
{
if
(
isIPv6Support
&&
addr
==
null
&&
a
.
isInstanceOf
[
Inet6Address
])
{
addr
=
a
}
if
(!
InetAddressUtils
.
isIPv4Address
(
appHost
)
&&
!
InetAddressUtils
.
isIPv6Address
(
appHost
))
{
if
(
Utils
.
isIPv6Support
)
{
resolve
(
appHost
,
Type
.
AAAA
)
match
{
case
Some
(
host
)
=>
{
appHost
=
host
resolved
=
true
}
if
(
addr
==
null
)
addr
=
addrs
(
0
)
}
catch
{
case
ignored
:
UnknownHostException
=>
{
addr
=
null
case
None
=>
}
}
if
(
addr
!=
null
)
{
appHost
=
addr
.
getHostAddress
if
(!
resolved
)
{
resolve
(
appHost
,
Type
.
A
)
match
{
case
Some
(
host
)
=>
{
appHost
=
host
resolved
=
true
}
case
None
=>
}
}
}
else
{
resolved
=
true
}
Log
.
d
(
TAG
,
"IPTABLES: "
+
Utils
.
getIptables
)
hasRedirectSupport
=
Utils
.
getHasRedirectSupport
if
(
resolved
&&
handleConnection
)
{
...
...
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