File tree 1 file changed +11
-8
lines changed
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"
2
2
local get_request = base .get_request
3
3
local ffi = require " ffi"
4
4
local C = ffi .C
5
- local ffi_new = ffi .new
6
5
local ffi_str = ffi .string
7
6
local ffi_gc = ffi .gc
8
7
local FFI_OK = base .FFI_OK
@@ -47,18 +46,22 @@ local mt = {
47
46
local Ctx = ffi .metatype (" ngx_http_lua_resolver_ctx_t" , mt )
48
47
49
48
function _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
-
54
49
local buf = get_string_buf (BUF_SIZE )
55
50
local buf_size = get_size_ptr ()
56
51
buf_size [0 ] = BUF_SIZE
57
52
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
59
61
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
62
65
63
66
local rc = C .ngx_http_lua_ffi_resolve (ctx , hostname )
64
67
You can’t perform that action at this time.
0 commit comments