Skip to content
/ dnsolve Public

Pure Dart library that provides an easy way to perform DNS lookups.

License

Notifications You must be signed in to change notification settings

vsevex/dnsolve

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DNSolve

License: MIT

DNSolve is a Dart library that provides an easy way to perform DNS lookups. It supports both forward and reverse DNS lookups, and can be used with different DNS providers.

Overview

This project provides a convenient API wrapper for interacting with public DNS services. While it might appear to function as a traditional DNS client, it's essential to note that it operates by sending HTTP GET requests to public DNS API endpoints like Google and Cloudflare.

Installation

To install DNSolve, add the following dependency to your pubspec.yaml file:

dependencies:
  dnsolve: ^1.0.0

Usage

To perform a DNS lookup, you can use the lookup() method. This method takes the following parameters:

  • domain: The domain to lookup.
  • dnsSec: Whether to enable DNSSEC (Domain Name System Security Extensions).
  • type: The DNS record type to look up.
  • provider: The DNS provider to use.

The following code snippet shows how to perform an SRV lookup which is located under the vsevex.me domain:

import 'dart:developer';

import 'package:dnsolve/dnsolve.dart';

Future<void> main() async {
  final dnsolve = DNSolve();
  final response = await dnsolve.lookup(
    '_xmpp._tcp.vsevex.me',
    dnsSec: true,
    type: RecordType.srv,
  );

  if (response.answer!.records != null) {
    for (final record in response.answer!.records!) {
      log(record.toBind);
    }
  }
}

The output will be something like this:

_xmpp._tcp.vsevex.me. 1805 IN SRV "0 5 1234 xmpp-client.vsevex.me."
_xmpp._tcp.vsevex.me. 1805 IN SRV "1 5 1234 xmpp-client.vsevex.me."

The lookup() method returns a ResolveResponse object. This object contains the following properties:

  • status: The status of the DNS lookup.
  • answer: The DNS answer.
  • Some other additional properties.

The answer property contains a list of Record and SRVRecord objects. Each Record object represents a single DNS record. The Record object has the following properties:

  • name: The name of the DNS record.
  • rType: The type of the DNS record.
  • ttl: The time to live of the DNS record.
  • data: The data of the DNS record.

Contributing to DNSolve

I do welcome and appreciate contributions from the community to enhance the DNSolve. If you have any improvements, bug fixes, or new features to contribute, you can do so by creating a pull request.

About

Pure Dart library that provides an easy way to perform DNS lookups.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages