Commit b67e2dd2 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Support listening on Unix domain sockets

parent e34d9bc4
...@@ -19,6 +19,7 @@ import ( ...@@ -19,6 +19,7 @@ import (
"fmt" "fmt"
"io" "io"
"log" "log"
"net"
"net/http" "net/http"
"os" "os"
"os/exec" "os/exec"
...@@ -47,6 +48,7 @@ var pathTraversal = regexp.MustCompile(`/../`) ...@@ -47,6 +48,7 @@ var pathTraversal = regexp.MustCompile(`/../`)
var repoRoot string var repoRoot string
var printVersion = flag.Bool("version", false, "Print version and exit") var printVersion = flag.Bool("version", false, "Print version and exit")
var listenAddr = flag.String("listenAddr", "localhost:8181", "Listen address for HTTP server") var listenAddr = flag.String("listenAddr", "localhost:8181", "Listen address for HTTP server")
var listenNetwork = flag.String("listenNetwork", "tcp", "Listen 'network' (protocol)")
var authBackend = flag.String("authBackend", "http://localhost:8080", "Authentication/authorization backend") var authBackend = flag.String("authBackend", "http://localhost:8080", "Authentication/authorization backend")
var gitServices = [...]gitService{ var gitServices = [...]gitService{
...@@ -75,7 +77,11 @@ func main() { ...@@ -75,7 +77,11 @@ func main() {
log.Printf("repoRoot: %s", repoRoot) log.Printf("repoRoot: %s", repoRoot)
http.HandleFunc("/", gitHandler) http.HandleFunc("/", gitHandler)
log.Fatal(http.ListenAndServe(*listenAddr, nil)) listener, err := net.Listen(*listenNetwork, *listenAddr)
if err != nil {
log.Fatal(err)
}
log.Fatal(http.Serve(listener, nil))
} }
func gitHandler(w http.ResponseWriter, r *http.Request) { func gitHandler(w http.ResponseWriter, r *http.Request) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment