<commit_before>local arp = require "proto.arp"

local dependency = {}

function dependency.env(env)
  function env.arp(ip, fallback, timeout)
    return { "arp", ip, fallback, timeout or 5 }
  end
end

function dependency.debug(tbl)
  local addr = tbl[2]
  if type(addr) == "number" then
    addr = ip4ToString(addr) -- luacheck: read globals ip4ToString
  elseif type(addr) == "cdata" then
    addr = addr:getString(true)
  end
  return string.format("Arp result for ip '%s'.", addr)
end

function dependency.getValue(_, tbl)
  return nil -- TODO arp.blockingLookup(tbl[2], tbl[4]) or tbl[3]
end

return dependency<commit_msg>Add support for printing arp fallback.<commit_after>local arp = require "proto.arp"

local dependency = {}

function dependency.env(env)
	function env.arp(ip, fallback, timeout)
		return { "arp", ip, fallback, timeout or 5 }
	end
end

local function macString(addr)
	if type(addr) == "number" then
		local mac = require("ffi").new("union mac_address")
		mac:set(addr)
		return mac:getString()
	elseif type(addr) == "cdata" then
		return addr:getString()
	end

	return addr
end

function dependency.debug(tbl)
	local addr = tbl[2]
	if type(addr) == "number" then
		addr = ip4ToString(addr) -- luacheck: read globals ip4ToString
	elseif type(addr) == "cdata" then
		addr = addr:getString(true)
	end

	if tbl[3] then
		return string.format("Arp result for ip '%s', fallback to '%s'.", addr, macString(tbl[3]))
	else
		return string.format("Arp result for ip '%s'.", addr)
	end
end

function dependency.getValue(_, tbl)
	return nil -- TODO arp.blockingLookup(tbl[2], tbl[4]) or tbl[3]
end

return dependency
{'fraction_non_alphanumeric': 0.13067484662576687, 'fraction_numerical': 0.0098159509202454, 'mean_word_length': 4.4366666666666665, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6487108', 'n_tokens_mistral': 571, 'n_tokens_neox': 549, 'n_words': 172}