-
Notifications
You must be signed in to change notification settings - Fork 4
/
overview.html
executable file
·89 lines (85 loc) · 7.49 KB
/
overview.html
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<body >
<h2> Table of Contents</h2>
<ul class="table-list">
<li><a href="#intro">Introduction</a></li>
<li><a href="#depend">Dependencies</a></li>
<li><a href="#build">Building</a></li>
<li><a href="#use">Using getdns</a></li>
<li><a href="#known">Known issues</a></li>
</ul>
<h3 id='intro'>Introduction</h3>
<p>
getdns Java bindings is an implementation of Java language bindings for the <a href="https://getdnsapi.net/spec.html" target="_blank">getdns API</a>,
built on top of the <a href="https://github.com/getdnsapi/getdns/" target="_blank">getdns implementation</a>. getdns is a modern, asynchronous DNS API that simplifies access to advanced DNS features, including DNSSEC. The API specification was developed by Paul Hoffman. getdns is built on top of the getdns implementation developed as a joint project between <a href='http://labs.verisigninc.com/en_US/innovation/verisign-labs/index.xhtml'>Verisign Labs</a> and <a href='http://nlnetlabs.nl/'>NLnet Labs</a>.
To explore further, refer <a href="com/verisign/getdns/GetDNSFactory.html">GetDnsFactory</a>
</p>
<h3 id='depend'>Dependencies</h3>
<p>This has been built and tested with Java 1.7 and 1.8</p>
<p>Currently building against the getdns 0.1.7 release.
getdns external dependencies include:</p>
<ul class="task-list">
<li> <a href="https://www.nlnetlabs.nl/projects/ldns/">libldns from NLnet Labs</a> version 1.6.17 or later (ldns requires openssl headers and libraries)</li>
<li> <a href="http://www.gnu.org/software/libidn/">libidn from the FSF</a> version 1.29</li>
<li> <a href="http://expat.sourceforge.net/">libexpat</a> for libunbound.</li>
<li> <a href="http://www.nlnetlabs.nl/projects/unbound/">libunbound from NLnet Labs</a> version 1.4.22 or later</li>
<li>
<a href="http://libevent.org">libevent</a> version 2.0.22 stable</li>
</ul>
<p>Note that getdns <strong>MUST</strong> be built with the --with-libevent flag to configure.</p>
<h3 id= 'build'>Building </h3>
<p> The code repository for getdns is available at: <a href='https://github.com/getdnsapi/getdns-java-bindings'>https://github.com/getdnsapi/getdns-java-bindings</a> <br/>
<h4 id='preconfig'><u>Pre-configuration </u></h4>
The file gradle.properties needs to be edited to customize java home property.
<h4 id='preconfig'><u>Running gradle build </u></h4>
<pre>./gradlew clean assemble buildJniLib<BR></pre>
</p>
<h3 id='use'>Using getdns</h3>
<p>
<h4 id='preconfig'><u>Libraries</u></h4>
As per gradle standard libraries will be available in the folder build/libs.
<ul>
<li>libgetdnsconnector.so is used to connect to getdns and dependent libraries from Java layer. This needs to be placed at location that can be passed as java.library.path parameter during java invocation</li>
<li>getdns-java-0.1.jar should be placed in the classpath.</li>
</ul>
</p>
<h4 id='example'><u>Examples</u></h4>
<p>
In this example, we do a simple address lookup and dump the results to the screen:<BR/>
<div style='text-align:right;BORDER-TOP: #ccc 1px dashed'></div>
<div style='background:#FFFFFF; font-family: Courier New, Courier; font-size: 10pt; COLOR: #000000; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;'><strong><font color='#7f0055'>import</font></strong> java.util.HashMap;
<br/>
<br/><strong><font color='#7f0055'>import</font></strong> com.verisign.getdns.ContextOptionName;
<br/><strong><font color='#7f0055'>import</font></strong> com.verisign.getdns.GetDNSFactory;
<br/><strong><font color='#7f0055'>import</font></strong> com.verisign.getdns.GetDNSUtil;
<br/><strong><font color='#7f0055'>import</font></strong> com.verisign.getdns.IGetDNSContextSync;
<br/><strong><font color='#7f0055'>import</font></strong> com.verisign.getdns.RRType;
<br/>
<br/><font color='#3f7f5f'>/*
<br/> * Given a DNS name and type, return the records in the DNS answer section
<br/> */</font>
<br/>
<br/><strong><font color='#7f0055'>public</font></strong> <strong><font color='#7f0055'>class</font></strong> GetDNSGeneralSync {
<br/>
<br/> <strong><font color='#7f0055'>public</font></strong> <strong><font color='#7f0055'>static</font></strong> <strong><font color='#7f0055'>void</font></strong> main(String[] args) {
<br/> <strong><font color='#7f0055'>final</font></strong> IGetDNSContextSync context = GetDNSFactory.createSync(1, <strong><font color='#7f0055'>null</font></strong>);
<br/> <strong><font color='#7f0055'>try</font></strong> {
<br/> HashMap info = context.generalSync(<font color='#2a00ff'>"getdnsapi.net"</font>, RRType.A, <strong><font color='#7f0055'>null</font></strong>);
<br/> <strong><font color='#7f0055'>if</font></strong> (info != <strong><font color='#7f0055'>null</font></strong>) {
<br/> <strong><font color='#7f0055'>if</font></strong> (Integer.parseInt(info.get(<font color='#2a00ff'>"status"</font>).toString()) == 900) {
<br/> System.out.println(GetDNSUtil.printReadable(info));
<br/> System.out.println(GetDNSUtil.getdnsStatus(info));
<br/> } <strong><font color='#7f0055'>else</font></strong> <strong><font color='#7f0055'>if</font></strong> (Integer.parseInt(info.get(<font color='#2a00ff'>"status"</font>).toString()) == 901)
<br/> System.out.println(<font color='#2a00ff'>"no such name: "</font>);
<br/> <strong><font color='#7f0055'>else</font></strong>
<br/> System.out.println(<font color='#2a00ff'>"Error in query GETDNS Status ="</font> + info.get(<font color='#2a00ff'>"status"</font>).toString());
<br/> } <strong><font color='#7f0055'>else</font></strong>
<br/> System.out.println(<font color='#2a00ff'>"No response form DNS SERVER"</font>);
<br/> } <strong><font color='#7f0055'>finally</font></strong> {
<br/> context.close();
<br/> }
<br/> System.exit(0);
<br/> }
<br/>}<div style='text-align:right;BORDER-TOP: #ccc 1px dashed'></div></div>
<h3 id='known'>Known issues</h3>
<p>On some machines some test cases might fail because of timeout issues.</p>
</body>