All Projects → dnsjava → Dnsjava

dnsjava / Dnsjava

Licence: bsd-2-clause
The offical home of dnsjava - an implementation of the DNS protocol in Java.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Dnsjava

Txeh
Go library and CLI utilty for /etc/hosts management.
Stars: ✭ 181 (-61.89%)
Mutual labels:  library, dns
C Ares
A C library for asynchronous DNS requests
Stars: ✭ 1,193 (+151.16%)
Mutual labels:  library, dns
Ivi
🔥 Javascript (TypeScript) library for building web user interfaces
Stars: ✭ 445 (-6.32%)
Mutual labels:  library
Fastlib
一个Android项目级快速开发框架,节约大部分写常用功能时间以实现更多项目业务功能及体验上的优化。使用说明见wiki
Stars: ✭ 469 (-1.26%)
Mutual labels:  library
Encrypted Dns
Configuration profiles for DNS HTTPS and DNS over TLS for iOS 14 and MacOS Big Sur
Stars: ✭ 455 (-4.21%)
Mutual labels:  dns
Twisted
Event-driven networking engine written in Python.
Stars: ✭ 4,442 (+835.16%)
Mutual labels:  dns
Virtual Hosts
hosts for android,implement by vpn mode,supports wildcard DNS records
Stars: ✭ 465 (-2.11%)
Mutual labels:  dns
Ponder
C++ reflection library with Lua binding, and JSON and XML serialisation.
Stars: ✭ 442 (-6.95%)
Mutual labels:  library
Competitiveprogramming
A collection of algorithms, data structures and other useful information for competitive programming.
Stars: ✭ 475 (+0%)
Mutual labels:  library
Compiler
The Hoa\Compiler library.
Stars: ✭ 458 (-3.58%)
Mutual labels:  library
Rubberpicker
Android Rubber Picker Library
Stars: ✭ 469 (-1.26%)
Mutual labels:  library
Certificationy
The core library to create tests and certifications
Stars: ✭ 457 (-3.79%)
Mutual labels:  library
Curl
A command line tool and library for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, RTMP, RTMPS, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP. libcurl offers a myriad of powerful features
Stars: ✭ 22,875 (+4715.79%)
Mutual labels:  library
Gobuster
Directory/File, DNS and VHost busting tool written in Go
Stars: ✭ 5,356 (+1027.58%)
Mutual labels:  dns
Information collection handbook
Handbook of information collection for penetration testing and src
Stars: ✭ 447 (-5.89%)
Mutual labels:  dns
Introduction
An Android library to show an intro to your users.
Stars: ✭ 471 (-0.84%)
Mutual labels:  library
Cordova Plugin Whitelist
Apache Cordova plugin whitelist
Stars: ✭ 442 (-6.95%)
Mutual labels:  library
Chat Api
WhatsApp's Private API
Stars: ✭ 4,251 (+794.95%)
Mutual labels:  library
Sleepy Discord
C++ library for the Discord chat client
Stars: ✭ 459 (-3.37%)
Mutual labels:  library
Almin
Client-side DDD/CQRS for JavaScript.
Stars: ✭ 477 (+0.42%)
Mutual labels:  library

Build Status codecov Maven Central Javadocs

dnsjava

Overview

dnsjava is an implementation of DNS in Java. It supports almost all defined record types (including the DNSSEC types), and unknown types. It can be used for queries, zone transfers, and dynamic updates. It includes a cache which can be used by clients, and an authoritative only server. It supports TSIG authenticated messages, partial DNSSEC verification, and EDNS0. It is fully thread safe.

dnsjava was started as an excuse to learn Java. It was useful for testing new features in BIND without rewriting the C resolver. It was then cleaned up and extended in order to be used as a testing framework for DNS interoperability testing. The high level API and caching resolver were added to make it useful to a wider audience. The authoritative only server was added as proof of concept.

dnsjava on Github

This repository has been a mirror of the dnsjava project at Sourceforge since 2014 to maintain the Maven build for publishing to Maven Central. As of 2019-05-15, Github is officially the new home of dnsjava.

Please use the Github issue tracker and send - well tested - pull requests. The [email protected] mailing list still exists.

Getting started

Config options

Some settings of dnsjava can be configured via system properties:

Property Type Default Example
Explanation
dns[.fallback].server String - 8.8.8.8,[2001:4860:4860::8888]:853,dns.google
DNS server(s) to use for resolving. Comma separated list. Can be IPv4/IPv6 addresses or hostnames (which are resolved using Java's built in DNS support).
dns[.fallback].search String - ds.example.com,example.com
Comma separated list of DNS search paths.
dns[.fallback].ndots Integer 1 2
Sets a threshold for the number of dots which must appear in a name given to resolve before an initial absolute query will be made.
dnsjava.options option list - BINDTTL,tsigfudge=1
Comma separated key-value pairs, see below.
dnsjava.configprovider.skipinit Boolean false true
Set to true to disable static ResolverConfig initialization.
dnsjava.configprovider.sunjvm.enabled Boolean false true
Set to true to enable the reflection based DNS server lookup, see limitations below.
dnsjava.udp.ephemeral.start Integer 49152 (Linux: 32768) 50000
First ephemeral port for UDP-based DNS queries.
dnsjava.udp.ephemeral.end Integer 65535 (Linux: 60999) 60000
Last ephemeral port for UDP-based DNS queries.
dnsjava.udp.ephemeral.use_ephemeral_port Boolean false true
Use an OS-assigned ephemeral port for UDP queries. Enabling this option is insecure! Do NOT use it.
dnsjava.lookup.max_iterations Integer 16 20
Maximum number of CNAMEs to follow in a chain.

dnsjava.options pairs

The dnsjava.options configuration options can also be set programmatically through the Options class. Please refer to the Javadoc for details.

Key Type Default Explanation
BINDTTL Boolean false Print TTLs in BIND format
multiline Boolean false Print records in multiline format
noPrintIN Boolean false Don't print the class of a record if it's IN
tsigfudge Integer 300 Sets the default TSIG fudge value (in seconds)
sig0validity Integer 300 Sets the default SIG(0) validity period (in seconds)

Resolvers

dnsjava comes with several built-in resolvers:

  • SimpleResolver: a basic resolver that uses UDP by default and falls back to TCP if required.
  • ExtendedResolver: a resolver that uses multiple SimpleResolvers to send the queries. Can be configured to query the servers in a round-robin order. Blacklists a server if it times out.
  • DohResolver: a proof-of-concept DNS over HTTP resolver, e.g. to use https://dns.google/query.

The project dnssecjava has a resolver that validates responses with DNSSEC.

Migrating from version 2.1.x to v3

dnsjava 3 has significant API changes compared to version 2.1.x and is neither source nor binary compatible. The most important changes are:

  • The minimum supported version is Java 8
  • Uses slf4j for logging and thus needs slf4j-api on the classpath
  • The command line tools were moved to the org.xbill.DNS.tools package
  • On Windows, JNA should be on the classpath for the search path
  • The Resolver API for custom resolvers has changed to use CompletionStage<Message> for asynchronous resolving. The built-in resolvers are now fully non-blocking and do not start a thread per query anymore.
  • Many methods return a List<T> instead of an array. Ideally, use a for-each loop. If this isn't possible, call size() instead of using length:
    • Cache#findAnyRecords
    • Cache#findRecords
    • Lookup#getDefaultSearchPath
    • Message#getSectionRRsets
    • SetResponse#answers
    • ResolverConfig
  • RRset returns a List instead of an Iterator. Ideally, modify your code to use a for-each loop. If this is not possible, create an iterator on the returned list:
    • RRset#rrs
    • RRset#sigs
  • Methods using java.util.Date are deprecated. Use the new versions with java.time.Instant or java.time.Duration instead
  • The type hierarchy of SMIMEARecord changed, it now inherits from TLSARecord and constants are shared
  • Records are no longer marked as Serializable. Use the RFC defined serialization formats:
    • toString(), rrToString() <-> fromString()
    • toWire() <-> fromWire(), newRecord()
  • Message and Header properly support clone()

Replacing the standard Java DNS functionality

Java versions from 1.4 to 8 can load DNS service providers at runtime. The functionality was removed in JDK 9, a replacement is requested, but so far has not been implemented.

To load the dnsjava service provider, build dnsjava on JDK 8 and set the system property:

sun.net.spi.nameservice.provider.1=dns,dnsjava

This instructs the JVM to use the dnsjava service provide for DNS at the highest priority.

Build

Run mvn package from the toplevel directory to build dnsjava. JDK 8 or higher is required.

Testing dnsjava

Matt Rutherford contributed a number of unit tests, which are in the tests subdirectory. The hierarchy under tests mirrors the org.xbill.DNS classes. To run the unit tests, execute mvn test.

Limitations

There's no standard way to determine what the local nameserver or DNS search path is at runtime from within the JVM. dnsjava attempts several methods until one succeeds.

  • The properties dns.server and dns.search (comma delimited lists) are checked. The servers can either be IP addresses or hostnames (which are resolved using Java's built in DNS support).
  • On Unix/Solaris, /etc/resolv.conf is parsed.
  • On Windows, if JNA is available on the classpath, the GetAdaptersAddresses API is used.
  • On Android the ConnectivityManager is used (requires initialization using org.xbill.DNS.config.AndroidResolverConfigProvider.setContext).
  • The sun.net.dns.ResolverConfiguration class is queried if enabled.
  • If available and no servers have been found yet, JNDI-DNS is used.
  • If still no servers have been found yet, use the fallback properties. This can be used to query e.g. a well-known public DNS server instead of localhost.
  • As a last resort, localhost is used as the nameserver, and the search path is empty.

Additional documentation

Javadoc documentation can be built with mvn javadoc:javadoc or viewed online at javadoc.io. See the examples for some basic usage information.

License

dnsjava is placed under the BSD license. Several files are also under additional licenses; see the individual files for details.

Authors

Final notes

  • Thanks to Network Associates, Inc. for sponsoring some of the original dnsjava work in 1999-2000.
  • Thanks to Nominum, Inc. for sponsoring some work on dnsjava from 2000 through 2017.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].