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
Hide 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 {
...
@@ -126,9 +126,9 @@ class ShadowVpnService extends VpnService {
val
records
=
lookup
.
run
()
val
records
=
lookup
.
run
()
for
(
r
<-
records
)
{
for
(
r
<-
records
)
{
addrType
match
{
addrType
match
{
case
org
.
xbill
.
DNS
.
Type
.
A
=>
case
Type
.
A
=>
return
Some
(
r
.
asInstanceOf
[
ARecord
].
getAddress
.
getHostAddress
)
return
Some
(
r
.
asInstanceOf
[
ARecord
].
getAddress
.
getHostAddress
)
case
org
.
xbill
.
DNS
.
Type
.
AAAA
=>
case
Type
.
AAAA
=>
return
Some
(
r
.
asInstanceOf
[
AAAARecord
].
getAddress
.
getHostAddress
)
return
Some
(
r
.
asInstanceOf
[
AAAARecord
].
getAddress
.
getHostAddress
)
}
}
}
}
...
@@ -192,6 +192,7 @@ class ShadowVpnService extends VpnService {
...
@@ -192,6 +192,7 @@ class ShadowVpnService extends VpnService {
appHost
=
host
appHost
=
host
resolved
=
true
resolved
=
true
}
}
case
None
=>
}
}
}
}
if
(!
resolved
)
{
if
(!
resolved
)
{
...
@@ -200,6 +201,7 @@ class ShadowVpnService extends VpnService {
...
@@ -200,6 +201,7 @@ class ShadowVpnService extends VpnService {
appHost
=
host
appHost
=
host
resolved
=
true
resolved
=
true
}
}
case
None
=>
}
}
}
}
}
else
{
}
else
{
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksService.scala
View file @
9855fcbb
...
@@ -66,6 +66,8 @@ import java.net.InetAddress
...
@@ -66,6 +66,8 @@ import java.net.InetAddress
import
java.net.UnknownHostException
import
java.net.UnknownHostException
import
org.apache.http.conn.util.InetAddressUtils
import
org.apache.http.conn.util.InetAddressUtils
import
scala.collection._
import
scala.collection._
import
org.xbill.DNS._
import
scala.Some
object
ShadowsocksService
{
object
ShadowsocksService
{
def
isServiceStarted
:
Boolean
=
{
def
isServiceStarted
:
Boolean
=
{
...
@@ -162,6 +164,23 @@ class ShadowsocksService extends Service {
...
@@ -162,6 +164,23 @@ class ShadowsocksService extends Service {
version
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
)
{
def
handleCommand
(
intent
:
Intent
)
{
if
(
intent
==
null
)
{
if
(
intent
==
null
)
{
stopSelf
()
stopSelf
()
...
@@ -198,28 +217,29 @@ class ShadowsocksService extends Service {
...
@@ -198,28 +217,29 @@ class ShadowsocksService extends Service {
def
run
()
{
def
run
()
{
handler
.
sendEmptyMessage
(
MSG_CONNECT_START
)
handler
.
sendEmptyMessage
(
MSG_CONNECT_START
)
var
resolved
:
Boolean
=
false
var
resolved
:
Boolean
=
false
if
(
appHost
!=
null
)
{
if
(!
InetAddressUtils
.
isIPv4Address
(
appHost
)
&&
!
InetAddressUtils
.
isIPv6Address
(
appHost
))
{
var
addr
:
InetAddress
=
null
if
(
Utils
.
isIPv6Support
)
{
val
isIPv6Support
:
Boolean
=
Utils
.
isIPv6Support
resolve
(
appHost
,
Type
.
AAAA
)
match
{
case
Some
(
host
)
=>
{
try
{
appHost
=
host
val
addrs
=
InetAddress
.
getAllByName
(
appHost
)
resolved
=
true
for
(
a
<-
addrs
)
{
if
(
isIPv6Support
&&
addr
==
null
&&
a
.
isInstanceOf
[
Inet6Address
])
{
addr
=
a
}
}
}
case
None
=>
if
(
addr
==
null
)
addr
=
addrs
(
0
)
}
catch
{
case
ignored
:
UnknownHostException
=>
{
addr
=
null
}
}
}
}
if
(
addr
!=
null
)
{
if
(!
resolved
)
{
appHost
=
addr
.
getHostAddress
resolve
(
appHost
,
Type
.
A
)
match
{
resolved
=
true
case
Some
(
host
)
=>
{
appHost
=
host
resolved
=
true
}
case
None
=>
}
}
}
}
else
{
resolved
=
true
}
}
Log
.
d
(
TAG
,
"IPTABLES: "
+
Utils
.
getIptables
)
Log
.
d
(
TAG
,
"IPTABLES: "
+
Utils
.
getIptables
)
hasRedirectSupport
=
Utils
.
getHasRedirectSupport
hasRedirectSupport
=
Utils
.
getHasRedirectSupport
if
(
resolved
&&
handleConnection
)
{
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