tokers commented on a change in pull request #2926: URL: https://github.com/apache/apisix/pull/2926#discussion_r537174850
########## File path: apisix/core/utils.lua ########## @@ -203,6 +209,26 @@ function _M.validate_header_value(value) end +function _M.gethostname() + if hostname then + return hostname + end + + local buf = get_string_buf(max_hostname_len) + + if C.gethostname(buf, max_hostname_len) == 0 then + buf[max_hostname_len - 1] = str_byte('\0') + hostname = ffi_string(buf, ffi.C.strlen(buf)) + + else + log.alert("ffi.C.gethostname() failed") Review comment: That'd be concise, i will try it. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org