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
Show 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,7 +334,6 @@ class Shadowsocks
...
@@ -334,7 +334,6 @@ class Shadowsocks
Console
.
runCommand
(
ab
.
toArray
)
Console
.
runCommand
(
ab
.
toArray
)
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
ab
.
clear
()
ab
.
clear
()
ab
.
append
(
"kill -9 `cat /data/data/com.github.shadowsocks/redsocks.pid`"
)
ab
.
append
(
"kill -9 `cat /data/data/com.github.shadowsocks/redsocks.pid`"
)
ab
.
append
(
"rm /data/data/com.github.shadowsocks/redsocks.conf"
)
ab
.
append
(
"rm /data/data/com.github.shadowsocks/redsocks.conf"
)
...
@@ -342,7 +341,6 @@ class Shadowsocks
...
@@ -342,7 +341,6 @@ class Shadowsocks
Console
.
runRootCommand
(
ab
.
toArray
)
Console
.
runRootCommand
(
ab
.
toArray
)
}
}
}
private
def
getVersionName
:
String
=
{
private
def
getVersionName
:
String
=
{
var
version
:
String
=
null
var
version
:
String
=
null
...
@@ -497,7 +495,7 @@ class Shadowsocks
...
@@ -497,7 +495,7 @@ class Shadowsocks
// Bind to the service
// Bind to the service
spawn
{
spawn
{
val
isRoot
=
Build
.
VERSION
.
SDK_INT
!=
Build
.
VERSION_CODES
.
LOLLIPOP
&&
Console
.
isRoot
val
isRoot
=
Console
.
isRoot
handler
.
post
(
new
Runnable
{
handler
.
post
(
new
Runnable
{
override
def
run
()
{
override
def
run
()
{
status
.
edit
.
putBoolean
(
Key
.
isRoot
,
isRoot
).
commit
()
status
.
edit
.
putBoolean
(
Key
.
isRoot
,
isRoot
).
commit
()
...
@@ -767,7 +765,7 @@ class Shadowsocks
...
@@ -767,7 +765,7 @@ class Shadowsocks
if
(
pref
!=
null
)
{
if
(
pref
!=
null
)
{
if
(
Seq
(
Key
.
isGlobalProxy
,
Key
.
proxyedApps
)
if
(
Seq
(
Key
.
isGlobalProxy
,
Key
.
proxyedApps
)
.
contains
(
name
))
{
.
contains
(
name
))
{
pref
.
setEnabled
(
enabled
&&
(!
isVpnEnabled
||
Build
.
VERSION
.
SDK_INT
==
Build
.
VERSION_CODES
.
LOLLIPOP
)
)
pref
.
setEnabled
(
enabled
&&
!
isVpnEnabled
)
}
else
{
}
else
{
pref
.
setEnabled
(
enabled
)
pref
.
setEnabled
(
enabled
)
}
}
...
@@ -875,8 +873,7 @@ class Shadowsocks
...
@@ -875,8 +873,7 @@ class Shadowsocks
def
isVpnEnabled
:
Boolean
=
{
def
isVpnEnabled
:
Boolean
=
{
if
(
vpnEnabled
<
0
)
{
if
(
vpnEnabled
<
0
)
{
vpnEnabled
=
if
(
Build
.
VERSION
.
SDK_INT
==
Build
.
VERSION_CODES
.
LOLLIPOP
vpnEnabled
=
if
(!
status
.
getBoolean
(
Key
.
isRoot
,
false
))
{
||
!
status
.
getBoolean
(
Key
.
isRoot
,
false
))
{
1
1
}
else
{
}
else
{
0
0
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala
View file @
b7c3c7d2
...
@@ -63,7 +63,6 @@ class ShadowsocksNatService extends Service with BaseService {
...
@@ -63,7 +63,6 @@ class ShadowsocksNatService extends Service with BaseService {
val
TAG
=
"ShadowsocksNatService"
val
TAG
=
"ShadowsocksNatService"
val
CMD_IPTABLES_RETURN
=
" -t nat -A OUTPUT -p tcp -d 0.0.0.0 -j RETURN"
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 "
+
val
CMD_IPTABLES_DNAT_ADD_SOCKS
=
" -t nat -A OUTPUT -p tcp "
+
"-j DNAT --to-destination 127.0.0.1:8123"
"-j DNAT --to-destination 127.0.0.1:8123"
val
DNS_PORT
=
8153
val
DNS_PORT
=
8153
...
@@ -75,7 +74,6 @@ class ShadowsocksNatService extends Service with BaseService {
...
@@ -75,7 +74,6 @@ class ShadowsocksNatService extends Service with BaseService {
var
receiver
:
BroadcastReceiver
=
null
var
receiver
:
BroadcastReceiver
=
null
var
notificationManager
:
NotificationManager
=
null
var
notificationManager
:
NotificationManager
=
null
var
config
:
Config
=
null
var
config
:
Config
=
null
var
hasRedirectSupport
=
false
var
apps
:
Array
[
ProxiedApp
]
=
null
var
apps
:
Array
[
ProxiedApp
]
=
null
val
myUid
=
Process
.
myUid
()
val
myUid
=
Process
.
myUid
()
...
@@ -293,22 +291,10 @@ class ShadowsocksNatService extends Service with BaseService {
...
@@ -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
(
"0.0.0.0"
,
"127.0.0.1"
))
init_sb
.
append
(
cmd_bypass
.
replace
(
"-d 0.0.0.0"
,
"-m owner --uid-owner "
+
myUid
))
init_sb
.
append
(
cmd_bypass
.
replace
(
"-d 0.0.0.0"
,
"-m owner --uid-owner "
+
myUid
))
if
(
hasRedirectSupport
)
{
init_sb
.
append
(
Utils
.
getIptables
init_sb
+
" -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to-destination 127.0.0.1:"
+
DNS_PORT
)
.
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
)
}
if
(
config
.
isGlobalProxy
||
config
.
isBypassApps
)
{
if
(
config
.
isGlobalProxy
||
config
.
isBypassApps
)
{
http_sb
.
append
(
if
(
hasRedirectSupport
)
{
http_sb
.
append
(
Utils
.
getIptables
+
CMD_IPTABLES_DNAT_ADD_SOCKS
)
Utils
.
getIptables
+
CMD_IPTABLES_REDIRECT_ADD_SOCKS
}
else
{
Utils
.
getIptables
+
CMD_IPTABLES_DNAT_ADD_SOCKS
})
}
}
if
(!
config
.
isGlobalProxy
)
{
if
(!
config
.
isGlobalProxy
)
{
if
(
apps
==
null
||
apps
.
length
<=
0
)
{
if
(
apps
==
null
||
apps
.
length
<=
0
)
{
...
@@ -322,11 +308,7 @@ class ShadowsocksNatService extends Service with BaseService {
...
@@ -322,11 +308,7 @@ class ShadowsocksNatService extends Service with BaseService {
}
}
for
(
uid
<-
uidSet
)
{
for
(
uid
<-
uidSet
)
{
if
(!
config
.
isBypassApps
)
{
if
(!
config
.
isBypassApps
)
{
http_sb
.
append
((
if
(
hasRedirectSupport
)
{
http_sb
.
append
((
Utils
.
getIptables
+
CMD_IPTABLES_DNAT_ADD_SOCKS
).
replace
(
"-t nat"
,
"-t nat -m owner --uid-owner "
+
uid
))
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
))
}
else
{
}
else
{
init_sb
.
append
(
cmd_bypass
.
replace
(
"-d 0.0.0.0"
,
"-m owner --uid-owner "
+
uid
))
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 {
...
@@ -430,8 +412,6 @@ class ShadowsocksNatService extends Service with BaseService {
resolved
=
true
resolved
=
true
}
}
hasRedirectSupport
=
Utils
.
getHasRedirectSupport
if
(
resolved
&&
handleConnection
)
{
if
(
resolved
&&
handleConnection
)
{
notifyForegroundAlert
(
getString
(
R
.
string
.
forward_success
),
notifyForegroundAlert
(
getString
(
R
.
string
.
forward_success
),
getString
(
R
.
string
.
service_running
).
format
(
config
.
profileName
))
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