mirror of
https://github.com/jech/galene.git
synced 2024-11-22 16:45:58 +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`")
|
"web server root `directory`")
|
||||||
flag.StringVar(&webserver.Redirect, "redirect", "",
|
flag.StringVar(&webserver.Redirect, "redirect", "",
|
||||||
"redirect to canonical `host`")
|
"redirect to canonical `host`")
|
||||||
|
flag.BoolVar(&webserver.Insecure, "insecure", false,
|
||||||
|
"act as an HTTP server rather than HTTPS")
|
||||||
flag.StringVar(&dataDir, "data", "./data/",
|
flag.StringVar(&dataDir, "data", "./data/",
|
||||||
"data `directory`")
|
"data `directory`")
|
||||||
flag.StringVar(&group.Directory, "groups", "./groups/",
|
flag.StringVar(&group.Directory, "groups", "./groups/",
|
||||||
|
|
|
@ -33,6 +33,8 @@ var StaticRoot string
|
||||||
|
|
||||||
var Redirect string
|
var Redirect string
|
||||||
|
|
||||||
|
var Insecure bool
|
||||||
|
|
||||||
func Serve(address string, dataDir string) error {
|
func Serve(address string, dataDir string) error {
|
||||||
http.Handle("/", &fileHandler{http.Dir(StaticRoot)})
|
http.Handle("/", &fileHandler{http.Dir(StaticRoot)})
|
||||||
http.HandleFunc("/group/", groupHandler)
|
http.HandleFunc("/group/", groupHandler)
|
||||||
|
@ -68,10 +70,17 @@ func Serve(address string, dataDir string) error {
|
||||||
|
|
||||||
server.Store(s)
|
server.Store(s)
|
||||||
|
|
||||||
err := s.ListenAndServeTLS(
|
var err error
|
||||||
filepath.Join(dataDir, "cert.pem"),
|
|
||||||
filepath.Join(dataDir, "key.pem"),
|
if !Insecure {
|
||||||
)
|
err = s.ListenAndServeTLS(
|
||||||
|
filepath.Join(dataDir, "cert.pem"),
|
||||||
|
filepath.Join(dataDir, "key.pem"),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
err = s.ListenAndServe()
|
||||||
|
}
|
||||||
|
|
||||||
if err == http.ErrServerClosed {
|
if err == http.ErrServerClosed {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue