Jump to content

IPv6 issue with hostname and reverse lookups


davygrvy

Recommended Posts

Posted

uTorrent is 1.8.1 build 12642

OS is Win2000 sp4 with the ipv6 preview patch (yes, it's old)

If the tracker is http://ipv6.torrent.ubuntu.com:6969/announce, the trackers tab reports its status as 'hostname not found'. But if I do a manual lookup with: "nslookup -type=AAAA ipv6.torrent.ubuntu.com" and replace the hostname with the address directly (http://[2001:7b8:3:37:0:0:21:2]:6969/announce) it all works.

I bet there's a difference with getaddrinfo() and getnameinfo() with ipv6 preview patch that uT is exercising.

Although uT works fine on my XP computer doing the forward lookup of the above example, uT doesn't reverse resolve v6 addresses either.

I posted this in the troubleshooting forum, but didn't get much traction there.

Posted

We don't support IPv6 on 2000. Reposting your issue here is not going to make us support it.

as for reverse lookups, they should work if the address actually has a PTR record. Try 1.8.1 and 1.9.

Posted

1.9 build 13485 has the same not working behavior on Win2k fore and back are both broke. I'll test reverse v6 on XP on Monday.

Here's a code sample how to do lookups:

isIpRE_IPv4 = Tcl_NewStringObj("^((25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3})$", -1);

Tcl_IncrRefCount(isIpRE_IPv4);

isIpRE_IPv6 = Tcl_NewStringObj("^((?:[[:xdigit:]]{1,4}:){7}[[:xdigit:]]{1,4})$", -1);

Tcl_IncrRefCount(isIpRE_IPv6);

isIpRE_IPv6Comp = Tcl_NewStringObj("^((?:[[:xdigit:]]{1,4}(?::[[:xdigit:]]{1,4})*)?)::((?:[[:xdigit:]]{1,4}(?::[[:xdigit:]]{1,4})*)?)$", -1);

Tcl_IncrRefCount(isIpRE_IPv6Comp);

isIpRE_4in6 = Tcl_NewStringObj("^(((?:[[:xdigit:]]{1,4}:){6,6})(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3})$", -1);

Tcl_IncrRefCount(isIpRE_4in6);

isIpRE_4in6Comp = Tcl_NewStringObj("^(((?:[[:xdigit:]]{1,4}(?::[[:xdigit:]]{1,4})*)?)::((?:[[:xdigit:]]{1,4}:)*)(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3})$", -1);

Tcl_IncrRefCount(isIpRE_4in6Comp);

int

isIp (Tcl_Obj *name)

{

int a, b, c, d, e;

a = Tcl_RegExpMatchObj(NULL, name, isIpRE_IPv4);

b = Tcl_RegExpMatchObj(NULL, name, isIpRE_IPv6);

c = Tcl_RegExpMatchObj(NULL, name, isIpRE_IPv6Comp);

d = Tcl_RegExpMatchObj(NULL, name, isIpRE_4in6);

e = Tcl_RegExpMatchObj(NULL, name, isIpRE_4in6Comp);

if (a || b || c || d || e) {

return 1;

}

return 0;

}

use AF_UNSPEC for addressFamily if you want both/either AF_INET and AF_INET6.

void

Do_IP_Work (int addressFamily, Tcl_Obj *question)

{

struct addrinfo hints;

struct addrinfo *hostaddr, *addr;

int result, type, len;

CONST char *utf8Chars;

Tcl_Obj *answers;

Tcl_DString dnsTxt;

Tcl_Encoding dnsEnc;

memset(&hints, 0, sizeof(struct addrinfo));

hints.ai_flags = 0;

hints.ai_family = addressFamily;

hints.ai_socktype = 0;

hints.ai_protocol = 0;

/*

* See: ftp://ftp.rfc-editor.org/in-notes/rfc3490.txt

*/

dnsEnc = Tcl_GetEncoding(NULL, "ascii");

Tcl_DStringInit(&dnsTxt);

utf8Chars = Tcl_GetStringFromObj(question, &len);

Tcl_UtfToExternalDString(dnsEnc, utf8Chars, len, &dnsTxt);

if ((result = getaddrinfo(Tcl_DStringValue(&dnsTxt), NULL, &hints,

&hostaddr)) != 0) {

#ifdef __WIN32__

Tcl_DStringAppend(&dnsTxt, " failed to resolve.", -1);

SendWinErrorData(405, Tcl_DStringValue(&dnsTxt), WSAGetLastError());

#else

/* TODO */

#endif

goto error1;

}

answers = Tcl_NewObj();

if (isIp(question)) {

/* question was a numeric IP, return a hostname. */

type = NI_NAMEREQD;

} else {

/* question was a hostname, return a numeric IP. */

type = NI_NUMERICHOST;

}

addr = hostaddr;

while (addr != NULL) {

char hostStr[NI_MAXHOST];

int err;

err = getnameinfo(addr->ai_addr, addr->ai_addrlen, hostStr,

NI_MAXHOST, NULL, 0, type);

if (err == 0) {

Tcl_ExternalToUtfDString(dnsEnc, hostStr, -1, &dnsTxt);

Tcl_ListObjAppendElement(NULL, answers,

Tcl_NewStringObj(Tcl_DStringValue(&dnsTxt),

Tcl_DStringLength(&dnsTxt)));

} else {

#ifdef __WIN32__

SendWinErrorData(406, "lookup failed on getnameinfo()", WSAGetLastError());

#else

/* TODO */

#endif

goto error2;

}

addr = addr->ai_next;

}

/* reply with answers */

SendAnswers(question, answers);

error2:

freeaddrinfo(hostaddr);

error1:

Tcl_DStringFree(&dnsTxt);

return;

}

Firon, Here's an example of an ipv6 host that does have a PTR record, but uT on XP does not reverse resolve:

C:\Documents and Settings\davygrvy>nslookup -type=aaaa davygrvy-pt.tunnel.tserv3

.fmt2.ipv6.he.net

Server: cns.sanjose.ca.sanfran.comcast.net

Address: 68.87.76.178

Non-authoritative answer:

davygrvy-pt.tunnel.tserv3.fmt2.ipv6.he.net AAAA IPv6 address = 2001:470:1f0

4:ed:0:0:0:2

C:\Documents and Settings\davygrvy>nslookup -type=ptr 2.0.0.0.0.0.0.0.0.0.0.0.0.

0.0.0.d.e.0.0.4.0.f.1.0.7.4.0.1.0.0.2.ip6.arpa

Server: cns.sanjose.ca.sanfran.comcast.net

Address: 68.87.76.178

Non-authoritative answer:

2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.e.0.0.4.0.f.1.0.7.4.0.1.0.0.2.ip6.arpa

name = davygrvy-pt.tunnel.tserv3.fmt2.ipv6.he.net

C:\Documents and Settings\davygrvy>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...