Software /
code /
prosody
Comparison
net/resolvers/basic.lua @ 11007:1d8e1f7a587c 0.11
net.resolvers.basic: Default conn_type to 'tcp' consistently if unspecified (thanks marc0s)
Fixes a traceback when passed an IP address with no conn_type.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 10 Jul 2020 13:00:02 +0100 |
parent | 10439:97c0f5fe5f41 |
child | 11008:fd735fe2fc50 |
comparison
equal
deleted
inserted
replaced
10994:e2ce067bb59a | 11007:1d8e1f7a587c |
---|---|
56 end | 56 end |
57 | 57 |
58 local function new(hostname, port, conn_type, extra) | 58 local function new(hostname, port, conn_type, extra) |
59 local ascii_host = idna_to_ascii(hostname); | 59 local ascii_host = idna_to_ascii(hostname); |
60 local targets = nil; | 60 local targets = nil; |
61 conn_type = conn_type or "tcp"; | |
61 | 62 |
62 local is_ip = inet_pton(hostname); | 63 local is_ip = inet_pton(hostname); |
63 if not is_ip and hostname:sub(1,1) == '[' then | 64 if not is_ip and hostname:sub(1,1) == '[' then |
64 is_ip = inet_pton(hostname:sub(2,-2)); | 65 is_ip = inet_pton(hostname:sub(2,-2)); |
65 end | 66 end |
73 end | 74 end |
74 | 75 |
75 return setmetatable({ | 76 return setmetatable({ |
76 hostname = ascii_host; | 77 hostname = ascii_host; |
77 port = port; | 78 port = port; |
78 conn_type = conn_type or "tcp"; | 79 conn_type = conn_type; |
79 extra = extra; | 80 extra = extra; |
80 targets = targets; | 81 targets = targets; |
81 }, resolver_mt); | 82 }, resolver_mt); |
82 end | 83 end |
83 | 84 |