mirror of
https://github.com/jech/galene.git
synced 2024-11-22 08:35:57 +01:00
Make https optional.
This commit is contained in:
parent
2dcfe9ad8d
commit
fece9287e2
2 changed files with 15 additions and 4 deletions
|
@ -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/",
|
||||
|
|
|
@ -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(
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue