mirror of
https://github.com/rfc1036/whois.git
synced 2026-08-31 07:30:22 +00:00
Refactoring
Merge the as and as32 data structures, since it is highly unlikely that using short ints will save any memory.
This commit is contained in:
parent
b433437563
commit
18145364ab
5
Makefile
5
Makefile
@ -94,9 +94,6 @@ version.h: debian/changelog make_version_h.pl
|
||||
as_del.h: as_del_list make_as_del.pl
|
||||
$(PERL) make_as_del.pl < $< > $@
|
||||
|
||||
as32_del.h: as32_del_list make_as32_del.pl
|
||||
$(PERL) make_as32_del.pl < $< > $@
|
||||
|
||||
ip_del.h: ip_del_list make_ip_del.pl
|
||||
$(PERL) make_ip_del.pl < $< > $@
|
||||
|
||||
@ -152,7 +149,7 @@ distclean: clean
|
||||
rm -f version.h po/whois.pot
|
||||
|
||||
clean:
|
||||
rm -f Makefile.depend as_del.h as32_del.h ip_del.h ip6_del.h \
|
||||
rm -f Makefile.depend as_del.h ip_del.h ip6_del.h \
|
||||
nic_handles.h new_gtlds.h tld_serv.h servers_charset.h \
|
||||
*.o whois mkpasswd
|
||||
rm -f po/*.mo
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
# http://www.iana.org/assignments/as-numbers
|
||||
|
||||
# actually I listed here also the unallocated space reserved for each RIR
|
||||
|
||||
131077 131086 whois.nic.ad.jp
|
||||
131092 131101 whois.nic.or.kr
|
||||
131152 131161 whois.nic.ad.jp
|
||||
131791 131890 whois.nic.or.kr
|
||||
131893 131992 whois.nic.ad.jp
|
||||
|
||||
2.0 2.65535 apnic
|
||||
3.0 3.65535 ripe
|
||||
4.0 4.65535 lacnic
|
||||
5.0 5.65535 afrinic
|
||||
6.0 6.65535 arin
|
||||
|
||||
# private ASN block
|
||||
4200000000 4294967294 ripe
|
||||
|
||||
16
as_del_list
16
as_del_list
@ -95,3 +95,19 @@
|
||||
# documentation and private ASN block
|
||||
64496 65534 ripe
|
||||
|
||||
131077 131086 whois.nic.ad.jp
|
||||
131092 131101 whois.nic.or.kr
|
||||
131152 131161 whois.nic.ad.jp
|
||||
131791 131890 whois.nic.or.kr
|
||||
131893 131992 whois.nic.ad.jp
|
||||
|
||||
# actually I listed here also the unallocated space reserved for each RIR
|
||||
2.0 2.65535 apnic
|
||||
3.0 3.65535 ripe
|
||||
4.0 4.65535 lacnic
|
||||
5.0 5.65535 afrinic
|
||||
6.0 6.65535 arin
|
||||
|
||||
# private ASN block
|
||||
4200000000 4294967294 ripe
|
||||
|
||||
|
||||
15
data.h
15
data.h
@ -118,8 +118,8 @@ const struct ip6_del ip6_assign[] = {
|
||||
};
|
||||
|
||||
struct as_del {
|
||||
const unsigned short first;
|
||||
const unsigned short last;
|
||||
const unsigned long first;
|
||||
const unsigned long last;
|
||||
const char *serv;
|
||||
};
|
||||
|
||||
@ -128,17 +128,6 @@ const struct as_del as_assign[] = {
|
||||
{ 0, 0, NULL }
|
||||
};
|
||||
|
||||
struct as32_del {
|
||||
const unsigned long first;
|
||||
const unsigned long last;
|
||||
const char *serv;
|
||||
};
|
||||
|
||||
const struct as32_del as32_assign[] = {
|
||||
#include "as32_del.h"
|
||||
{ 0, 0, NULL }
|
||||
};
|
||||
|
||||
const char *new_gtlds[] = {
|
||||
#include "new_gtlds.h"
|
||||
NULL
|
||||
|
||||
@ -1,28 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
while (<>) {
|
||||
chomp;
|
||||
s/#.*$//;
|
||||
s/^\s+//; s/\s+$//;
|
||||
next if /^$/;
|
||||
|
||||
my ($fh, $fl, $lh, $ll, $s, $f, $l);
|
||||
if (($fh, $fl, $lh, $ll, $s) =
|
||||
/^(\d+)\.(\d+)\s+(\d+)\.(\d+)\s+([\w\.-]+)$/) {
|
||||
$f = ($fh << 16) + $fl;
|
||||
$l = ($lh << 16) + $ll;
|
||||
|
||||
my $server = ($s =~ /\./) ? $s : "whois.$s.net";
|
||||
print qq|{ ${f}u, ${l}u,\t"$server" },\t/* $fh.$fl $lh.$ll */\n|;
|
||||
} elsif (($f, $l, $s) = /^(\d+)\s+(\d+)\s+([\w\.-]+)$/) {
|
||||
my $server = ($s =~ /\./) ? $s : "whois.$s.net";
|
||||
print qq|{ ${f}u, ${l}u,\t"$server" },\n|;
|
||||
} else {
|
||||
die "format error: $_";
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,18 +12,22 @@ while (<>) {
|
||||
s/^\s+//; s/\s+$//;
|
||||
next if /^$/;
|
||||
|
||||
die "format error: $_" if not (/^([\d\.]+)\s+([\d\.]+)\s+([\w\.]+)$/);
|
||||
my $f = $1; my $l = $2; my $s = $3;
|
||||
my ($fh, $fl, $lh, $ll, $s, $f, $l);
|
||||
my $comment = '';
|
||||
if (($fh, $fl, $lh, $ll, $s) =
|
||||
/^(\d+)\.(\d+)\s+(\d+)\.(\d+)\s+([\w\.-]+)$/) {
|
||||
$f = ($fh << 16) + $fl;
|
||||
$l = ($lh << 16) + $ll;
|
||||
$comment = qq|\t/* $fh.$fl $lh.$ll */|;
|
||||
} elsif (($f, $l, $s) = /^(\d+)\s+(\d+)\s+([\w\.-]+)$/) {
|
||||
} else {
|
||||
die "format error: $_";
|
||||
}
|
||||
|
||||
die "constraint violated: $l < $last_l" if $l < $last_l;
|
||||
$last_l = $l;
|
||||
|
||||
print "{ ${f}, ${l}, \"";
|
||||
if ($s =~ /\./) {
|
||||
print "$s";
|
||||
} else {
|
||||
print "whois.$s.net";
|
||||
}
|
||||
print qq(" },\n);
|
||||
my $server = ($s =~ /\./) ? $s : "whois.$s.net";
|
||||
print qq|{ ${f}u, ${l}u,\t"$server" },$comment\n|;
|
||||
}
|
||||
|
||||
|
||||
12
whois.c
12
whois.c
@ -638,15 +638,9 @@ const char *whereas(const unsigned long asn)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (asn > 65535) {
|
||||
for (i = 0; as32_assign[i].serv; i++)
|
||||
if (asn >= as32_assign[i].first && asn <= as32_assign[i].last)
|
||||
return as32_assign[i].serv;
|
||||
} else {
|
||||
for (i = 0; as_assign[i].serv; i++)
|
||||
if (asn >= as_assign[i].first && asn <= as_assign[i].last)
|
||||
return as_assign[i].serv;
|
||||
}
|
||||
for (i = 0; as_assign[i].serv; i++)
|
||||
if (asn >= as_assign[i].first && asn <= as_assign[i].last)
|
||||
return as_assign[i].serv;
|
||||
return "\x06";
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user