workaround fortios max object name length

This commit is contained in:
Steven Polley 2020-05-29 20:32:50 -06:00
parent 784ff2fcc9
commit 17cfaf377a

View File

@ -24,7 +24,12 @@ func config(redirects []Redirect) error {
return fmt.Errorf("unable to parse source URL '%s': %v", redirect.sourceURL, err) return fmt.Errorf("unable to parse source URL '%s': %v", redirect.sourceURL, err)
} }
fmt.Printf("edit \"%s\"\n", redirect.sourceURL) var ruleName string
if len(redirect.sourceURL) > 63 { // FortiOS only allows up to 63 characters
ruleName = redirect.sourceURL[:62]
} else {
ruleName = redirect.sourceURL
}
fmt.Println("set action redirect") fmt.Println("set action redirect")
fmt.Printf("set location %s\n", redirect.destinationURL) fmt.Printf("set location %s\n", redirect.destinationURL)
fmt.Println("set action redirect") fmt.Println("set action redirect")
@ -39,7 +44,7 @@ func config(redirects []Redirect) error {
fmt.Println("next") fmt.Println("next")
// Add this rule to the policy map // Add this rule to the policy map
redirectPolicies[sourceURL.Host] = append(redirectPolicies[sourceURL.Host], redirect.sourceURL) redirectPolicies[sourceURL.Host] = append(redirectPolicies[sourceURL.Host], ruleName)
} }
fmt.Println("end") fmt.Println("end")