mirror of
https://github.com/jech/galene.git
synced 2024-11-13 20:25:57 +01:00
Allow running the web server on a Unix domain socket.
Thanks to Martin Pépin.
This commit is contained in:
parent
b821cd71a9
commit
dcb370677f
1 changed files with 13 additions and 3 deletions
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue