teamcfadvance / statDns

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

statDNS API Consumer

CFC to consume the REST API from statdns.com.

Additional Information

Some of the available record types referenced below are uncommon. A full list of DNS records with explanations may be found here on the list of DNS record types.

Simple Example

<cfscript>
	// instantiate component
	statdns = createobject("component","StatDNSConsumer").init();
	
	// verbose method name example
	a = statdns.domain("www.whitehouse.gov").getHostAddress();  // sets active domain for inquiries and invokes a method
	b = statdns.getCanonicalName(); // continues executing against the previously specified domain
	
	writeOutput("Host Address: " & a.result & "<br />"); // outputs simplified results in a comma-separated list
	writeOutput("Canonical Name: " & b.result & "<br />"); // outputs simplified results in a comma-separated list
	
	// note that only those result types matching the original inquiry (A records) 
	// are included in the simplified 'result' value above; full results may be looped below for more verbose info
	writeOutput("Full Results:<br />");
	if(arraylen(a.results)) {
		for(r in a.results) { 
			writeDump(r);
		}
	}
	 
	// terse method name example
	c = statdns.domain("statdns.net").getMX(); // sets a new domain and invokes a method 
	d = statdns.getNS(); // executes the newly set domain 
</cfscript>

Response Format

Response is a standardized struct containing the following keys:

response = {
		inquiry = { // an echo of the request being processed
			name = "", // typically the domain or ip value for which info is being retrieved
			type = "", // the type of record data requested; this is used when determining how to build the 'result' key below
			class = "" 
		},
		result = "", // convenience value; comma-delimited list of result data values which specifically match the query type
		results = [], // array of raw results
		authoritative = [], // array of entities acting as authoritative sources for the returned data
		timestamp = "", // timestamp of the request
		success = false, // whether the data request was successful; requests which will result in NO data will have this flag set false
		errors = "" // any errors which may have occurred during the call; when response.success key is false, this string will be relevant
};	

A valid response for the domain www.whitehouse.gov from a call to getHostAddress() with its result formatted as JSON (for display purposes) - notice how only those results whose type matched the inquiry type will be included in the simplified 'result' value:

{
	"inquiry" : {
		"name" : "www.whitehouse.gov.",
		"class" : "IN",
		"type" : "A"
	},
	"result" : "92.122.189.80,92.122.189.59",
	"results" : [{
			"name" : "www.whitehouse.gov.",
			"data" : "www.whitehouse.gov.edgesuite.net.",
			"datalength" : 34,
			"class" : "IN",
			"ttl" : 3527,
			"type" : "CNAME"
		}, {
			"name" : "www.whitehouse.gov.edgesuite.net.",
			"data" : "www.eop-edge-lb.akadns.net.",
			"datalength" : 25,
			"class" : "IN",
			"ttl" : 827,
			"type" : "CNAME"
		}, {
			"name" : "www.eop-edge-lb.akadns.net.",
			"data" : "a1128.dsch.akamai.net.",
			"datalength" : 20,
			"class" : "IN",
			"ttl" : 227,
			"type" : "CNAME"
		}, {
			"name" : "a1128.dsch.akamai.net.",
			"data" : "92.122.189.80",
			"datalength" : 4,
			"class" : "IN",
			"ttl" : 20,
			"type" : "A"
		}, {
			"name" : "a1128.dsch.akamai.net.",
			"data" : "92.122.189.59",
			"datalength" : 4,
			"class" : "IN",
			"ttl" : 20,
			"type" : "A"
		}
	],
	"authoritative" : [],
	"success" : true,
	"errors" : "",
	"timestamp" : "November, 10 2013 21:03:10 -0600"
}

Methods

Initialization methods:
The following set of methods are chainable, returning the StatDNSConsumer component itself.

Example:	
	statdns = createobject("component","StatDNSConsumer").init(); // instantiate component
	
	statdns.domain("www.whitehouse.gov"); // set domain to query
	a = statdns.getHostAddress(); // get A record data
	
	// alternatively, may be chained as:		
	a = statdns.domain("www.whitehouse.gov").getHostAddress();
  • init() - initializes the component
  • Arguments
    • domain (optional) - string - if specified, sets the active domain against which subsequent methods will be invoked
    • ipv4 (optional) - string - if specified, sets the active IPV4 address against which subsequent methods will be invoked
    • ipv6 (optional) - string - if specified, sets the active IPV6 address against which subsequent methods will be invoked
    • arpa (optional) - string - if specified, sets the active ARPA address against which subsequent methods will be invoked
    • httptimeout (optional) - numeric - if specified, overrides the default of 60 seconds timeout when making API calls
  • Returns
    • StatDNSConsumer (this) - chainable
  • domain() - sets the active domain against which methods are invoked
  • Arguments
    • domain (required) - string - a valid domain name without protocol or path; note that some methods return different information depending on the nature of the domain name; e.g., www.statdns.net may return different information than statdns.net
  • Returns
    • StatDNSConsumer (this) - chainable
  • Throws
    • InvalidDomain exception if domain value cannot be reliably determined to be a valid format
  • ipv4() - sets the active IPV4 address against which methods are invoked
  • Arguments
    • ipv4 (required) - string - a valid IPV4 address
  • Returns
    • StatDNSConsumer (this) - chainable
  • Throws
    • InvalidIPv4 exception if ipv4 value cannot be reliably determined to be a valid format
  • ipv6() - sets the active IPV6 address against which methods are invoked
  • Arguments
    • ipv6 (required) - string - a valid IPV6 address
  • Returns
    • StatDNSConsumer (this) - chainable
  • Throws
    • InvalidIPv4 exception if ipv6 value cannot be reliably determined to be a valid format
  • arpa() - sets the active ARPA address against which methods are invoked
  • Arguments
    • arpa (required) - string - a valid ARPA address
  • Returns
    • StatDNSConsumer (this) - chainable
  • Throws
    • InvalidARPA exception if arpa value is empty string (no additional validation at this time)

Data retrieval methods:

Note that both terse and verbose method names are available and may be used; you may prefer one or the other for either brevity or readability. Invoking these methods without previously setting the data they require, domain(), ipv4(), etc., will throw an exception.

  • getA() - getHostAddress() - gets Host Address data for the current domain
  • Arguments:
    • type (optional) - string - ipv4 / ipv6 - specifies the type of IP data to return; defaults to ipv4
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getCERT() - getCertificate() - gets Certificate data for the current domain
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getCNAME() - getCanonicalName() - gets Canonical Name data for the current domain
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getDHCPID() - getDHCPIdentifier() - gets DHCP Identifier data for the current domain
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getDLV() - getDNSSECLookasideValidation() - gets DNSSEC Lookaside Validation data for the current domain
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getDNAME() - getDelegationName() - gets Delegation Name data for the current domain
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getDS() - getDelegationSigner() - gets Delegation Signer data for the current domain
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getHINFO() - getHostInformation() - gets Host Information data for the current domain
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getHIP() - getHostIdentityProtocol() - gets Host Identifiy Protocol data for the current domain
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getKX() - getKeyExchanger() - gets Key Exchanger data for the current domain
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getLOC() - getLocation() - gets Location data for the current domain
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getMX() - getMailExchange() - gets Mail Exchange data for the current domain
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getNAPTR() - getNameAuthorityPointer() - get Name Authority Pointer data for the current domain
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getNS() - getNameServers() - gets Name Servers data for the current domain
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getNSEC() - getNextSecure() - gets Next-Secure data for the current domain
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getNSEC3() - getNextSecureV3() - gets Next-Secure v3 data for the current domain
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getNSEC3Param() - getNextSecureV3Parameters() - gets Next-Secure v3 Parameters data for the current domain
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getOPT() - getOption() - gets Option data for the current domain
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getPTR() - getPointer() - gets Pointer data for the current ARPA address
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the arpa() or init() methods
  • getRRSIG() - getResourceRecordsSignature() - gets Resource Records Signature data for the current domain
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getSOA() - getStartOfAuthority() - gets Start of Authority data for the current domain
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getSPF() - getSenderPolicyFramework() - gets Sender Policy Framework data for the current domain
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getSRV() - getServiceLocator() - gets Service Locator data for the current domain
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getSSHFP() - getSSHPublicKeyFingerprint() - gets SSH Public Key Fingerprint data for the current domain
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getTA() - getTrustAuthorities() - getDNSSECTrustAuthorities() - gets DNSSEC Trust Authorities data for the current domain
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getTALINK() - getTrustAnchorLink() - gets Trust Anchor LINK data for the current domain
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getTXT() - getText() - getTextRecord() - gets Text record data for the current domain
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the domain() or init() methods
  • getRPTR() - getReversePointer() - gets Reverse Pointer data for the current ipv4 or ipv6 address
  • Arguments:
    • type (optional) - string - ipv4 / ipv6 - specifies the type of IP data being passed; defaults to ipv4
  • Returns
    • standardized response (struct)
  • Throws
    • RequiredValueMissing exception if domain has not been set via the ipv4(), ipv6 or init() methods

Team CF Advance:

The CF Advance team is focused on developing open source software for ColdFusion/Railo.

Developers of all walks of life, skill level and experience are welcome to join the team. The more participants, the better the outcome will be. So, if you have ideas for open source ColdFusion software, want to be part of like-minded teams of developers working towards building quality solutions for the community, enjoy a good challenge, etc., then join us!

http://www.teamcfadvance.org/

About

License:Apache License 2.0


Languages

Language:ColdFusion 100.0%