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
b7c3c7d2
Commit
b7c3c7d2
authored
Nov 17, 2014
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enable NAT mode again
parent
897b222a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
35 deletions
+12
-35
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+8
-11
src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala
.../scala/com/github/shadowsocks/ShadowsocksNatService.scala
+4
-24
No files found.
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
View file @
b7c3c7d2
...
...
@@ -334,14 +334,12 @@ class Shadowsocks
Console
.
runCommand
(
ab
.
toArray
)
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
ab
.
clear
()
ab
.
append
(
"kill -9 `cat /data/data/com.github.shadowsocks/redsocks.pid`"
)
ab
.
append
(
"rm /data/data/com.github.shadowsocks/redsocks.conf"
)
ab
.
append
(
Utils
.
getIptables
+
" -t nat -F OUTPUT"
)
ab
.
clear
()
ab
.
append
(
"kill -9 `cat /data/data/com.github.shadowsocks/redsocks.pid`"
)
ab
.
append
(
"rm /data/data/com.github.shadowsocks/redsocks.conf"
)
ab
.
append
(
Utils
.
getIptables
+
" -t nat -F OUTPUT"
)
Console
.
runRootCommand
(
ab
.
toArray
)
}
Console
.
runRootCommand
(
ab
.
toArray
)
}
private
def
getVersionName
:
String
=
{
...
...
@@ -497,7 +495,7 @@ class Shadowsocks
// Bind to the service
spawn
{
val
isRoot
=
Build
.
VERSION
.
SDK_INT
!=
Build
.
VERSION_CODES
.
LOLLIPOP
&&
Console
.
isRoot
val
isRoot
=
Console
.
isRoot
handler
.
post
(
new
Runnable
{
override
def
run
()
{
status
.
edit
.
putBoolean
(
Key
.
isRoot
,
isRoot
).
commit
()
...
...
@@ -767,7 +765,7 @@ class Shadowsocks
if
(
pref
!=
null
)
{
if
(
Seq
(
Key
.
isGlobalProxy
,
Key
.
proxyedApps
)
.
contains
(
name
))
{
pref
.
setEnabled
(
enabled
&&
(!
isVpnEnabled
||
Build
.
VERSION
.
SDK_INT
==
Build
.
VERSION_CODES
.
LOLLIPOP
)
)
pref
.
setEnabled
(
enabled
&&
!
isVpnEnabled
)
}
else
{
pref
.
setEnabled
(
enabled
)
}
...
...
@@ -875,8 +873,7 @@ class Shadowsocks
def
isVpnEnabled
:
Boolean
=
{
if
(
vpnEnabled
<
0
)
{
vpnEnabled
=
if
(
Build
.
VERSION
.
SDK_INT
==
Build
.
VERSION_CODES
.
LOLLIPOP
||
!
status
.
getBoolean
(
Key
.
isRoot
,
false
))
{
vpnEnabled
=
if
(!
status
.
getBoolean
(
Key
.
isRoot
,
false
))
{
1
}
else
{
0
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala
View file @
b7c3c7d2
...
...
@@ -63,7 +63,6 @@ class ShadowsocksNatService extends Service with BaseService {
val
TAG
=
"ShadowsocksNatService"
val
CMD_IPTABLES_RETURN
=
" -t nat -A OUTPUT -p tcp -d 0.0.0.0 -j RETURN"
val
CMD_IPTABLES_REDIRECT_ADD_SOCKS
=
" -t nat -A OUTPUT -p tcp "
+
"-j REDIRECT --to 8123"
val
CMD_IPTABLES_DNAT_ADD_SOCKS
=
" -t nat -A OUTPUT -p tcp "
+
"-j DNAT --to-destination 127.0.0.1:8123"
val
DNS_PORT
=
8153
...
...
@@ -75,7 +74,6 @@ class ShadowsocksNatService extends Service with BaseService {
var
receiver
:
BroadcastReceiver
=
null
var
notificationManager
:
NotificationManager
=
null
var
config
:
Config
=
null
var
hasRedirectSupport
=
false
var
apps
:
Array
[
ProxiedApp
]
=
null
val
myUid
=
Process
.
myUid
()
...
...
@@ -293,22 +291,10 @@ class ShadowsocksNatService extends Service with BaseService {
init_sb
.
append
(
cmd_bypass
.
replace
(
"0.0.0.0"
,
"127.0.0.1"
))
init_sb
.
append
(
cmd_bypass
.
replace
(
"-d 0.0.0.0"
,
"-m owner --uid-owner "
+
myUid
))
if
(
hasRedirectSupport
)
{
init_sb
.
append
(
Utils
.
getIptables
+
" -t nat -A OUTPUT -p udp --dport 53 -j REDIRECT --to "
+
DNS_PORT
)
}
else
{
init_sb
.
append
(
Utils
.
getIptables
+
" -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to-destination 127.0.0.1:"
+
DNS_PORT
)
}
init_sb
.
append
(
Utils
.
getIptables
+
" -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to-destination 127.0.0.1:"
+
DNS_PORT
)
if
(
config
.
isGlobalProxy
||
config
.
isBypassApps
)
{
http_sb
.
append
(
if
(
hasRedirectSupport
)
{
Utils
.
getIptables
+
CMD_IPTABLES_REDIRECT_ADD_SOCKS
}
else
{
Utils
.
getIptables
+
CMD_IPTABLES_DNAT_ADD_SOCKS
})
http_sb
.
append
(
Utils
.
getIptables
+
CMD_IPTABLES_DNAT_ADD_SOCKS
)
}
if
(!
config
.
isGlobalProxy
)
{
if
(
apps
==
null
||
apps
.
length
<=
0
)
{
...
...
@@ -322,11 +308,7 @@ class ShadowsocksNatService extends Service with BaseService {
}
for
(
uid
<-
uidSet
)
{
if
(!
config
.
isBypassApps
)
{
http_sb
.
append
((
if
(
hasRedirectSupport
)
{
Utils
.
getIptables
+
CMD_IPTABLES_REDIRECT_ADD_SOCKS
}
else
{
Utils
.
getIptables
+
CMD_IPTABLES_DNAT_ADD_SOCKS
}).
replace
(
"-t nat"
,
"-t nat -m owner --uid-owner "
+
uid
))
http_sb
.
append
((
Utils
.
getIptables
+
CMD_IPTABLES_DNAT_ADD_SOCKS
).
replace
(
"-t nat"
,
"-t nat -m owner --uid-owner "
+
uid
))
}
else
{
init_sb
.
append
(
cmd_bypass
.
replace
(
"-d 0.0.0.0"
,
"-m owner --uid-owner "
+
uid
))
}
...
...
@@ -430,8 +412,6 @@ class ShadowsocksNatService extends Service with BaseService {
resolved
=
true
}
hasRedirectSupport
=
Utils
.
getHasRedirectSupport
if
(
resolved
&&
handleConnection
)
{
notifyForegroundAlert
(
getString
(
R
.
string
.
forward_success
),
getString
(
R
.
string
.
service_running
).
format
(
config
.
profileName
))
...
...
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