Tcl Library Source Code

View Ticket
Login
Ticket UUID: 8168daf796e4cc2a843f4d1a4f2f38e348197945
Title: make reverse lookup of IPv6 addresses work
Type: RFE Version: 1.19
Submitter: buzzdeee Created on: 2019-06-13 10:53:11
Subsystem: dns Assigned To: aku
Priority: 6 Severity: Important
Status: Closed Last Modified: 2019-11-19 07:42:59
Resolution: Accepted Closed By: aku
    Closed on: 2019-11-19 07:42:59
Description:

using

[dns::resolve AN_IPv6_ADDRESS]
currently leads to an error.
this patch against modules/dns/dns.tcl below makes it work for me:
--- dns.tcl.orig	Thu Jun 13 12:34:10 2019
+++ dns.tcl	Thu Jun 13 12:38:02 2019
@@ -286,10 +286,17 @@
         }
     }
 
-    # Check for reverse lookups
+    # Check for reverse lookups, IPv4 first, then IPv6
     if {[regexp {^(?:\d{0,3}\.){3}\d{0,3}$} $state(query)]} {
         set addr [lreverse [split $state(query) .]]
         lappend addr in-addr arpa
+        set state(query) [join $addr .]
+        set state(-type) PTR
+    } elseif {[string match {*:*} $state(query)]} {
+        set addr [ip::normalize $state(query)]
+        set addr [split [string reverse $addr] :]
+        set addr [join [split [join $addr ""] {}] .]
+        lappend addr ip6 arpa
         set state(query) [join $addr .]
         set state(-type) PTR
     }

similarily to checking if we got an IPv4 address, check if the query contains a colon. Checking if it contains a colon should be sufficient, since IPv4 addresses don't contain colons, as well as they are not allowed in hostnames. Once an IPv6 address is identified, normalize it, and format the query appropriately.

User Comments: aku added on 2019-11-19 07:42:59:
Integrated, commit [620ac0d5eb].

Attachments: