diff --git a/main.go b/main.go index 0da35ab..842bb0b 100644 --- a/main.go +++ b/main.go @@ -48,6 +48,21 @@ func loadConfig() (err error) { err = yaml.Unmarshal(configfile, &config) + // todo: check for bad data !! + + var re = regexp.MustCompile(`(((ftp|http|https):\/\/)|(\/)|(..\/))(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?`) + tocheck := [2]string{config.Panel.Host, config.Auth.GiteaURL} + + for _, val := range tocheck { + if len(re.FindStringIndex(val)) == 0 { + log.Fatalf(`"%s" is not a valid url.`, val) + } + } + + if config.Panel.Port > 65535 { + log.Fatalf("port is too big (max 65535)") + } + // init oauth bits redirecturi = fmt.Sprintf("%s/login/endpoint", config.Panel.Host) requesturl = fmt.Sprintf("%s/login/oauth/authorize?client_id=%s&redirect_uri=%s&response_type=code&state=STATE",