mirror of
https://github.com/ginuerzh/gost.git
synced 2024-04-21 12:31:34 +00:00
add QUIC support
This commit is contained in:
+11
-14
@@ -30,30 +30,27 @@ func Glob(pattern, subj string) bool {
|
||||
trailingGlob := strings.HasSuffix(pattern, GLOB)
|
||||
end := len(parts) - 1
|
||||
|
||||
for i, part := range parts {
|
||||
// Go over the leading parts and ensure they match.
|
||||
for i := 0; i < end; i++ {
|
||||
idx := strings.Index(subj, parts[i])
|
||||
|
||||
switch i {
|
||||
case 0:
|
||||
if leadingGlob {
|
||||
continue
|
||||
}
|
||||
if !strings.HasPrefix(subj, part) {
|
||||
// Check the first section. Requires special handling.
|
||||
if !leadingGlob && idx != 0 {
|
||||
return false
|
||||
}
|
||||
case end:
|
||||
if len(subj) > 0 {
|
||||
return trailingGlob || strings.HasSuffix(subj, part)
|
||||
}
|
||||
default:
|
||||
if !strings.Contains(subj, part) {
|
||||
// Check that the middle parts match.
|
||||
if idx < 0 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Trim evaluated text from subj as we loop over the pattern.
|
||||
idx := strings.Index(subj, part) + len(part)
|
||||
subj = subj[idx:]
|
||||
subj = subj[idx+len(parts[i]):]
|
||||
}
|
||||
|
||||
// All parts of the pattern matched
|
||||
return true
|
||||
// Reached the last section. Requires special handling.
|
||||
return trailingGlob || strings.HasSuffix(subj, parts[end])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user