Skip to content

Commit 2a84831

Browse files
committed
on ipv6 hostname remove brackets for correct getRelayData response object
1 parent f9639f6 commit 2a84831

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

lib/tools.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,12 @@ function getRelayData(url) {
390390
} catch {
391391
urlparts = {};
392392
}
393+
let hostname = urlparts.hostname || '';
394+
if (/^\[[^\]]+\]$/.test(hostname)) {
395+
hostname = hostname.slice(1, -1);
396+
}
393397
let targetMx = {
394-
host: urlparts.hostname,
398+
host: hostname,
395399
port: urlparts.port || 25,
396400
auth:
397401
urlparts.username || urlparts.password
@@ -401,8 +405,8 @@ function getRelayData(url) {
401405
}
402406
: false,
403407
secure: urlparts.protocol === 'smtps:',
404-
A: [].concat(net.isIPv4(urlparts.hostname) ? urlparts.hostname : []),
405-
AAAA: [].concat(net.isIPv6(urlparts.hostname) ? urlparts.hostname : [])
408+
A: [].concat(net.isIPv4(hostname) ? hostname : []),
409+
AAAA: [].concat(net.isIPv6(hostname) ? hostname : [])
406410
};
407411
let data = {
408412
mx: [

0 commit comments

Comments
 (0)