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
a89ca2d1
Commit
a89ca2d1
authored
Feb 28, 2014
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add udp dns option
parent
c4429633
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
78 additions
and
45 deletions
+78
-45
src/main/java/com/github/shadowsocks/aidl/Config.java
src/main/java/com/github/shadowsocks/aidl/Config.java
+18
-16
src/main/res/values-zh/strings.xml
src/main/res/values-zh/strings.xml
+3
-0
src/main/res/values/strings.xml
src/main/res/values/strings.xml
+2
-0
src/main/res/xml/pref_feature.xml
src/main/res/xml/pref_feature.xml
+10
-4
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+2
-1
src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala
.../scala/com/github/shadowsocks/ShadowsocksNatService.scala
+13
-9
src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
.../scala/com/github/shadowsocks/ShadowsocksVpnService.scala
+14
-11
src/main/scala/com/github/shadowsocks/database/DBHelper.scala
...main/scala/com/github/shadowsocks/database/DBHelper.scala
+6
-2
src/main/scala/com/github/shadowsocks/database/Profile.scala
src/main/scala/com/github/shadowsocks/database/Profile.scala
+3
-0
src/main/scala/com/github/shadowsocks/database/ProfileManager.scala
...cala/com/github/shadowsocks/database/ProfileManager.scala
+2
-0
src/main/scala/com/github/shadowsocks/utils/ConfigUtils.scala
...main/scala/com/github/shadowsocks/utils/ConfigUtils.scala
+4
-2
src/main/scala/com/github/shadowsocks/utils/Constants.scala
src/main/scala/com/github/shadowsocks/utils/Constants.scala
+1
-0
No files found.
src/main/java/com/github/shadowsocks/aidl/Config.java
View file @
a89ca2d1
...
...
@@ -9,6 +9,7 @@ public class Config implements Parcelable {
public
boolean
isGFWList
=
true
;
public
boolean
isBypassApps
=
false
;
public
boolean
isTrafficStat
=
false
;
public
boolean
isUdpDns
=
false
;
public
String
profileName
=
"Untitled"
;
public
String
proxy
=
"127.0.0.1"
;
...
...
@@ -20,24 +21,24 @@ public class Config implements Parcelable {
public
int
remotePort
=
1984
;
public
int
localPort
=
1080
;
public
static
final
Parcelable
.
Creator
<
Config
>
CREATOR
=
new
Parcelable
.
Creator
<
Config
>()
{
public
Config
createFromParcel
(
Parcel
in
)
{
return
new
Config
(
in
);
}
public
static
final
Parcelable
.
Creator
<
Config
>
CREATOR
=
new
Parcelable
.
Creator
<
Config
>()
{
public
Config
createFromParcel
(
Parcel
in
)
{
return
new
Config
(
in
);
}
public
Config
[]
newArray
(
int
size
)
{
return
new
Config
[
size
];
}
};
public
Config
[]
newArray
(
int
size
)
{
return
new
Config
[
size
];
}
};
public
Config
(
boolean
isGlobalProxy
,
boolean
isGFWList
,
boolean
isBypassApps
,
boolean
isTrafficStat
,
String
profileName
,
String
proxy
,
String
sitekey
,
String
encMethod
,
String
proxiedAppString
,
int
remotePort
,
int
localPort
)
{
boolean
isTrafficStat
,
boolean
isUdpDns
,
String
profileName
,
String
proxy
,
String
sitekey
,
String
encMethod
,
String
proxiedAppString
,
int
remotePort
,
int
localPort
)
{
this
.
isGlobalProxy
=
isGlobalProxy
;
this
.
isGFWList
=
isGFWList
;
this
.
isBypassApps
=
isBypassApps
;
this
.
isTrafficStat
=
isTrafficStat
;
this
.
isUdpDns
=
isUdpDns
;
this
.
profileName
=
profileName
;
this
.
proxy
=
proxy
;
this
.
sitekey
=
sitekey
;
...
...
@@ -56,6 +57,7 @@ public class Config implements Parcelable {
isGFWList
=
in
.
readInt
()
==
1
;
isBypassApps
=
in
.
readInt
()
==
1
;
isTrafficStat
=
in
.
readInt
()
==
1
;
isUdpDns
=
in
.
readInt
()
==
1
;
profileName
=
in
.
readString
();
proxy
=
in
.
readString
();
sitekey
=
in
.
readString
();
...
...
@@ -70,10 +72,11 @@ public class Config implements Parcelable {
}
@Override
public
void
writeToParcel
(
Parcel
out
,
int
flags
)
{
out
.
writeInt
(
isGlobalProxy
?
1
:
0
);
out
.
writeInt
(
isGFWList
?
1
:
0
);
out
.
writeInt
(
isBypassApps
?
1
:
0
);
out
.
writeInt
(
isTrafficStat
?
1
:
0
);
out
.
writeInt
(
isGlobalProxy
?
1
:
0
);
out
.
writeInt
(
isGFWList
?
1
:
0
);
out
.
writeInt
(
isBypassApps
?
1
:
0
);
out
.
writeInt
(
isTrafficStat
?
1
:
0
);
out
.
writeInt
(
isUdpDns
?
1
:
0
);
out
.
writeString
(
profileName
);
out
.
writeString
(
proxy
);
out
.
writeString
(
sitekey
);
...
...
@@ -81,6 +84,5 @@ public class Config implements Parcelable {
out
.
writeString
(
proxiedAppString
);
out
.
writeInt
(
remotePort
);
out
.
writeInt
(
localPort
);
}
}
src/main/res/values-zh/strings.xml
View file @
a89ca2d1
...
...
@@ -67,6 +67,9 @@
<string
name=
"flushing"
>
刷新中...
</string>
<string
name=
"add_profile"
>
添加配置文件
</string>
<string
name=
"udp_dns"
>
DNS转发
</string>
<string
name=
"udp_dns_summary"
>
向远程服务器转发UDP协议的DNS请求
</string>
<!-- profile -->
<string
name=
"add_profile_dialog"
>
为影梭添加此配置文件?
</string>
<string-array
name=
"add_profile_methods"
>
...
...
src/main/res/values/strings.xml
View file @
a89ca2d1
...
...
@@ -45,6 +45,8 @@
<string
name=
"auto_connect_summary"
>
Enable Shadowsocks on startup
</string>
<string
name=
"traffic_stat"
>
Traffic Stats
</string>
<string
name=
"traffic_stat_summary"
>
Show traffic stats in notification bar
</string>
<string
name=
"udp_dns"
>
DNS Forwarding
</string>
<string
name=
"udp_dns_summary"
>
Forward DNS\'s UDP packets to remote server
</string>
<!-- notification category -->
<string
name=
"forward_success"
>
Shadowsocks started.
</string>
...
...
src/main/res/xml/pref_feature.xml
View file @
a89ca2d1
...
...
@@ -22,10 +22,16 @@
<intent
android:action=
"com.github.shadowsocks.AppManager"
/>
</Preference>
<CheckBoxPreference
android:key=
"isTrafficStat"
android:defaultValue=
"true"
android:summary=
"@string/traffic_stat_summary"
android:title=
"@string/traffic_stat"
>
android:key=
"isTrafficStat"
android:defaultValue=
"true"
android:summary=
"@string/traffic_stat_summary"
android:title=
"@string/traffic_stat"
>
</CheckBoxPreference>
<CheckBoxPreference
android:key=
"isUdpDns"
android:defaultValue=
"false"
android:summary=
"@string/udp_dns_summary"
android:title=
"@string/udp_dns"
>
</CheckBoxPreference>
<CheckBoxPreference
android:key=
"isAutoConnect"
...
...
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
View file @
a89ca2d1
...
...
@@ -122,7 +122,7 @@ object Shadowsocks {
val
PROXY_PREFS
=
Array
(
Key
.
profileName
,
Key
.
proxy
,
Key
.
remotePort
,
Key
.
localPort
,
Key
.
sitekey
,
Key
.
encMethod
)
val
FEATRUE_PREFS
=
Array
(
Key
.
isGFWList
,
Key
.
isGlobalProxy
,
Key
.
proxyedApps
,
Key
.
isTrafficStat
,
Key
.
isAutoConnect
)
Key
.
is
UdpDns
,
Key
.
is
AutoConnect
)
val
TAG
=
"Shadowsocks"
val
REQUEST_CONNECT
=
1
...
...
@@ -162,6 +162,7 @@ object Shadowsocks {
case
Key
.
isGFWList
=>
updateCheckBoxPreference
(
pref
,
profile
.
chnroute
)
case
Key
.
isGlobalProxy
=>
updateCheckBoxPreference
(
pref
,
profile
.
global
)
case
Key
.
isTrafficStat
=>
updateCheckBoxPreference
(
pref
,
profile
.
traffic
)
case
Key
.
isUdpDns
=>
updateCheckBoxPreference
(
pref
,
profile
.
udpdns
)
case
_
=>
}
}
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala
View file @
a89ca2d1
...
...
@@ -111,15 +111,19 @@ class ShadowsocksNatService extends Service with BaseService {
}
def
startDnsDaemon
()
{
val
cmd
=
(
Path
.
BASE
+
"ss-tunnel -b 127.0.0.1 -s \"%s\" -p \"%d\" -l \"%d\" -k \"%s\" -m \"%s\" -L 8.8.8.8:53 -u -f "
+
Path
.
BASE
+
"ss-local.pid"
)
.
format
(
config
.
proxy
,
config
.
remotePort
,
8153
,
config
.
sitekey
,
config
.
encMethod
)
// val cmd = Path.BASE + "pdnsd -c " + Path.BASE + "pdnsd.conf"
// val conf = ConfigUtils.PDNSD.format("127.0.0.1")
// ConfigUtils.printToFile(new File(Path.BASE + "pdnsd.conf"))(p => {
// p.println(conf)
// })
val
cmd
=
if
(
config
.
isUdpDns
)
{
(
Path
.
BASE
+
"ss-tunnel -b 127.0.0.1 -s \"%s\" -p \"%d\" -l \"%d\" -k \"%s\" -m \"%s\" -L 8.8.8.8:53 -u -f "
+
Path
.
BASE
+
"ss-local.pid"
)
.
format
(
config
.
proxy
,
config
.
remotePort
,
8153
,
config
.
sitekey
,
config
.
encMethod
)
}
else
{
val
conf
=
ConfigUtils
.
PDNSD
.
format
(
"127.0.0.1"
)
ConfigUtils
.
printToFile
(
new
File
(
Path
.
BASE
+
"pdnsd.conf"
))(
p
=>
{
p
.
println
(
conf
)
})
Path
.
BASE
+
"pdnsd -c "
+
Path
.
BASE
+
"pdnsd.conf"
}
Utils
.
runCommand
(
cmd
)
}
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
View file @
a89ca2d1
...
...
@@ -76,23 +76,26 @@ class ShadowsocksVpnService extends VpnService with BaseService {
def
startShadowsocksDaemon
()
{
val
cmd
:
String
=
(
Path
.
BASE
+
"s
hadowsocks
-b 127.0.0.1 -s \"%s\" -p \"%d\" -l \"%d\" -k \"%s\" -m \"%s\" -f "
+
Path
.
BASE
+
"s
hadowsocks
.pid"
)
"s
s-local
-b 127.0.0.1 -s \"%s\" -p \"%d\" -l \"%d\" -k \"%s\" -m \"%s\" -f "
+
Path
.
BASE
+
"s
s-local
.pid"
)
.
format
(
config
.
proxy
,
config
.
remotePort
,
config
.
localPort
,
config
.
sitekey
,
config
.
encMethod
)
if
(
BuildConfig
.
DEBUG
)
Log
.
d
(
TAG
,
cmd
)
System
.
exec
(
cmd
)
}
def
startDnsDaemon
()
{
val
cmd
=
(
Path
.
BASE
+
"ss-tunnel -b 127.0.0.1 -s \"%s\" -p \"%d\" -l \"%d\" -k \"%s\" -m \"%s\" -L 8.8.8.8:53 -u -f "
+
Path
.
BASE
+
"ss-local.pid"
)
.
format
(
config
.
proxy
,
config
.
remotePort
,
8153
,
config
.
sitekey
,
config
.
encMethod
)
// val cmd: String = Path.BASE + "pdnsd -c " + Path.BASE + "pdnsd.conf"
// val conf: String = ConfigUtils.PDNSD.format("0.0.0.0")
// ConfigUtils.printToFile(new File(Path.BASE + "pdnsd.conf"))(p => {
// p.println(conf)
// })
val
cmd
=
if
(
config
.
isUdpDns
)
{
(
Path
.
BASE
+
"ss-tunnel -b 0.0.0.0 -s \"%s\" -p \"%d\" -l \"%d\" -k \"%s\" -m \"%s\" -L 8.8.8.8:53 -u -f "
+
Path
.
BASE
+
"ss-tunnel.pid"
)
.
format
(
config
.
proxy
,
config
.
remotePort
,
8153
,
config
.
sitekey
,
config
.
encMethod
)
}
else
{
val
conf
=
ConfigUtils
.
PDNSD
.
format
(
"0.0.0.0"
)
ConfigUtils
.
printToFile
(
new
File
(
Path
.
BASE
+
"pdnsd.conf"
))(
p
=>
{
p
.
println
(
conf
)
})
Path
.
BASE
+
"pdnsd -c "
+
Path
.
BASE
+
"pdnsd.conf"
}
Utils
.
runCommand
(
cmd
)
}
...
...
src/main/scala/com/github/shadowsocks/database/DBHelper.scala
View file @
a89ca2d1
...
...
@@ -50,7 +50,7 @@ object DBHelper {
val
PROFILE
=
"profile.db"
}
class
DBHelper
(
val
context
:
Context
)
extends
OrmLiteSqliteOpenHelper
(
context
,
DBHelper
.
PROFILE
,
null
,
7
)
{
class
DBHelper
(
val
context
:
Context
)
extends
OrmLiteSqliteOpenHelper
(
context
,
DBHelper
.
PROFILE
,
null
,
8
)
{
lazy
val
profileDao
:
Dao
[
Profile
,
Int
]
=
getDao
(
classOf
[
Profile
])
...
...
@@ -59,7 +59,11 @@ class DBHelper(val context: Context) extends OrmLiteSqliteOpenHelper(context, DB
}
def
onUpgrade
(
database
:
SQLiteDatabase
,
connectionSource
:
ConnectionSource
,
oldVersion
:
Int
,
newVersion
:
Int
)
{
TableUtils
.
dropTable
(
connectionSource
,
classOf
[
Profile
],
true
)
if
(
oldVersion
<
8
)
{
profileDao
.
executeRaw
(
"ALTER TABLE `profile` ADD COLUMN udpdns INTEGER;"
)
}
else
{
TableUtils
.
dropTable
(
connectionSource
,
classOf
[
Profile
],
true
)
}
onCreate
(
database
,
connectionSource
)
}
}
src/main/scala/com/github/shadowsocks/database/Profile.scala
View file @
a89ca2d1
...
...
@@ -84,6 +84,9 @@ class Profile {
@DatabaseField
var
traffic
:
Boolean
=
false
@DatabaseField
var
udpdns
:
Boolean
=
false
@DatabaseField
(
dataType
=
DataType
.
LONG_STRING
)
var
individual
:
String
=
""
...
...
src/main/scala/com/github/shadowsocks/database/ProfileManager.scala
View file @
a89ca2d1
...
...
@@ -121,6 +121,7 @@ class ProfileManager(settings: SharedPreferences, dbHelper: DBHelper) {
edit
.
putBoolean
(
Key
.
isGFWList
,
profile
.
chnroute
)
edit
.
putBoolean
(
Key
.
isBypassApps
,
profile
.
bypass
)
edit
.
putBoolean
(
Key
.
isTrafficStat
,
profile
.
traffic
)
edit
.
putBoolean
(
Key
.
isUdpDns
,
profile
.
udpdns
)
edit
.
putString
(
Key
.
profileName
,
profile
.
name
)
edit
.
putString
(
Key
.
proxy
,
profile
.
host
)
edit
.
putString
(
Key
.
sitekey
,
profile
.
password
)
...
...
@@ -143,6 +144,7 @@ class ProfileManager(settings: SharedPreferences, dbHelper: DBHelper) {
profile
.
chnroute
=
settings
.
getBoolean
(
Key
.
isGFWList
,
false
)
profile
.
bypass
=
settings
.
getBoolean
(
Key
.
isBypassApps
,
false
)
profile
.
traffic
=
settings
.
getBoolean
(
Key
.
isTrafficStat
,
false
)
profile
.
udpdns
=
settings
.
getBoolean
(
Key
.
isUdpDns
,
false
)
profile
.
name
=
settings
.
getString
(
Key
.
profileName
,
"default"
)
profile
.
host
=
settings
.
getString
(
Key
.
proxy
,
"127.0.0.1"
)
profile
.
password
=
settings
.
getString
(
Key
.
sitekey
,
"default"
)
...
...
src/main/scala/com/github/shadowsocks/utils/ConfigUtils.scala
View file @
a89ca2d1
...
...
@@ -84,7 +84,8 @@ object ConfigUtils {
val
method
=
proxy
(
3
).
trim
new
Config
(
config
.
isGlobalProxy
,
config
.
isGFWList
,
config
.
isBypassApps
,
config
.
isTrafficStat
,
config
.
profileName
,
host
,
password
,
method
,
config
.
proxiedAppString
,
port
,
config
.
localPort
)
config
.
isUdpDns
,
config
.
profileName
,
host
,
password
,
method
,
config
.
proxiedAppString
,
port
,
config
.
localPort
)
}
def
load
(
settings
:
SharedPreferences
)
:
Config
=
{
...
...
@@ -92,6 +93,7 @@ object ConfigUtils {
val
isGFWList
=
settings
.
getBoolean
(
Key
.
isGFWList
,
false
)
val
isBypassApps
=
settings
.
getBoolean
(
Key
.
isBypassApps
,
false
)
val
isTrafficStat
=
settings
.
getBoolean
(
Key
.
isTrafficStat
,
false
)
val
isUdpDns
=
settings
.
getBoolean
(
Key
.
isUdpDns
,
false
)
val
profileName
=
settings
.
getString
(
Key
.
profileName
,
"default"
)
val
proxy
=
settings
.
getString
(
Key
.
proxy
,
"127.0.0.1"
)
...
...
@@ -111,7 +113,7 @@ object ConfigUtils {
}
val
proxiedAppString
=
settings
.
getString
(
Key
.
proxied
,
""
)
new
Config
(
isGlobalProxy
,
isGFWList
,
isBypassApps
,
isTrafficStat
,
profileName
,
proxy
,
sitekey
,
new
Config
(
isGlobalProxy
,
isGFWList
,
isBypassApps
,
isTrafficStat
,
isUdpDns
,
profileName
,
proxy
,
sitekey
,
encMethod
,
proxiedAppString
,
remotePort
,
localPort
)
}
...
...
src/main/scala/com/github/shadowsocks/utils/Constants.scala
View file @
a89ca2d1
...
...
@@ -70,6 +70,7 @@ object Key {
val
isGFWList
=
"isGFWList"
val
isBypassApps
=
"isBypassApps"
val
isTrafficStat
=
"isTrafficStat"
val
isUdpDns
=
"isUdpDns"
val
proxy
=
"proxy"
val
sitekey
=
"sitekey"
...
...
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