mirror of
https://github.com/lunarmodules/luasocket.git
synced 2025-07-12 22:03:31 +02:00
Fix. getaddrinfo returns garbage as address on Windows.
Add. test_getaddrinfo.lua
This commit is contained in:
15
test/test_getaddrinfo.lua
Normal file
15
test/test_getaddrinfo.lua
Normal file
@ -0,0 +1,15 @@
|
||||
local socket = require "socket"
|
||||
local addresses = assert(socket.dns.getaddrinfo("localhost"))
|
||||
assert(type(addresses) == 'table')
|
||||
|
||||
local ipv4mask = "^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?$"
|
||||
|
||||
for i, alt in ipairs(addresses) do
|
||||
if alt.family == 'inet' then
|
||||
assert(type(alt.addr) == 'string')
|
||||
assert(alt.addr:find(ipv4mask))
|
||||
assert(alt.addr == '127.0.0.1')
|
||||
end
|
||||
end
|
||||
|
||||
print("done!")
|
Reference in New Issue
Block a user