add support for redirect types in config

This commit is contained in:
Steven Polley 2020-05-29 21:00:52 -06:00
parent 0b58316916
commit d9ab7e77c1

View File

@ -24,15 +24,22 @@ 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)
} }
var ruleName string var ruleName, action string
if len(redirect.sourceURL) > 63 { // FortiOS only allows up to 63 characters if len(redirect.sourceURL) > 63 { // FortiOS only allows up to 63 characters
ruleName = redirect.sourceURL[:62] ruleName = redirect.sourceURL[:62]
} else { } else {
ruleName = redirect.sourceURL ruleName = redirect.sourceURL
} }
if redirect.statusCode == 301 { //translate to fortiOS syntax
action = "redirect-301"
} else {
action = "redirect"
}
fmt.Printf("edit \"%s\"\n", ruleName) fmt.Printf("edit \"%s\"\n", ruleName)
fmt.Printf("set location %s\n", redirect.destinationURL) fmt.Printf("set location %s\n", redirect.destinationURL)
fmt.Println("set action redirect") fmt.Printf("set action %s\n", action)
fmt.Println("config match-condition") fmt.Println("config match-condition")
fmt.Println("edit 0") fmt.Println("edit 0")
fmt.Println("set object http-url") fmt.Println("set object http-url")