1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-22 08:35:57 +01:00

Allow running the web server on a Unix domain socket.

Thanks to Martin Pépin.
This commit is contained in:
Juliusz Chroboczek 2022-08-04 18:36:07 +02:00
parent b821cd71a9
commit dcb370677f

View file

@ -9,6 +9,7 @@ import (
"html"
"io"
"log"
"net"
"net/http"
"net/url"
"os"
@ -72,12 +73,21 @@ func Serve(address string, dataDir string) error {
server.Store(s)
var err error
proto := "tcp"
if strings.HasPrefix(address, "/") {
proto = "unix"
}
listener, err := net.Listen(proto, address)
if err != nil {
return err
}
defer listener.Close()
if !Insecure {
err = s.ListenAndServeTLS("", "")
err = s.ServeTLS(listener, "", "")
} else {
err = s.ListenAndServe()
err = s.Serve(listener)
}
if err == http.ErrServerClosed {