You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.1 KiB
Go

1 year ago
package Configuration
// Imports
import (
"errors"
"net"
"os"
)
// Validate Configurations
func ValidateConfigurations(configurations []Configuration) error {
// Configuration Number
var configurationNumber uint
// Configurations
for configurationNumber = 0; configurationNumber < uint(len(configurations)); configurationNumber++ {
// Validate Domain
_, err := net.LookupHost(configurations[configurationNumber].Domain)
// Handle Error
if err != nil {
return err
}
// Certificate
item, err := os.Stat(configurations[configurationNumber].TLSCertificate)
// Handle Error
if err != nil {
return err
}
// Check File
if item.IsDir() == true {
return errors.New("Error TLSCertificate Is Not A File")
}
// Key
item, err = os.Stat(configurations[configurationNumber].TLSKey)
// Handle Error
if err != nil {
return err
}
// Check File
if item.IsDir() == true {
return errors.New("Error TLSKey Is Not A File")
}
// Validate File Server
err = validateFileServer(configurations[configurationNumber].FileServer)
// Handle Error
if err != nil {
return err
}
}
// Return
return nil
}