diff --git a/galene.go b/galene.go index ea72150..9ce9a57 100644 --- a/galene.go +++ b/galene.go @@ -24,6 +24,8 @@ func main() { "web server root `directory`") flag.StringVar(&webserver.Redirect, "redirect", "", "redirect to canonical `host`") + flag.BoolVar(&webserver.Insecure, "insecure", false, + "act as an HTTP server rather than HTTPS") flag.StringVar(&dataDir, "data", "./data/", "data `directory`") flag.StringVar(&group.Directory, "groups", "./groups/", diff --git a/webserver/webserver.go b/webserver/webserver.go index c98ddfb..8ab8ad7 100644 --- a/webserver/webserver.go +++ b/webserver/webserver.go @@ -33,6 +33,8 @@ var StaticRoot string var Redirect string +var Insecure bool + func Serve(address string, dataDir string) error { http.Handle("/", &fileHandler{http.Dir(StaticRoot)}) http.HandleFunc("/group/", groupHandler) @@ -68,10 +70,17 @@ func Serve(address string, dataDir string) error { server.Store(s) - err := s.ListenAndServeTLS( - filepath.Join(dataDir, "cert.pem"), - filepath.Join(dataDir, "key.pem"), - ) + var err error + + if !Insecure { + err = s.ListenAndServeTLS( + filepath.Join(dataDir, "cert.pem"), + filepath.Join(dataDir, "key.pem"), + ) + } else { + err = s.ListenAndServe() + } + if err == http.ErrServerClosed { return nil }