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
bdf06c9c
Commit
bdf06c9c
authored
Apr 28, 2013
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add IPv6 support
parent
a2841483
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
6 deletions
+26
-6
src/com/github/shadowsocks/ShadowsocksService.java
src/com/github/shadowsocks/ShadowsocksService.java
+24
-5
src/com/github/shadowsocks/Utils.java
src/com/github/shadowsocks/Utils.java
+2
-1
No files found.
src/com/github/shadowsocks/ShadowsocksService.java
View file @
bdf06c9c
...
@@ -55,6 +55,7 @@ import android.os.PowerManager;
...
@@ -55,6 +55,7 @@ import android.os.PowerManager;
import
android.preference.PreferenceManager
;
import
android.preference.PreferenceManager
;
import
android.util.Log
;
import
android.util.Log
;
import
com.google.analytics.tracking.android.EasyTracker
;
import
com.google.analytics.tracking.android.EasyTracker
;
import
org.apache.http.conn.util.InetAddressUtils
;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.FileNotFoundException
;
import
java.io.FileNotFoundException
;
...
@@ -63,6 +64,7 @@ import java.io.IOException;
...
@@ -63,6 +64,7 @@ import java.io.IOException;
import
java.lang.ref.WeakReference
;
import
java.lang.ref.WeakReference
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
java.net.Inet6Address
;
import
java.net.InetAddress
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.net.UnknownHostException
;
import
java.util.HashSet
;
import
java.util.HashSet
;
...
@@ -285,11 +287,26 @@ public class ShadowsocksService extends Service {
...
@@ -285,11 +287,26 @@ public class ShadowsocksService extends Service {
boolean
resolved
=
false
;
boolean
resolved
=
false
;
if
(
appHost
!=
null
)
{
if
(
appHost
!=
null
)
{
boolean
isIPv6Support
=
Utils
.
isIPv6Support
();
InetAddress
addr
=
null
;
InetAddress
addr
=
null
;
if
(
isIPv6Support
)
{
try
{
addr
=
Inet6Address
.
getByName
(
appHost
);
}
catch
(
UnknownHostException
ignored
)
{
addr
=
null
;
}
}
if
(
addr
==
null
)
{
try
{
try
{
addr
=
InetAddress
.
getByName
(
appHost
);
addr
=
InetAddress
.
getByName
(
appHost
);
}
catch
(
UnknownHostException
ignored
)
{
}
catch
(
UnknownHostException
ignored
)
{
addr
=
null
;
}
}
}
if
(
addr
!=
null
)
{
if
(
addr
!=
null
)
{
appHost
=
addr
.
getHostAddress
();
appHost
=
addr
.
getHostAddress
();
resolved
=
true
;
resolved
=
true
;
...
@@ -540,7 +557,9 @@ public class ShadowsocksService extends Service {
...
@@ -540,7 +557,9 @@ public class ShadowsocksService extends Service {
String
cmd_bypass
=
Utils
.
getIptables
()
+
CMD_IPTABLES_RETURN
;
String
cmd_bypass
=
Utils
.
getIptables
()
+
CMD_IPTABLES_RETURN
;
if
(!
InetAddressUtils
.
isIPv6Address
(
appHost
.
toUpperCase
()))
{
init_sb
.
append
(
cmd_bypass
.
replace
(
"-d 0.0.0.0"
,
"-d "
+
appHost
));
init_sb
.
append
(
cmd_bypass
.
replace
(
"-d 0.0.0.0"
,
"-d "
+
appHost
));
}
init_sb
.
append
(
cmd_bypass
.
replace
(
"0.0.0.0"
,
"127.0.0.1"
));
init_sb
.
append
(
cmd_bypass
.
replace
(
"0.0.0.0"
,
"127.0.0.1"
));
if
(!
isDNSProxy
)
{
if
(!
isDNSProxy
)
{
init_sb
.
append
(
cmd_bypass
.
replace
(
"-d 0.0.0.0"
,
"--dport "
+
53
));
init_sb
.
append
(
cmd_bypass
.
replace
(
"-d 0.0.0.0"
,
"--dport "
+
53
));
...
...
src/com/github/shadowsocks/Utils.java
View file @
bdf06c9c
...
@@ -85,10 +85,11 @@ public class Utils {
...
@@ -85,10 +85,11 @@ public class Utils {
for
(
NetworkInterface
intf
:
interfaces
)
{
for
(
NetworkInterface
intf
:
interfaces
)
{
List
<
InetAddress
>
addrs
=
Collections
.
list
(
intf
.
getInetAddresses
());
List
<
InetAddress
>
addrs
=
Collections
.
list
(
intf
.
getInetAddresses
());
for
(
InetAddress
addr
:
addrs
)
{
for
(
InetAddress
addr
:
addrs
)
{
if
(!
addr
.
isLoopbackAddress
())
{
if
(!
addr
.
isLoopbackAddress
()
&&
!
addr
.
isLinkLocalAddress
()
)
{
String
sAddr
=
addr
.
getHostAddress
().
toUpperCase
();
String
sAddr
=
addr
.
getHostAddress
().
toUpperCase
();
boolean
isIPv6
=
InetAddressUtils
.
isIPv6Address
(
sAddr
);
boolean
isIPv6
=
InetAddressUtils
.
isIPv6Address
(
sAddr
);
if
(
isIPv6
)
{
if
(
isIPv6
)
{
Log
.
d
(
TAG
,
"IPv6 address detected"
);
return
true
;
return
true
;
}
}
}
}
...
...
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