-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrpslexpand
executable file
·71 lines (53 loc) · 1.8 KB
/
rpslexpand
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/perl
#
# Copyright 2006 by Marco d'Itri <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
use warnings;
use strict;
use YAML::XS qw(Load LoadFile);
use Getopt::Long;
use FindBin;
use lib "$FindBin::RealBin/lib";
use RPSLToolUtils;
use RPSLToolBGPQ3;
##############################################################################
my $ipv6 = 0;
my ($whois_server, $whois_source);
GetOptions(
'ipv6' => \$ipv6,
'whois-server=s' => \$whois_server,
'whois-source=s' => \$whois_source,
);
usage(1) if not @ARGV;
my @import = @ARGV;
##############################################################################
my ($param) = Load(join('', <DATA>));
die if not $param;
make_boolean($param, qw(whois_show_cache_misses
whois_die_on_error whois_warn_on_error whois_warn_on_recursive_error));
$param->{whois_server} = $whois_server if $whois_server;
$param->{whois_source} = $whois_source if $whois_source;
my $whois = bgpq3_factory($param);
my ($routes, $asn) = $whois->import(\@import, $ipv6, 0);
print join("\n", @$routes) . "\n" if @$routes;
print join("\n", @$asn) . "\n" if @$asn;
exit;
##############################################################################
sub usage {
print STDERR <<END;
Usage: rpslexpand [OPTIONS]... [AS-SET|RS-SET]...
--ipv6 ask for route6 records instead of route records
--whois-server=HOST connect to HOST instead of the default
--whois-source=NAME ask for records with a specific source attribute
END
exit(shift);
}
__DATA__
cache_root: /tmp/rpsltool
#whois_show_cache_misses: y
#whois_warn_on_error: y
#whois_warn_on_recursive_error: y