Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

可以增加域名后缀匹配模式吗? #275

Open
blog2i2j opened this issue Jan 14, 2022 · 3 comments
Open

可以增加域名后缀匹配模式吗? #275

blog2i2j opened this issue Jan 14, 2022 · 3 comments

Comments

@blog2i2j
Copy link

overture的匹配模式full-map,只能对域名玩这个匹配才能识别, 可以增加对域名后缀匹配. 比如google.com作为匹配. 所有的 *.google.com都能被匹配到(比如www.google.com, mail.google.com)

@blog2i2j
Copy link
Author

/*

  • Copyright (c) 2019 shawn1m. All rights reserved.
  • Use of this source code is governed by The MIT License (MIT) that can be
  • found in the LICENSE file..
    */

package suffix

import (
"strings"
log "github.com/sirupsen/logrus"
)

type List struct {
DataList []string
}

func (s *List) Insert(str string) error {
s.DataList = append(s.DataList, "." + str)
return nil
}

func (s *List) Has(str string) bool {
str = "." + str
for _, data := range s.DataList {
if strings.Contains(str, data) {
log.Debugf("Match: Domain %s match suffix-list %s", str, data)
return true
}
}
return false
}

func (s *List) Name() string {
return "suffix-list"
}

@blog2i2j
Copy link
Author

自己瞎改了一段, 测试了一下可以实现子域名匹配.

@Alion548
Copy link

#180

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants