From 98e842b9c78f231997632666429094fc07e6c939 Mon Sep 17 00:00:00 2001 From: Jianhui Zhao Date: Wed, 13 Mar 2024 14:22:02 +0800 Subject: [PATCH] feat(http): add an option `mark` to set SO_MARK Signed-off-by: Jianhui Zhao --- http/client.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/http/client.lua b/http/client.lua index 58d2421..a953a44 100644 --- a/http/client.lua +++ b/http/client.lua @@ -358,7 +358,10 @@ function methods:request(method, url, body, opts) headers[k:lower()] = v end - local answers, err = dns.query(host, { type = opts.ipv6 and dns.TYPE_AAAA or dns.TYPE_A }) + local answers, err = dns.query(host, { + type = opts.ipv6 and dns.TYPE_AAAA or dns.TYPE_A, + mark = opts.mark + }) if not answers then return nil, 'resolve "' .. host .. '" fail: ' .. err end @@ -426,6 +429,7 @@ end insecure: A boolean, SSL connecting with insecure. ipv6: A boolean, parse ipv6 address for host. body_to_file: A string indicates that the body is to be written to the file. + mark: a number used to set SO_MARK to socket In case of failure, the function returns nil followed by an error message. If successful, returns a table contains the