aboutsummaryrefslogtreecommitdiffstats
path: root/tools/make-linknet-hosts.pl
diff options
context:
space:
mode:
authorKristian Lyngstol <kristian@bohemians.org>2016-03-27 08:27:17 +0200
committerKristian Lyngstol <kristian@bohemians.org>2016-03-27 08:27:17 +0200
commit1d2470a411e5eaac7e5a1c5d5b6b81e92c92f4a8 (patch)
tree54b901757b088d54d33e70f28a6203383b4dc844 /tools/make-linknet-hosts.pl
parent0a230ac5481b9518abc64181dbbb4509d83c0b89 (diff)
parent96a9bb4c42f4b53020302fea2a46e734c61c0319 (diff)
Merge branch 'master' of github.com:tech-server/tgmanage
Diffstat (limited to 'tools/make-linknet-hosts.pl')
-rwxr-xr-xtools/make-linknet-hosts.pl36
1 files changed, 25 insertions, 11 deletions
diff --git a/tools/make-linknet-hosts.pl b/tools/make-linknet-hosts.pl
index 1db630a..c00e81b 100755
--- a/tools/make-linknet-hosts.pl
+++ b/tools/make-linknet-hosts.pl
@@ -24,21 +24,35 @@ while (<STDIN>) {
my ($ipv4_raw, $ipv6_raw, $from, $to) = split;
- # v4
- my $ipv4_first = NetAddr::IP->new($ipv4_raw);
- my $ipv4_second = $ipv4_first + 1;
-
- # v6
- my $ipv6_first = NetAddr::IP->new($ipv6_raw);
- my $ipv6_second = $ipv6_first + 1;
+ my ($ipv4_first, $ipv4_second, $ipv6_first, $ipv6_second);
+ if($ipv6_raw =~ m/nope/){
+ $ipv6_first = "nope";
+ $ipv6_second = "nope";
+ } else {
+ my $ipv6 = NetAddr::IP->new($ipv6_raw);
+ $ipv6_first = $ipv6->addr();
+ $ipv6++;
+ $ipv6_second = $ipv6->addr();
+ }
+
+ if($ipv4_raw =~ m/nope/){
+ $ipv4_first = "";
+ $ipv4_second = "";
+ } else {
+ my $ipv4 = NetAddr::IP->new($ipv4_raw);
+ $ipv4_first = $ipv4->addr();
+ $ipv4++;
+ $ipv4_second = $ipv4->addr;
+ }
+
# generate-dnsrr.pl format:
# hostname ipv4 ipv6
if($first){
- printf("%s %s %s\n", $from, $ipv4_first->addr, $ipv6_first->addr);
- printf("%s %s %s\n", $to, $ipv4_second->addr, $ipv6_second->addr);
+ printf("%s %s %s\n", $from, $ipv4_first, $ipv6_first);
+ printf("%s %s %s\n", $to, $ipv4_second, $ipv6_second);
} else {
- printf("%s-%s %s %s\n", $from, $to, $ipv4_first->addr, $ipv6_first->addr);
- printf("%s-%s %s %s\n", $to, $from, $ipv4_second->addr, $ipv6_second->addr);
+ printf("%s-%s %s %s\n", $from, $to, $ipv4_first, $ipv6_first);
+ printf("%s-%s %s %s\n", $to, $from, $ipv4_second, $ipv6_second);
}
}