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
39c70f65
Commit
39c70f65
authored
Dec 15, 2012
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix redsocks conf
parent
2e0a6fc6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
71 deletions
+68
-71
assets/pdnsd.conf
assets/pdnsd.conf
+1
-12
src/com/github/shadowsocks/Shadowsocks.java
src/com/github/shadowsocks/Shadowsocks.java
+2
-2
src/com/github/shadowsocks/ShadowsocksService.java
src/com/github/shadowsocks/ShadowsocksService.java
+65
-57
No files found.
assets/pdnsd.conf
View file @
39c70f65
...
...
@@ -3,9 +3,7 @@ global {
cache_dir
=
"/data/data/com.github.shadowsocks"
;
server_ip
=
127
.
0
.
0
.
1
;
server_port
=
8053
;
status_ctl
=
on
;
paranoid
=
on
;
query_method
=
tcp_only
;
query_method
=
tcp_only
;
min_ttl
=
15
m
;
max_ttl
=
1
w
;
timeout
=
10
;
...
...
@@ -15,7 +13,6 @@ global {
server
{
label
=
"root-servers"
;
root_server
=
on
;
ip
=
8
.
8
.
8
.
8
,
8
.
8
.
4
.
4
...
...
@@ -24,14 +21,6 @@ server {
;
timeout
=
5
;
uptest
=
query
;
interval
=
30
m
; //
Test
every
half
hour
.
ping_timeout
=
300
; //
30
seconds
.
purge_cache
=
off
;
exclude
= .
localdomain
;
policy
=
included
;
preset
=
off
;
}
rr
{
...
...
src/com/github/shadowsocks/Shadowsocks.java
View file @
39c70f65
...
...
@@ -409,8 +409,8 @@ public class Shadowsocks extends PreferenceActivity implements
getString
(
R
.
string
.
port_summary
)));
if
(!
settings
.
getString
(
"remotePort"
,
""
).
equals
(
""
))
p
ortText
.
setSummary
(
settings
.
getString
(
"remotePort"
,
getString
(
R
.
string
.
port_summary
)));
remoteP
ortText
.
setSummary
(
settings
.
getString
(
"remotePort"
,
getString
(
R
.
string
.
remote_
port_summary
)));
if
(!
settings
.
getString
(
"proxy"
,
""
).
equals
(
""
))
proxyText
.
setSummary
(
settings
.
getString
(
"proxy"
,
...
...
src/com/github/shadowsocks/ShadowsocksService.java
View file @
39c70f65
...
...
@@ -64,65 +64,42 @@ import java.util.HashSet;
public
class
ShadowsocksService
extends
Service
{
private
Notification
notification
;
private
NotificationManager
notificationManager
;
private
PendingIntent
pendIntent
;
private
PowerManager
.
WakeLock
mWakeLock
;
public
static
final
String
BASE
=
"/data/data/com.github.shadowsocks/"
;
private
static
final
int
MSG_CONNECT_START
=
0
;
private
static
final
int
MSG_CONNECT_FINISH
=
1
;
private
static
final
int
MSG_CONNECT_SUCCESS
=
2
;
private
static
final
int
MSG_CONNECT_FAIL
=
3
;
private
static
final
int
MSG_HOST_CHANGE
=
4
;
private
static
final
int
MSG_STOP_SELF
=
5
;
final
static
String
REDSOCKS_CONF
=
"base {"
+
" log_debug = off;"
+
" log_info = off;"
+
" log = stderr;"
+
" daemon = on;"
+
" redirector = iptables;"
+
"}"
+
"redsocks {"
+
" local_ip = 127.0.0.1;"
+
" local_port = 8123;"
+
" ip = 127.0.0.1;"
+
" port = %d;"
+
" type = socks5;"
+
"}"
;
final
static
String
CMD_IPTABLES_RETURN
=
" -t nat -A OUTPUT -p tcp -d 0.0.0.0 -j RETURN\n"
;
final
static
String
CMD_IPTABLES_REDIRECT_ADD_HTTP
=
" -t nat -A OUTPUT -p tcp "
+
"--dport 80 -j REDIRECT --to 8123\n"
;
final
static
String
CMD_IPTABLES_REDIRECT_ADD_HTTPS
=
" -t nat -A OUTPUT -p tcp "
+
"--dport 443 -j REDIRECT --to 8124\n"
;
final
static
String
CMD_IPTABLES_DNAT_ADD_HTTP
=
" -t nat -A OUTPUT -p tcp "
+
"--dport 80 -j DNAT --to-destination 127.0.0.1:8123\n"
;
final
static
String
CMD_IPTABLES_DNAT_ADD_HTTPS
=
" -t nat -A OUTPUT -p tcp "
+
"--dport 443 -j DNAT --to-destination 127.0.0.1:8124\n"
;
private
static
final
int
MSG_CONNECT_START
=
0
;
private
static
final
int
MSG_CONNECT_FINISH
=
1
;
private
static
final
int
MSG_CONNECT_SUCCESS
=
2
;
private
static
final
int
MSG_CONNECT_FAIL
=
3
;
private
static
final
int
MSG_HOST_CHANGE
=
4
;
private
static
final
int
MSG_STOP_SELF
=
5
;
private
static
final
String
TAG
=
"ShadowsocksService"
;
private
static
final
String
DEFAULT_HOST
=
"74.125.128.18"
;
private
final
static
int
DNS_PORT
=
8053
;
private
Process
httpProcess
=
null
;
private
DataOutputStream
httpOS
=
null
;
private
String
appHost
;
private
int
remotePort
;
private
int
port
;
private
String
sitekey
;
private
SharedPreferences
settings
=
null
;
private
boolean
hasRedirectSupport
=
true
;
private
boolean
isGlobalProxy
=
false
;
private
boolean
isGFWList
=
false
;
private
boolean
isBypassApps
=
false
;
private
ProxyedApp
apps
[];
private
static
final
Class
<?>[]
mStartForegroundSignature
=
new
Class
[]{
int
.
class
,
Notification
.
class
};
private
static
final
Class
<?>[]
mStopForegroundSignature
=
new
Class
[]{
boolean
.
class
};
private
static
final
Class
<?>[]
mSetForegroundSignature
=
new
Class
[]{
boolean
.
class
};
private
Method
mSetForeground
;
private
Method
mStartForeground
;
private
Method
mStopForeground
;
private
Object
[]
mSetForegroundArgs
=
new
Object
[
1
];
private
Object
[]
mStartForegroundArgs
=
new
Object
[
2
];
private
Object
[]
mStopForegroundArgs
=
new
Object
[
1
];
/*
* This is a hack see
* http://www.mail-archive.com/android-developers@googlegroups
...
...
@@ -132,20 +109,6 @@ public class ShadowsocksService extends Service {
* reference will hopefully vanish
*/
private
static
WeakReference
<
ShadowsocksService
>
sRunningInstance
=
null
;
public
static
boolean
isServiceStarted
()
{
final
boolean
isServiceStarted
;
if
(
sRunningInstance
==
null
)
{
isServiceStarted
=
false
;
}
else
if
(
sRunningInstance
.
get
()
==
null
)
{
isServiceStarted
=
false
;
sRunningInstance
=
null
;
}
else
{
isServiceStarted
=
true
;
}
return
isServiceStarted
;
}
final
Handler
handler
=
new
Handler
()
{
@Override
public
void
handleMessage
(
Message
msg
)
{
...
...
@@ -185,6 +148,41 @@ public class ShadowsocksService extends Service {
super
.
handleMessage
(
msg
);
}
};
private
Notification
notification
;
private
NotificationManager
notificationManager
;
private
PendingIntent
pendIntent
;
private
PowerManager
.
WakeLock
mWakeLock
;
private
Process
httpProcess
=
null
;
private
DataOutputStream
httpOS
=
null
;
private
String
appHost
;
private
int
remotePort
;
private
int
port
;
private
String
sitekey
;
private
SharedPreferences
settings
=
null
;
private
boolean
hasRedirectSupport
=
true
;
private
boolean
isGlobalProxy
=
false
;
private
boolean
isGFWList
=
false
;
private
boolean
isBypassApps
=
false
;
private
ProxyedApp
apps
[];
private
Method
mSetForeground
;
private
Method
mStartForeground
;
private
Method
mStopForeground
;
private
Object
[]
mSetForegroundArgs
=
new
Object
[
1
];
private
Object
[]
mStartForegroundArgs
=
new
Object
[
2
];
private
Object
[]
mStopForegroundArgs
=
new
Object
[
1
];
public
static
boolean
isServiceStarted
()
{
final
boolean
isServiceStarted
;
if
(
sRunningInstance
==
null
)
{
isServiceStarted
=
false
;
}
else
if
(
sRunningInstance
.
get
()
==
null
)
{
isServiceStarted
=
false
;
sRunningInstance
=
null
;
}
else
{
isServiceStarted
=
true
;
}
return
isServiceStarted
;
}
public
void
startShadowsocksDaemon
()
{
final
String
cmd
=
String
.
format
(
BASE
...
...
@@ -269,6 +267,15 @@ public class ShadowsocksService extends Service {
markServiceStarted
();
}
private
void
startRedsocksDaemon
()
{
String
conf
=
String
.
format
(
REDSOCKS_CONF
,
port
);
String
cmd
=
String
.
format
(
"%sredsocks -p %sredsocks.pid -c %sredsocks.conf"
,
BASE
,
BASE
,
BASE
);
Utils
.
runRootCommand
(
"echo \""
+
conf
+
"\" > "
+
BASE
+
"redsocks.conf\n"
+
cmd
);
}
/**
* Called when the activity is first created.
*/
...
...
@@ -276,6 +283,7 @@ public class ShadowsocksService extends Service {
startShadowsocksDaemon
();
startDnsDaemon
();
startRedsocksDaemon
();
setupIptables
();
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