From 1bfcc61a92c252c65c405451542f4ff7191020e9 Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 11 Jan 2018 14:59:33 +0100 Subject: [PATCH] Fixed issues with ensuring appropriate hostName's are FQDN (absolute) --- src/dorkbox/network/dns/DnsQuestion.java | 46 ++++++++----------- .../network/dns/constants/DnsRecordType.java | 36 +++++++++++++++ 2 files changed, 56 insertions(+), 26 deletions(-) diff --git a/src/dorkbox/network/dns/DnsQuestion.java b/src/dorkbox/network/dns/DnsQuestion.java index 87fd67cc..95899426 100644 --- a/src/dorkbox/network/dns/DnsQuestion.java +++ b/src/dorkbox/network/dns/DnsQuestion.java @@ -54,29 +54,31 @@ class DnsQuestion extends DnsMessage implements AddressedEnvelope ip address, the hostname MUST end in a dot - hostname = appendTrailingDot(hostname); - } - try { - DnsRecord questionRecord = DnsRecord.newRecord(Name.fromString(hostname), type, DnsClass.IN); + DnsRecord questionRecord = DnsRecord.newRecord(name, type, DnsClass.IN); DnsQuestion question = new DnsQuestion(isResolveQuestion); question.getHeader() .setOpcode(DnsOpCode.QUERY); @@ -92,23 +94,23 @@ class DnsQuestion extends DnsMessage implements AddressedEnvelope ip address, the hostname MUST end in a dot + if (!StringUtil.endsWith(hostName, '.')) { + return hostName + '.'; + } else { + return hostName; + } + + default: + return hostName; + } + } }