aboutsummaryrefslogtreecommitdiffstats
path: root/tools/make-linknet-hosts.pl
diff options
context:
space:
mode:
authorJoachim Tingvold <joachim@tingvold.com>2016-03-25 15:51:28 +0100
committerroot <root@yoda.tg16.gathering.org>2016-03-25 16:35:40 +0100
commit23fabb7c1476a7f1ef3c00ff7e95eed4f7daa190 (patch)
tree425e30091d7a6d5bea23919e08511c197a5d2d67 /tools/make-linknet-hosts.pl
parent1670071c058a2676a4a880a93acd57b35d6dc24e (diff)
parent875f3e404537de55d5b03abd3b0b9bec58c34d49 (diff)
Merge branch 'master' of https://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);
}
}