1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-14 12:45:58 +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" "html"
"io" "io"
"log" "log"
"net"
"net/http" "net/http"
"net/url" "net/url"
"os" "os"
@ -72,12 +73,21 @@ func Serve(address string, dataDir string) error {
server.Store(s) 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 { if !Insecure {
err = s.ListenAndServeTLS("", "") err = s.ServeTLS(listener, "", "")
} else { } else {
err = s.ListenAndServe() err = s.Serve(listener)
} }
if err == http.ErrServerClosed { if err == http.ErrServerClosed {