shawn1m / overture

A customized DNS relay server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

blog2i2j opened this issue · comments

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

/*

  • 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"
}

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