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
1e2b3c8d
Commit
1e2b3c8d
authored
Dec 20, 2012
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
force DNS queries through socks proxy
parent
e4991a30
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
39 deletions
+23
-39
src/com/github/shadowsocks/Shadowsocks.java
src/com/github/shadowsocks/Shadowsocks.java
+3
-35
src/com/github/shadowsocks/ShadowsocksService.java
src/com/github/shadowsocks/ShadowsocksService.java
+20
-4
No files found.
src/com/github/shadowsocks/Shadowsocks.java
View file @
1e2b3c8d
...
...
@@ -495,11 +495,7 @@ public class Shadowsocks extends PreferenceActivity implements
public
boolean
serviceStart
()
{
if
(
ShadowsocksService
.
isServiceStarted
())
{
try
{
stopService
(
new
Intent
(
this
,
ShadowsocksService
.
class
));
}
catch
(
Exception
e
)
{
// Nothing
}
stopService
(
new
Intent
(
this
,
ShadowsocksService
.
class
));
return
false
;
}
...
...
@@ -510,29 +506,6 @@ public class Shadowsocks extends PreferenceActivity implements
if
(
isTextEmpty
(
proxy
,
getString
(
R
.
string
.
proxy_empty
)))
return
false
;
if
(
proxy
.
contains
(
"proxyofmax.appspot.com"
))
{
final
TextView
message
=
new
TextView
(
this
);
message
.
setPadding
(
10
,
5
,
10
,
5
);
final
SpannableString
s
=
new
SpannableString
(
getText
(
R
.
string
.
default_proxy_alert
));
Linkify
.
addLinks
(
s
,
Linkify
.
WEB_URLS
);
message
.
setText
(
s
);
message
.
setMovementMethod
(
LinkMovementMethod
.
getInstance
());
new
AlertDialog
.
Builder
(
this
)
.
setTitle
(
R
.
string
.
warning
)
.
setCancelable
(
false
)
.
setIcon
(
android
.
R
.
drawable
.
ic_dialog_info
)
.
setNegativeButton
(
getString
(
R
.
string
.
ok_iknow
),
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
id
)
{
dialog
.
cancel
();
}
}).
setView
(
message
).
create
().
show
();
}
String
portText
=
settings
.
getString
(
"port"
,
""
);
if
(
isTextEmpty
(
portText
,
getString
(
R
.
string
.
port_empty
)))
return
false
;
...
...
@@ -547,13 +520,8 @@ public class Shadowsocks extends PreferenceActivity implements
return
false
;
}
try
{
Intent
it
=
new
Intent
(
this
,
ShadowsocksService
.
class
);
startService
(
it
);
}
catch
(
Exception
e
)
{
// Nothing
return
false
;
}
Intent
it
=
new
Intent
(
this
,
ShadowsocksService
.
class
);
startService
(
it
);
return
true
;
}
...
...
src/com/github/shadowsocks/ShadowsocksService.java
View file @
1e2b3c8d
...
...
@@ -60,6 +60,8 @@ import java.io.*;
import
java.lang.ref.WeakReference
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.util.HashSet
;
public
class
ShadowsocksService
extends
Service
{
...
...
@@ -254,6 +256,20 @@ public class ShadowsocksService extends Service {
@Override
public
void
run
()
{
boolean
resolved
=
false
;
if
(
appHost
!=
null
)
{
InetAddress
addr
=
null
;
try
{
addr
=
InetAddress
.
getByName
(
appHost
);
}
catch
(
UnknownHostException
ignored
)
{
}
if
(
addr
!=
null
)
{
appHost
=
addr
.
getHostAddress
();
resolved
=
true
;
}
}
handler
.
sendEmptyMessage
(
MSG_CONNECT_START
);
Log
.
d
(
TAG
,
"IPTABLES: "
+
Utils
.
getIptables
());
...
...
@@ -261,7 +277,7 @@ public class ShadowsocksService extends Service {
// Test for Redirect Support
hasRedirectSupport
=
Utils
.
getHasRedirectSupport
();
if
(
handleConnection
())
{
if
(
resolved
&&
handleConnection
())
{
// Connection and forward successful
notifyAlert
(
getString
(
R
.
string
.
forward_success
),
getString
(
R
.
string
.
service_running
));
...
...
@@ -510,10 +526,10 @@ public class ShadowsocksService extends Service {
String
cmd_bypass
=
Utils
.
getIptables
()
+
CMD_IPTABLES_RETURN
;
init_sb
.
append
(
cmd_bypass
.
replace
(
"-d 0.0.0.0"
,
"--dport "
+
remotePort
));
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));
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 "
+
getApplicationInfo
().
uid
));
//
init_sb.append(cmd_bypass.replace("-d 0.0.0.0", "-m owner --uid-owner "
//
+ getApplicationInfo().uid));
if
(
hasRedirectSupport
)
{
init_sb
.
append
(
Utils
.
getIptables
()).
append
(
" -t nat -A OUTPUT -p udp --dport 53 -j REDIRECT --to "
).
append
(
DNS_PORT
).
append
(
"\n"
);
...
...
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