feat(ftp): support receive ftp connection (#6)

Co-authored-by: E99p1ant <[email protected]>
This commit is contained in:
Li4n0
2021-04-25 13:39:27 +08:00
committed by GitHub
co-authored by E99p1ant
parent 5e24f9530d
commit 26755351f7
36 changed files with 1446 additions and 141 deletions
+15 -3
View File
@@ -2,6 +2,7 @@ package rule
import (
"regexp"
"strings"
"time"
log "unknwon.dev/clog/v2"
@@ -25,7 +26,9 @@ type BaseRule struct {
Notice bool `gorm:"default:false;not null;" form:"notice" json:"notice"`
}
func (br BaseRule) Match(s string) (flag, flagGroup string) {
func (br BaseRule) Match(s string) (flag, flagGroup string, vars map[string]string) {
vars = make(map[string]string)
if br.flagCatcher == nil {
if br.FlagFormat == "*" {
flag = "*"
@@ -41,13 +44,22 @@ func (br BaseRule) Match(s string) (flag, flagGroup string) {
}
matched := br.flagCatcher.FindStringSubmatch(s)
groupNames := br.flagCatcher.SubexpNames()
if len(matched) == 0 {
return
}
flag = matched[0]
if len(matched) > 1 {
if len(matched) > 1 && len(groupNames) == 0 {
flagGroup = matched[1]
}
return flag, flagGroup
for j, name := range groupNames {
if j != 0 && name != "" {
vars[name] = strings.TrimSpace(matched[j])
}
}
return flag, flagGroup, vars
}