From: Marek VavruĊĦa Date: Wed, 29 Aug 2018 22:35:20 +0000 (-0700) Subject: modules/http: allow listening on UNIX sockets X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=99a3f9b77b41fc88c75153cac229fc1f3a7ca232;p=thirdparty%2Fknot-resolver.git modules/http: allow listening on UNIX sockets --- diff --git a/modules/http/http.lua b/modules/http/http.lua index a81935997..7fdf96db5 100644 --- a/modules/http/http.lua +++ b/modules/http/http.lua @@ -310,12 +310,26 @@ function M.add_interface(conf) warn('[http] the "reuseport" option is disabled and multiple forks are used, ' .. 'port binding will fail on some instances') end + -- Check if UNIX socket path is used + local addr_str + if not conf.path then + conf.host = conf.host or 'localhost' + conf.port = conf.port or 8053 + addr_str = string.format('%s@%d', conf.host, conf.port) + else + if conf.host or conf.port then + error('either "path", or "host" and "port" must be provided') + end + addr_str = conf.path + end -- Create TLS context and start listening local s, err = http_server.listen { cq = worker.bg_worker.cq, - host = conf.host or 'localhost', - port = conf.port or 8053, + host = conf.host, + port = conf.port, + path = conf.path, v6only = conf.v6only, + unlink = conf.unlink, reuseaddr = conf.reuseaddr, reuseport = reuseport, client_timeout = conf.client_timeout or 5, @@ -338,7 +352,7 @@ function M.add_interface(conf) err = select(2, s:listen()) end if err then - panic('failed to listen on %s@%d: %s', conf.host, conf.port, err) + panic('failed to listen on %s: %s', addr_str, err) end table.insert(M.servers, s) -- Create certificate renewal timer if ephemeral