diff --git a/app.go b/app.go index 2b73e58b465681b076946ca998736fef619c2021..83af9461877583f1489933882c0d75e6a10d70e6 100644 --- a/app.go +++ b/app.go @@ -3,6 +3,7 @@ package main import ( "fmt" "log" + "net" "os" "sync/atomic" "time" @@ -73,5 +74,13 @@ func serve(sig chan os.Signal, db *leveldb.DB) error { } }() - return app.Listen(conf[listenAddr]) + if conf[listen] == "unset" { + return app.Listen(conf[listenAddr]) + } else { + if l, err := net.Listen("unix", conf[listen]); err != nil { + return err + } else { + return app.Listener(l) + } + } } diff --git a/conf.go b/conf.go index a95b71fafe42fc5bae60d13befa533a67b89674b..c31d17e782b81554ad12559cb10dfc1ac4c05161 100644 --- a/conf.go +++ b/conf.go @@ -7,6 +7,7 @@ import ( const ( dbPath uint8 = iota + listen listenAddr allowedURL hCaptchaSiteKey @@ -17,6 +18,7 @@ const ( // env variable, default pairing var confEnv = [...][2]string{ dbPath: {"DB", "db"}, + listen: {"LISTEN", "unset"}, listenAddr: {"LISTEN_ADDR", "127.0.0.1:3000"}, allowedURL: {"ALLOWED_URL", "https://hizla.io"}, hCaptchaSiteKey: {"HCAPTCHA_SITE_KEY", "unset"},