Skip to content

Commit

Permalink
remove ffi imports
Browse files Browse the repository at this point in the history
  • Loading branch information
omegabytes committed Dec 10, 2022
1 parent 739a308 commit 5f2ce54
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions lua-tree/share/lua/5.1/kong/pdk/node.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
-- @module kong.node

local utils = require "kong.tools.utils"
local ffi = require "ffi"
local private_node = require "kong.pdk.private.node"


Expand All @@ -15,9 +14,6 @@ local sort = table.sort
local insert = table.insert
local ngx = ngx
local shared = ngx.shared
local C = ffi.C
local ffi_new = ffi.new
local ffi_str = ffi.string

local NODE_ID_KEY = "kong:node_id"

Expand Down Expand Up @@ -234,16 +230,6 @@ local function new(self)
-- @usage
-- local hostname = kong.node.get_hostname()
function _NODE.get_hostname()
local SIZE = 253 -- max number of chars for a hostname

local buf = ffi_new("unsigned char[?]", SIZE)
local res = C.gethostname(buf, SIZE)

if res == 0 then
local hostname = ffi_str(buf, SIZE)
return gsub(hostname, "%z+$", "")
end

local f = io.popen("/bin/hostname")
local hostname = f:read("*a") or ""
f:close()
Expand Down

0 comments on commit 5f2ce54

Please sign in to comment.