0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# Copyright (C) 2000, 2001, 2004, 2007, 2012, 2013, 2016 Internet Systems Consortium, Inc. ("ISC")
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# This Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# License, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# file, You can obtain one at http://mozilla.org/MPL/2.0/.
70e5a7403f0e0a3bd292b8287c5fed5772c15270Automatic Updater# $Id: digcomp.pl,v 1.14 2007/06/19 23:47:00 tbox Exp $
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer# Compare two files, each with the output from dig, for differences.
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer# Ignore "unimportant" differences, like ordering of NS lines, TTL's,
ed0a75d4a494e5ebc4ab50d6b9e6fb9dfe3681f4Andreas Gustafssonopen(FILE1, $file1) || die("open: $file1: $!\n");
8d0f8e8c2e4d8ff5bef14b7e7ae7b73bbc5743eeMark Andrews ~ s/\r\n//g;
ed0a75d4a494e5ebc4ab50d6b9e6fb9dfe3681f4Andreas Gustafsson if (/^;.+status:\s+(\S+).+$/) {
ed0a75d4a494e5ebc4ab50d6b9e6fb9dfe3681f4Andreas Gustafsson next if (/^;/);
ed0a75d4a494e5ebc4ab50d6b9e6fb9dfe3681f4Andreas Gustafsson if (/^(\S+)\s+\S+\s+(\S+)\s+(\S+)\s+(.+)$/) {
ed0a75d4a494e5ebc4ab50d6b9e6fb9dfe3681f4Andreas Gustafsson $firstname = $name if ($firstname eq "");
ed0a75d4a494e5ebc4ab50d6b9e6fb9dfe3681f4Andreas Gustafsson if ($entry{"$name ; $class.$type ; $value"} ne "") {
ed0a75d4a494e5ebc4ab50d6b9e6fb9dfe3681f4Andreas Gustafsson $line = $entry{"$name ; $class.$type ; $value"};
ed0a75d4a494e5ebc4ab50d6b9e6fb9dfe3681f4Andreas Gustafsson print("Duplicate entry in $file1:\n> $_\n< $line\n");
ed0a75d4a494e5ebc4ab50d6b9e6fb9dfe3681f4Andreas Gustafsson $entry{"$name ; $class.$type ; $value"} = $_;
ed0a75d4a494e5ebc4ab50d6b9e6fb9dfe3681f4Andreas Gustafssonopen(FILE2, $file2) || die("open: $file2: $!\n");
8d0f8e8c2e4d8ff5bef14b7e7ae7b73bbc5743eeMark Andrews ~ s/\r\n//g;
ed0a75d4a494e5ebc4ab50d6b9e6fb9dfe3681f4Andreas Gustafsson if (/^;.+status:\s+(\S+).+$/) {
ed0a75d4a494e5ebc4ab50d6b9e6fb9dfe3681f4Andreas Gustafsson next if (/^;/);
ed0a75d4a494e5ebc4ab50d6b9e6fb9dfe3681f4Andreas Gustafsson if (/^(\S+)\s+\S+\s+(\S+)\s+(\S+)\s+(.+)$/) {
ed0a75d4a494e5ebc4ab50d6b9e6fb9dfe3681f4Andreas Gustafsson if (($name eq $firstname) && ($type eq "SOA")) {
ed0a75d4a494e5ebc4ab50d6b9e6fb9dfe3681f4Andreas Gustafsson if ($entry{"$name ; $class.$type ; $value"} ne "") {
ed0a75d4a494e5ebc4ab50d6b9e6fb9dfe3681f4Andreas Gustafsson $entry{"$name ; $class.$type ; $value"} = "";
ed0a75d4a494e5ebc4ab50d6b9e6fb9dfe3681f4Andreas Gustafsson print("Only in $file2 (missing from $file1):\n")
ed0a75d4a494e5ebc4ab50d6b9e6fb9dfe3681f4Andreas Gustafsson print("> $_\n");
ed0a75d4a494e5ebc4ab50d6b9e6fb9dfe3681f4Andreas Gustafsson print("Only in $file1 (missing from $file2):\n")
ed0a75d4a494e5ebc4ab50d6b9e6fb9dfe3681f4Andreas Gustafsson print("< $entry{$key}\n");
ed0a75d4a494e5ebc4ab50d6b9e6fb9dfe3681f4Andreas Gustafsson print("< status: $rcode1\n");
ed0a75d4a494e5ebc4ab50d6b9e6fb9dfe3681f4Andreas Gustafsson print("> status: $rcode2\n");