mirror of
https://github.com/rfc1036/whois.git
synced 2026-05-03 06:51:09 +00:00
Implement querying ip6.arpa domains
The program will query the whois server of the appropriate RIR when provided with an *.ip6.arpa IPv6 reverse DNS domain.
This commit is contained in:
parent
cb0c7062ab
commit
8a6ce04adb
@ -17,6 +17,7 @@ while (<>) {
|
||||
$b = "\\x03" if $b eq 'NONE';
|
||||
$b = "\\x08" if $b eq 'AFILIAS';
|
||||
$b = "\\x0C" if $b eq 'ARPA';
|
||||
$b = "\\x0D" if $b eq 'IP6';
|
||||
print qq| "$a",\t"$b",\n|;
|
||||
}
|
||||
|
||||
|
||||
@ -44,6 +44,7 @@
|
||||
|
||||
.e164.arpa whois.ripe.net
|
||||
.in-addr.arpa ARPA
|
||||
.ip6.arpa IP6
|
||||
.arpa whois.iana.org
|
||||
|
||||
.aero whois.aero
|
||||
|
||||
69
whois.c
69
whois.c
@ -368,6 +368,12 @@ int handle_query(const char *hserver, const char *hport,
|
||||
server = guess_server(p);
|
||||
free(p);
|
||||
goto retry;
|
||||
case 0x0D:
|
||||
p = convert_in6arpa(query);
|
||||
free(server);
|
||||
server = guess_server(p);
|
||||
free(p);
|
||||
goto retry;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -1328,6 +1334,69 @@ char *convert_inaddr(const char *s)
|
||||
return new;
|
||||
}
|
||||
|
||||
char *convert_in6arpa(const char *s)
|
||||
{
|
||||
char *ip, *p;
|
||||
int character = 0;
|
||||
int digits = 1;
|
||||
|
||||
ip = malloc(40);
|
||||
|
||||
p = strstr(s, ".ip6.arpa");
|
||||
if (!p || p == s) {
|
||||
ip[character] = '\0';
|
||||
return ip;
|
||||
}
|
||||
|
||||
/* start from the first character before ".ip6.arpa" */
|
||||
p--;
|
||||
|
||||
while (1) {
|
||||
/* check that this is a valid digit for an IPv6 address */
|
||||
if (!((*p >= '0' && *p <= '9') || (*p >= 'a' && *p <= 'f') ||
|
||||
(*p >= 'A' && *p <= 'F'))) {
|
||||
free(ip);
|
||||
ip[character] = '\0';
|
||||
return ip;
|
||||
}
|
||||
|
||||
/* copy the digit to the IP address */
|
||||
ip[character++] = *p;
|
||||
|
||||
/* stop if we have reached the beginning of the string */
|
||||
if (p == s)
|
||||
break;
|
||||
|
||||
/* stop if we have parsed a complete address */
|
||||
if (character == 39)
|
||||
break;
|
||||
|
||||
/* add the colon separator every four digits */
|
||||
if ((digits++ % 4) == 0)
|
||||
ip[character++] = ':';
|
||||
|
||||
/* go to the precedent character and abort if it is not a dot */
|
||||
p--;
|
||||
if (*p != '.') {
|
||||
ip[character] = '\0';
|
||||
return ip;
|
||||
}
|
||||
|
||||
/* abort if the string starts with the dot */
|
||||
if (p == s) {
|
||||
ip[character] = '\0';
|
||||
return ip;
|
||||
}
|
||||
|
||||
/* go to the precedent character and continue */
|
||||
p--;
|
||||
}
|
||||
|
||||
/* terminate the string */
|
||||
ip[character] = '\0';
|
||||
return ip;
|
||||
}
|
||||
|
||||
unsigned long myinet_aton(const char *s)
|
||||
{
|
||||
unsigned long a, b, c, d;
|
||||
|
||||
1
whois.h
1
whois.h
@ -38,6 +38,7 @@ char *normalize_domain(const char *);
|
||||
char *convert_6to4(const char *);
|
||||
char *convert_teredo(const char *);
|
||||
char *convert_inaddr(const char *);
|
||||
char *convert_in6arpa(const char *);
|
||||
int handle_query(const char *server, const char *port,
|
||||
const char *qstring, const char *fstring);
|
||||
void split_server_port(const char *const input, char **server, char **port);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user