]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
modules/http: allow listening on UNIX sockets
authorMarek Vavruša <mvavrusa@cloudflare.com>
Wed, 29 Aug 2018 22:35:20 +0000 (15:35 -0700)
committerMarek Vavruša <mvavrusa@cloudflare.com>
Fri, 7 Sep 2018 17:45:21 +0000 (10:45 -0700)
modules/http/http.lua

index a81935997ce828711d8abf4398fd3475e85ef824..7fdf96db513c95513f1f46ffd247ec6289c17549 100644 (file)
@@ -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