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
a6ac6ea8
Commit
a6ac6ea8
authored
Dec 14, 2019
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert re2j
parent
b7520896
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
17 deletions
+6
-17
core/build.gradle
core/build.gradle
+0
-1
core/src/main/java/com/github/shadowsocks/acl/AclMatcher.kt
core/src/main/java/com/github/shadowsocks/acl/AclMatcher.kt
+6
-16
No files found.
core/build.gradle
View file @
a6ac6ea8
...
...
@@ -65,7 +65,6 @@ dependencies {
api
'com.google.code.gson:gson:2.8.6'
api
'com.google.firebase:firebase-analytics:17.2.1'
api
'com.google.firebase:firebase-config:19.0.4'
api
'com.google.re2j:re2j:1.3'
api
'dnsjava:dnsjava:2.1.9'
api
"org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"
api
"org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutinesVersion"
...
...
core/src/main/java/com/github/shadowsocks/acl/AclMatcher.kt
View file @
a6ac6ea8
...
...
@@ -21,39 +21,29 @@
package
com.github.shadowsocks.acl
import
com.github.shadowsocks.net.Subnet
import
com.google.re2j.Pattern
import
java.net.Inet4Address
import
java.net.Inet6Address
class
AclMatcher
(
id
:
String
)
{
private
val
subnetsIpv4
:
List
<
Subnet
.
Immutable
>
private
val
subnetsIpv6
:
List
<
Subnet
.
Immutable
>
private
val
bypassDomains
:
Pattern
?
private
val
proxyDomains
:
Pattern
?
private
val
bypassDomains
=
mutableListOf
<
Regex
>()
private
val
proxyDomains
=
mutableListOf
<
Regex
>()
private
val
bypass
:
Boolean
init
{
val
bypassBuilder
=
StringBuilder
()
val
proxyBuilder
=
StringBuilder
()
val
(
bypass
,
subnets
)
=
Acl
.
parse
(
Acl
.
getFile
(
id
).
bufferedReader
(),
{
if
(
bypassBuilder
.
isNotEmpty
())
bypassBuilder
.
append
(
'|'
)
bypassBuilder
.
append
(
it
)
},
{
if
(
proxyBuilder
.
isNotEmpty
())
proxyBuilder
.
append
(
'|'
)
proxyBuilder
.
append
(
it
)
})
val
(
bypass
,
subnets
)
=
Acl
.
parse
(
Acl
.
getFile
(
id
).
bufferedReader
(),
{
bypassDomains
.
add
(
it
.
toRegex
())
},
{
proxyDomains
.
add
(
it
.
toRegex
())
})
subnetsIpv4
=
subnets
.
filter
{
it
.
address
is
Inet4Address
}.
map
{
it
.
toImmutable
()
}
subnetsIpv6
=
subnets
.
filter
{
it
.
address
is
Inet6Address
}.
map
{
it
.
toImmutable
()
}
bypassDomains
=
if
(
bypassBuilder
.
isEmpty
())
null
else
Pattern
.
compile
(
bypassBuilder
.
toString
())
proxyDomains
=
if
(
proxyBuilder
.
isEmpty
())
null
else
Pattern
.
compile
(
proxyBuilder
.
toString
())
this
.
bypass
=
bypass
}
fun
shouldBypassIpv4
(
ip
:
ByteArray
)
=
bypass
xor
subnetsIpv4
.
any
{
it
.
matches
(
ip
)
}
fun
shouldBypassIpv6
(
ip
:
ByteArray
)
=
bypass
xor
subnetsIpv6
.
any
{
it
.
matches
(
ip
)
}
fun
shouldBypass
(
host
:
String
):
Boolean
?
{
if
(
bypassDomains
?.
matches
(
host
)
==
true
)
return
true
if
(
proxyDomains
?.
matches
(
host
)
==
false
)
return
false
if
(
bypassDomains
.
any
{
it
.
matches
(
host
)
}
)
return
true
if
(
proxyDomains
.
any
{
it
.
matches
(
host
)
}
)
return
false
return
null
}
}
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