mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 16:09:57 +00:00
Split out typed config from legacy command-line switches; refactor ingress commands and fix tests
This commit is contained in:
@@ -13,7 +13,6 @@ var (
|
||||
ErrNoIngressRules = errors.New("No ingress rules were specified in the config file")
|
||||
errLastRuleNotCatchAll = errors.New("The last ingress rule must match all hostnames (i.e. it must be missing, or must be \"*\")")
|
||||
errBadWildcard = errors.New("Hostname patterns can have at most one wildcard character (\"*\") and it can only be used for subdomains, e.g. \"*.example.com\"")
|
||||
errNoIngressRulesMatch = errors.New("The URL didn't match any ingress rules")
|
||||
ErrURLIncompatibleWithIngress = errors.New("You can't set the --url flag (or $TUNNEL_URL) when using multiple-origin ingress rules")
|
||||
)
|
||||
|
||||
@@ -166,14 +165,3 @@ func ParseIngress(ing UnvalidatedIngress) (Ingress, error) {
|
||||
}
|
||||
return ing.validate()
|
||||
}
|
||||
|
||||
// RuleCommand checks which ingress rule matches the given request URL.
|
||||
func RuleCommand(ing Ingress, requestURL *url.URL) error {
|
||||
if requestURL.Hostname() == "" {
|
||||
return fmt.Errorf("%s is malformed and doesn't have a hostname", requestURL)
|
||||
}
|
||||
i := ing.FindMatchingRule(requestURL.Hostname(), requestURL.Path)
|
||||
fmt.Printf("Matched rule #%d\n", i+1)
|
||||
fmt.Println(ing.Rules[i].MultiLineString())
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user