File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ local base = require "resty.core.base"
22local get_request = base .get_request
33local ffi = require " ffi"
44local C = ffi .C
5- local ffi_new = ffi .new
65local ffi_str = ffi .string
76local ffi_gc = ffi .gc
87local FFI_OK = base .FFI_OK
@@ -47,18 +46,22 @@ local mt = {
4746local Ctx = ffi .metatype (" ngx_http_lua_resolver_ctx_t" , mt )
4847
4948function _M .resolve (hostname , ipv4 , ipv6 )
50- assert (type (hostname ) == " string" , " hostname must be string" )
51- assert (ipv4 == nil or type (ipv4 ) == " boolean" , " ipv4 must be boolean or nil" )
52- assert (ipv6 == nil or type (ipv6 ) == " boolean" , " ipv6 must be boolean or nil" )
53-
5449 local buf = get_string_buf (BUF_SIZE )
5550 local buf_size = get_size_ptr ()
5651 buf_size [0 ] = BUF_SIZE
5752
58- local ctx = Ctx ({get_request (), buf , buf_size })
53+ local ctx = Ctx ()
54+ ctx .request = get_request ()
55+ ctx .buf = buf
56+ ctx .buf_size = buf_size
57+
58+ if ipv4 == nil or ipv4 then
59+ ctx .ipv4 = 1
60+ end
5961
60- ctx .ipv4 = ipv4 == nil and 1 or ipv4
61- ctx .ipv6 = ipv6 == nil and 0 or ipv6
62+ if ipv6 then
63+ ctx .ipv6 = 1
64+ end
6265
6366 local rc = C .ngx_http_lua_ffi_resolve (ctx , hostname )
6467
You can’t perform that action at this time.
0 commit comments