Merge current v2.9 into v3.0
This commit is contained in:
commit
241fb5093a
18 changed files with 386 additions and 116 deletions
|
@ -67,7 +67,7 @@ func clientIP(tree *matchersTree, clientIP ...string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
var almostFQDN = regexp.MustCompile(`^[[:alnum:]\.-]+$`)
|
||||
var hostOrIP = regexp.MustCompile(`^[[:alnum:]\.\-\:]+$`)
|
||||
|
||||
// hostSNI checks if the SNI Host of the connection match the matcher host.
|
||||
func hostSNI(tree *matchersTree, hosts ...string) error {
|
||||
|
@ -80,7 +80,7 @@ func hostSNI(tree *matchersTree, hosts ...string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
if !almostFQDN.MatchString(host) {
|
||||
if !hostOrIP.MatchString(host) {
|
||||
return fmt.Errorf("invalid value for HostSNI matcher, %q is not a valid hostname", host)
|
||||
}
|
||||
|
||||
|
|
|
@ -250,6 +250,16 @@ func Test_addTCPRoute(t *testing.T) {
|
|||
serverName: "example.com",
|
||||
matchErr: true,
|
||||
},
|
||||
{
|
||||
desc: "Matching IPv4",
|
||||
rule: "HostSNI(`127.0.0.1`)",
|
||||
serverName: "127.0.0.1",
|
||||
},
|
||||
{
|
||||
desc: "Matching IPv6",
|
||||
rule: "HostSNI(`10::10`)",
|
||||
serverName: "10::10",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
|
@ -332,6 +342,16 @@ func TestParseHostSNI(t *testing.T) {
|
|||
expression: "hostsni(`example.com`)",
|
||||
domain: []string{"example.com"},
|
||||
},
|
||||
{
|
||||
desc: "HostSNI IPv4",
|
||||
expression: "HostSNI(`127.0.0.1`)",
|
||||
domain: []string{"127.0.0.1"},
|
||||
},
|
||||
{
|
||||
desc: "HostSNI IPv6",
|
||||
expression: "HostSNI(`10::10`)",
|
||||
domain: []string{"10::10"},
|
||||
},
|
||||
{
|
||||
desc: "No hostSNI rule",
|
||||
expression: "ClientIP(`10.1`)",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue