local function replace_host_to_ipv4( url) local function url_to_host(url) return (url.."/"):match("://(.-)/") end local host = url_to_host(url) local ip_addresses = socket.dns.getaddrinfo(host) local ipv4_address = nil local ipv6_detected = false for i, v in ipairs(ip_addresses) do if v.family == "inet" then if ipv6_detected then ipv4_address = v.addr end break end if v.family == "inet6" then ipv6_detected = true end end if ipv4_address then local result = string.gsub(url, host, ipv4_address) if result then return result end end return url end