]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
modules/http: allow passing server options to http configuration
authorMarek Vavruša <mvavrusa@cloudflare.com>
Tue, 6 Mar 2018 22:29:45 +0000 (14:29 -0800)
committerMarek Vavruša <mvavrusa@cloudflare.com>
Fri, 7 Sep 2018 17:45:21 +0000 (10:45 -0700)
This allows HTTP server to start with reuseport, reuseaddr or v6only.
The reuseport allows running HTTP module on all forks, not just the main one.

modules/http/http.lua
modules/http/http.test.lua

index c0df9400416160a444d848d25c5ab6bd7178180f..e4baf8fdde5cfd38aa114a5afd5723eefebd5074 100644 (file)
@@ -391,12 +391,7 @@ function M.config(conf)
                end
        end
 
-       -- Add endpoints to default endpoints
-       local endpoints = conf.endpoints or {}
-       for k, v in pairs(M.endpoints) do
-               endpoints[k] = v
-       end
-       M.interface(conf.host, conf.port, endpoints, conf.cert, conf.key)
+       M.add_interface(conf)
 end
 
 return M
index 198dd0abf2417024ec390c983131469df8d57721..e22024b9be7e068378d6c125d6c35e4dd6b0a521 100644 (file)
@@ -5,13 +5,17 @@ if not has_http then
        done()
 else
        local request = require('http.request')
+       local endpoints = require('http').endpoints
+
+       -- custom endpoints
+       endpoints['/test'] = {'text/custom', function () return 'hello' end}
 
        -- setup resolver
        modules = {
                http = {
                        port = 0, -- Select random port
                        cert = false,
-                       endpoints = { ['/test'] = {'text/custom', function () return 'hello' end} },
+                       endpoints = endpoints,
                }
        }