aboutsummaryrefslogtreecommitdiff
path: root/src/org/xbill/DNS/tests/primary.java
blob: 85455b9cc46e46395f428def98961ce8f0cc180d (plain)
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
// Copyright (c) 1999-2004 Brian Wellington (bwelling@xbill.org)

package org.xbill.DNS.tests;

import java.util.*;
import org.xbill.DNS.*;

public class primary {

private static void
usage() {
	System.out.println("usage: primary [-t] [-a | -i] origin file");
	System.exit(1);
}

public static void
main(String [] args) throws Exception {
	boolean time = false;
	boolean axfr = false;
	boolean iterator = false;
	int arg = 0;

	if (args.length < 2)
		usage();

	while (args.length - arg > 2) {
		if (args[0].equals("-t"))
			time = true;
		else if (args[0].equals("-a"))
			axfr = true;
		else if (args[0].equals("-i"))
			iterator = true;
		arg++;
	}

	Name origin = Name.fromString(args[arg++], Name.root);
	String file = args[arg++];

	long start = System.currentTimeMillis();
	Zone zone = new Zone(origin, file);
	long end = System.currentTimeMillis();
	if (axfr) {
		Iterator it = zone.AXFR();
		while (it.hasNext()) {
			System.out.println(it.next());
		}
	} else if (iterator) {
		Iterator it = zone.iterator();
		while (it.hasNext()) {
			System.out.println(it.next());
		}
	} else {
		System.out.println(zone);
	}
	if (time)
		System.out.println("; Load time: " + (end - start) + " ms");
}

}