Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce72dcf4dc | ||
|
|
c024049778 |
@@ -64,7 +64,7 @@ func MatchDomain(pattern string, domain string) (isMatched bool) {
|
||||
var portIndex = strings.LastIndex(patternPiece, ":*")
|
||||
if portIndex >= 0 {
|
||||
var prefix = patternPiece[:portIndex]
|
||||
if strings.HasPrefix(domainPieces[index], prefix+":") {
|
||||
if strings.HasPrefix(domainPieces[index], prefix+":") || domainPieces[index] == prefix {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,6 +94,14 @@ func TestMatchDomain(t *testing.T) {
|
||||
var ok = MatchDomains([]string{"*.example.com:8001"}, "a.example.com:8001")
|
||||
a.IsTrue(ok)
|
||||
}
|
||||
{
|
||||
var ok = MatchDomains([]string{"a.example.com:*"}, "a.example.com:8001")
|
||||
a.IsTrue(ok)
|
||||
}
|
||||
{
|
||||
var ok = MatchDomains([]string{"a.example.com:*"}, "a.example.com")
|
||||
a.IsTrue(ok)
|
||||
}
|
||||
{
|
||||
var ok = MatchDomains([]string{"*.example.com:*"}, "a.example.com:8001")
|
||||
a.IsTrue(ok)
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package firewallconfigs_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRuleCheckpoint_Markdown(t *testing.T) {
|
||||
var result = []string{}
|
||||
for _, def := range firewallconfigs.AllCheckpoints {
|
||||
def.Description = strings.ReplaceAll(def.Description, "<code-label>", "`")
|
||||
def.Description = strings.ReplaceAll(def.Description, "</code-label>", "`")
|
||||
|
||||
var row = "## " + def.Name + "\n"
|
||||
row += "* 名称:" + def.Name + "\n"
|
||||
row += "* 代号:`${" + def.Prefix + "}`\n"
|
||||
row += "* 描述:" + def.Description + "\n"
|
||||
result = append(result, row)
|
||||
}
|
||||
|
||||
fmt.Print(strings.Join(result, "\n") + "\n")
|
||||
}
|
||||
@@ -1,17 +1,22 @@
|
||||
package firewallconfigs
|
||||
package firewallconfigs_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRuleOperator_Markdown(t *testing.T) {
|
||||
result := []string{}
|
||||
for _, def := range AllRuleOperators {
|
||||
row := "## " + def.Name + "\n"
|
||||
row += "符号:`" + def.Code + "`\n"
|
||||
row += "描述:" + def.Description + "\n"
|
||||
var result = []string{}
|
||||
for _, def := range firewallconfigs.AllRuleOperators {
|
||||
def.Description = strings.ReplaceAll(def.Description, "<code-label>", "`")
|
||||
def.Description = strings.ReplaceAll(def.Description, "</code-label>", "`")
|
||||
|
||||
var row = "## " + def.Name + "\n"
|
||||
row += "* 名称:" + def.Name + "\n"
|
||||
row += "* 代号:`" + def.Code + "`\n"
|
||||
row += "* 描述:" + def.Description + "\n"
|
||||
result = append(result, row)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user