Skip to content

Commit

Permalink
Merge b2f3db2 into backport/fix/gh-15210/sockaddr-template-parsing-wh…
Browse files Browse the repository at this point in the history
…en-needed/gladly-immense-gar
  • Loading branch information
hc-github-team-secure-vault-core committed Apr 29, 2022
2 parents fdafc8d + b2f3db2 commit eda74f7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions internalshared/configutil/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"net/textproto"
"regexp"
"strings"
"time"

Expand Down Expand Up @@ -410,10 +411,13 @@ func ParseListeners(result *SharedConfig, list *ast.ObjectList) error {

// ParseSingleIPTemplate is used as a helper function to parse out a single IP
// address from a config parameter.
// If the input doesn't appear to be 'template' format,
// it will return the specified input.
// If the input doesn't appear to contain the 'template' format,
// it will return the specified input unchanged.
func ParseSingleIPTemplate(ipTmpl string) (string, error) {
if !(strings.HasPrefix(ipTmpl, "{{") && strings.HasSuffix(ipTmpl, "}}")) {
m, err := regexp.MatchString("(.*?)({{.*?}})(.*)", ipTmpl)
if err != nil {
return "", fmt.Errorf("unable to verify existence of template syntax in input %q: %v", ipTmpl, err)
} else if !m {
return ipTmpl, nil
}

Expand Down

0 comments on commit eda74f7

Please sign in to comment.