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
17bedaff
Commit
17bedaff
authored
Jan 09, 2017
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #1064
parent
49fbfcc2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
9 deletions
+19
-9
src/main/scala/com/github/shadowsocks/acl/Acl.scala
src/main/scala/com/github/shadowsocks/acl/Acl.scala
+3
-3
src/main/scala/com/github/shadowsocks/acl/CustomRulesFragment.scala
...cala/com/github/shadowsocks/acl/CustomRulesFragment.scala
+11
-4
src/main/scala/com/github/shadowsocks/acl/Subnet.scala
src/main/scala/com/github/shadowsocks/acl/Subnet.scala
+1
-1
src/main/scala/scala/collection/mutable/SortedList.scala
src/main/scala/scala/collection/mutable/SortedList.scala
+4
-1
No files found.
src/main/scala/com/github/shadowsocks/acl/Acl.scala
View file @
17bedaff
...
...
@@ -80,7 +80,7 @@ class Acl {
}
case
_
=>
}
this
.
subnets
++=
(
if
(
bypass
)
bypassSubnets
else
proxy
Subnets
)
this
.
subnets
++=
(
if
(
bypass
)
proxySubnets
else
bypass
Subnets
)
this
}
final
def
fromId
(
id
:
String
)
:
Acl
=
fromSource
(
Source
.
fromFile
(
Acl
.
getPath
(
id
)))
...
...
@@ -90,8 +90,8 @@ class Acl {
result
.
append
(
if
(
bypass
)
"[bypass_all]\n"
else
"[proxy_all]\n"
)
var
bypassList
=
bypassHostnames
.
toStream
var
proxyList
=
proxyHostnames
.
toStream
if
(
bypass
)
bypass
List
=
subnets
.
toStream
.
map
(
_
.
toString
)
#:::
bypassList
else
proxy
List
=
subnets
.
toStream
.
map
(
_
.
toString
)
#:::
proxyList
if
(
bypass
)
proxy
List
=
subnets
.
toStream
.
map
(
_
.
toString
)
#:::
bypassList
else
bypass
List
=
subnets
.
toStream
.
map
(
_
.
toString
)
#:::
proxyList
if
(
bypassList
.
nonEmpty
)
{
result
.
append
(
"[bypass_list]\n"
)
result
.
append
(
bypassList
.
mkString
(
"\n"
))
...
...
src/main/scala/com/github/shadowsocks/acl/CustomRulesFragment.scala
View file @
17bedaff
...
...
@@ -95,8 +95,13 @@ class CustomRulesFragment extends ToolbarFragment with Toolbar.OnMenuItemClickLi
})
:
DialogInterface.OnClickListener
)
.
setPositiveButton
(
android
.
R
.
string
.
ok
,
((
_
,
_
)
=>
adapter
.
addFromTemplate
(
templateSelector
.
getSelectedItemPosition
,
editText
.
getText
)
match
{
case
-
1
=>
adapter
.
remove
(
item
)
case
index
=>
list
.
post
(()
=>
list
.
scrollToPosition
(
index
))
case
-
1
=>
case
index
=>
val
item
=
this
.
item
list
.
post
(()
=>
{
list
.
scrollToPosition
(
index
)
adapter
.
remove
(
item
)
})
})
:
DialogInterface.OnClickListener
)
.
create
().
show
()
...
...
@@ -203,13 +208,15 @@ class CustomRulesFragment extends ToolbarFragment with Toolbar.OnMenuItemClickLi
def
getSectionTitle
(
i
:
Int
)
:
String
=
{
val
j
=
i
-
acl
.
subnets
.
size
(
if
(
j
<
0
)
acl
.
subnets
(
i
).
address
.
toString
.
charAt
(
0
).
toString
else
{
try
(
if
(
j
<
0
)
acl
.
subnets
(
i
).
address
.
getHostAddress
.
substring
(
0
,
1
)
else
{
val
hostname
=
acl
.
proxyHostnames
(
i
)
PATTERN_DOMAIN
.
findFirstMatchIn
(
hostname
)
match
{
case
Some
(
m
)
=>
m
.
matched
.
replaceAll
(
"\\\\."
,
"."
)
// don't convert IDN yet
case
None
=>
hostname
}
}).
substring
(
0
,
1
)
}).
substring
(
0
,
1
)
catch
{
case
_:
IndexOutOfBoundsException
=>
" "
}
}
}
...
...
src/main/scala/com/github/shadowsocks/acl/Subnet.scala
View file @
17bedaff
...
...
@@ -18,7 +18,7 @@ class Subnet(val address: InetAddress, val prefixSize: Int) extends Comparable[S
override
def
toString
:
String
=
if
(
address
match
{
case
_:
Inet4Address
=>
prefixSize
==
32
case
_:
Inet6Address
=>
prefixSize
==
128
})
address
.
toString
else
address
.
toString
+
'/'
+
prefixSize
})
address
.
getHostAddress
else
address
.
getHostAddress
+
'/'
+
prefixSize
override
def
compareTo
(
that
:
Subnet
)
:
Int
=
{
val
addrThis
=
address
.
getAddress
...
...
src/main/scala/scala/collection/mutable/SortedList.scala
View file @
17bedaff
...
...
@@ -39,7 +39,10 @@ class SortedList[A] private(treeRef: ObjectRef[RB.Tree[A, Null]], from: Option[A
}
// AbstractSeq
def
apply
(
i
:
Int
)
:
A
=
RB
.
nth
(
treeRef
.
elem
,
i
).
key
// Should i out of range result in NullReferenceException?
def
apply
(
i
:
Int
)
:
A
=
try
RB
.
nth
(
treeRef
.
elem
,
i
).
key
catch
{
// out of bounds will result in accessing null nodes
case
e
:
NullPointerException
=>
throw
new
IndexOutOfBoundsException
().
initCause
(
e
)
}
def
length
:
Int
=
size
// Buffer
...
...
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