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
b10c848e
Commit
b10c848e
authored
Nov 02, 2013
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trim strings
parent
b77a599e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
9 deletions
+24
-9
src/main/scala/com/github/shadowsocks/ShadowVpnService.scala
src/main/scala/com/github/shadowsocks/ShadowVpnService.scala
+1
-1
src/main/scala/com/github/shadowsocks/ShadowsocksService.scala
...ain/scala/com/github/shadowsocks/ShadowsocksService.scala
+1
-1
src/main/scala/com/github/shadowsocks/Utils.scala
src/main/scala/com/github/shadowsocks/Utils.scala
+22
-7
No files found.
src/main/scala/com/github/shadowsocks/ShadowVpnService.scala
View file @
b10c848e
...
@@ -192,7 +192,7 @@ class ShadowVpnService extends VpnService {
...
@@ -192,7 +192,7 @@ class ShadowVpnService extends VpnService {
if
(
config
.
proxy
==
"198.199.101.152"
)
{
if
(
config
.
proxy
==
"198.199.101.152"
)
{
val
container
=
getApplication
.
asInstanceOf
[
ShadowsocksApplication
].
tagContainer
val
container
=
getApplication
.
asInstanceOf
[
ShadowsocksApplication
].
tagContainer
try
{
try
{
config
=
Config
.
getPublicConfig
(
container
,
config
)
config
=
Config
.
getPublicConfig
(
getBaseContext
,
container
,
config
)
}
catch
{
}
catch
{
case
ex
:
Exception
=>
{
case
ex
:
Exception
=>
{
notifyAlert
(
getString
(
R
.
string
.
forward_fail
),
getString
(
R
.
string
.
service_failed
))
notifyAlert
(
getString
(
R
.
string
.
forward_fail
),
getString
(
R
.
string
.
service_failed
))
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksService.scala
View file @
b10c848e
...
@@ -228,7 +228,7 @@ class ShadowsocksService extends Service {
...
@@ -228,7 +228,7 @@ class ShadowsocksService extends Service {
if
(
config
.
proxy
==
"198.199.101.152"
)
{
if
(
config
.
proxy
==
"198.199.101.152"
)
{
val
container
=
getApplication
.
asInstanceOf
[
ShadowsocksApplication
].
tagContainer
val
container
=
getApplication
.
asInstanceOf
[
ShadowsocksApplication
].
tagContainer
try
{
try
{
config
=
Config
.
getPublicConfig
(
container
,
config
)
config
=
Config
.
getPublicConfig
(
getBaseContext
,
container
,
config
)
}
catch
{
}
catch
{
case
ex
:
Exception
=>
{
case
ex
:
Exception
=>
{
notifyAlert
(
getString
(
R
.
string
.
forward_fail
),
getString
(
R
.
string
.
service_failed
))
notifyAlert
(
getString
(
R
.
string
.
forward_fail
),
getString
(
R
.
string
.
service_failed
))
...
...
src/main/scala/com/github/shadowsocks/Utils.scala
View file @
b10c848e
...
@@ -42,7 +42,7 @@ import android.content.{Intent, SharedPreferences, Context}
...
@@ -42,7 +42,7 @@ import android.content.{Intent, SharedPreferences, Context}
import
android.content.pm.ApplicationInfo
import
android.content.pm.ApplicationInfo
import
android.content.pm.PackageManager
import
android.content.pm.PackageManager
import
android.graphics.drawable.
{
BitmapDrawable
,
Drawable
}
import
android.graphics.drawable.
{
BitmapDrawable
,
Drawable
}
import
android.util.
Log
import
android.util.
{
Base64
,
Log
}
import
java.io._
import
java.io._
import
java.net.
{
UnknownHostException
,
InetAddress
,
NetworkInterface
}
import
java.net.
{
UnknownHostException
,
InetAddress
,
NetworkInterface
}
import
org.apache.http.conn.util.InetAddressUtils
import
org.apache.http.conn.util.InetAddressUtils
...
@@ -55,6 +55,7 @@ import android.provider.Settings
...
@@ -55,6 +55,7 @@ import android.provider.Settings
import
scala.Some
import
scala.Some
import
scalaj.http.
{
Http
,
HttpOptions
}
import
scalaj.http.
{
Http
,
HttpOptions
}
import
com.google.tagmanager.Container
import
com.google.tagmanager.Container
import
java.security.MessageDigest
object
Config
{
object
Config
{
val
SHADOWSOCKS
=
"{\"server\": [%s], \"server_port\": %d, \"local_port\": %d, \"password\": %s, \"timeout\": %d}"
val
SHADOWSOCKS
=
"{\"server\": [%s], \"server_port\": %d, \"local_port\": %d, \"password\": %s, \"timeout\": %d}"
...
@@ -117,16 +118,21 @@ object Config {
...
@@ -117,16 +118,21 @@ object Config {
if
(
container
!=
null
)
container
.
refresh
()
if
(
container
!=
null
)
container
.
refresh
()
}
}
def
getPublicConfig
(
container
:
Container
,
config
:
Config
)
:
Config
=
{
def
getPublicConfig
(
cont
ext
:
Context
,
cont
ainer
:
Container
,
config
:
Config
)
:
Config
=
{
val
url
=
container
.
getString
(
"proxy_url"
)
val
url
=
container
.
getString
(
"proxy_url"
)
val
list
=
Http
(
url
).
option
(
HttpOptions
.
connTimeout
(
1000
)).
option
(
HttpOptions
.
readTimeout
(
5000
)).
asString
val
sig
=
Utils
.
getSignature
(
context
)
val
list
=
Http
(
url
)
.
params
(
"sig"
->
sig
)
.
option
(
HttpOptions
.
connTimeout
(
1000
))
.
option
(
HttpOptions
.
readTimeout
(
5000
))
.
asString
val
proxies
=
util
.
Random
.
shuffle
(
list
.
split
(
'|'
).
toSeq
).
toSeq
val
proxies
=
util
.
Random
.
shuffle
(
list
.
split
(
'|'
).
toSeq
).
toSeq
val
proxy
=
proxies
(
0
).
split
(
':'
)
val
proxy
=
proxies
(
0
).
split
(
':'
)
val
host
=
proxy
(
0
)
val
host
=
proxy
(
0
)
.
trim
val
port
=
proxy
(
1
).
toInt
val
port
=
proxy
(
1
).
t
rim
.
t
oInt
val
password
=
proxy
(
2
)
val
password
=
proxy
(
2
)
.
trim
val
method
=
proxy
(
3
)
val
method
=
proxy
(
3
)
.
trim
new
Config
(
config
.
isGlobalProxy
,
config
.
isGFWList
,
config
.
isBypassApps
,
config
.
isTrafficStat
,
new
Config
(
config
.
isGlobalProxy
,
config
.
isGFWList
,
config
.
isBypassApps
,
config
.
isTrafficStat
,
config
.
profileName
,
host
,
password
,
method
,
port
,
config
.
localPort
,
config
.
proxiedAppString
)
config
.
profileName
,
host
,
password
,
method
,
port
,
config
.
localPort
,
config
.
proxiedAppString
)
...
@@ -287,6 +293,15 @@ object Utils {
...
@@ -287,6 +293,15 @@ object Utils {
var
data_path
:
String
=
null
var
data_path
:
String
=
null
var
rootTries
=
0
var
rootTries
=
0
def
getSignature
(
context
:
Context
)
:
String
=
{
val
info
=
context
.
getPackageManager
.
getPackageInfo
(
context
.
getPackageName
,
PackageManager
.
GET_SIGNATURES
)
val
mdg
=
MessageDigest
.
getInstance
(
"SHA-1"
)
mdg
.
update
(
info
.
signatures
(
0
).
toByteArray
)
new
String
(
Base64
.
encode
(
mdg
.
digest
,
0
))
}
/*
/*
* round or floor depending on whether you are using offsets(floor) or
* round or floor depending on whether you are using offsets(floor) or
* widths(round)
* widths(round)
...
...
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