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
a69183cc
Commit
a69183cc
authored
Aug 03, 2017
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move all network rules to new block
parent
62a0bb59
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
24 deletions
+6
-24
mobile/src/main/scala/com/github/shadowsocks/acl/Acl.scala
mobile/src/main/scala/com/github/shadowsocks/acl/Acl.scala
+6
-24
No files found.
mobile/src/main/scala/com/github/shadowsocks/acl/Acl.scala
View file @
a69183cc
...
...
@@ -27,25 +27,6 @@ class Acl {
var
bypass
:
Boolean
=
_
def
isUrl
(
url
:
String
)
:
Boolean
=
url
.
startsWith
(
"http://"
)
||
url
.
startsWith
(
"https://"
)
def
getBypassHostnamesString
:
String
=
bypassHostnames
.
mkString
(
"\n"
)
def
getProxyHostnamesString
:
String
=
proxyHostnames
.
mkString
(
"\n"
)
def
getSubnetsString
:
String
=
subnets
.
mkString
(
"\n"
)
def
setBypassHostnamesString
(
value
:
String
)
{
bypassHostnames
.
clear
()
bypassHostnames
++=
value
.
split
(
"\n"
)
}
def
setProxyHostnamesString
(
value
:
String
)
{
proxyHostnames
.
clear
()
proxyHostnames
++=
value
.
split
(
"\n"
)
}
def
setSubnetsString
(
value
:
String
)
{
subnets
.
clear
()
subnets
++=
value
.
split
(
"\n"
).
map
(
Subnet
.
fromString
)
}
def
setUrlRules
(
value
:
String
)
{
urls
.
clear
()
urls
++=
value
.
split
(
"\n"
)
}
def
fromAcl
(
other
:
Acl
)
:
Acl
=
{
bypassHostnames
.
clear
()
...
...
@@ -70,9 +51,8 @@ class Acl {
var
hostnames
:
mutable.SortedList
[
String
]
=
if
(
defaultBypass
)
proxyHostnames
else
bypassHostnames
var
subnets
:
mutable.SortedList
[
Subnet
]
=
if
(
defaultBypass
)
proxySubnets
else
bypassSubnets
var
in_urls
=
false
for
(
line
<-
value
.
getLines
())
(
line
.
indexOf
(
'#'
)
match
{
case
-
1
=>
if
(!
in_urls
)
line
else
""
case
index
=>
{
for
(
line
<-
value
.
getLines
())
(
line
.
trim
.
indexOf
(
'#'
)
match
{
case
0
=>
{
line
.
indexOf
(
"NETWORK_ACL_BEGIN"
)
match
{
case
-
1
=>
case
index
=>
in_urls
=
true
...
...
@@ -83,6 +63,7 @@ class Acl {
}
""
// ignore any comment lines
}
case
index
=>
if
(!
in_urls
)
line
else
""
}).
trim
match
{
case
"[outbound_block_list]"
=>
hostnames
=
null
...
...
@@ -113,16 +94,17 @@ class Acl {
val
result
=
new
StringBuilder
()
if
(
urls
.
nonEmpty
)
{
result
.
append
(
urls
.
mkString
(
"\n"
))
result
.
append
(
"
#NETWORK_ACL_BEGIN
\n"
)
result
.
append
(
"\n"
)
if
(
network
)
{
result
.
append
(
"#NETWORK_ACL_BEGIN\n"
)
try
{
urls
.
foreach
((
url
:
String
)
=>
result
.
append
(
Source
.
fromURL
(
url
).
mkString
))
}
catch
{
case
e
:
IOException
=>
// ignore
}
}
result
.
append
(
"#NETWORK_ACL_END\n"
)
}
}
if
(
result
.
isEmpty
)
{
result
.
append
(
if
(
bypass
)
"[bypass_all]\n"
else
"[proxy_all]\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