Project

radiodns

0.0
No commit activity in last 3 years
No release in over 3 years
Perform RadioDNS resolutions and service lookups
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

RadioDNS Ruby Library

Summary

This Ruby Gem provides utilities for working with RadioDNS. It supports service CNAME resolution from bearer parameters and application discovery, corresponding to v0.6.1 of the RadioDNS spec.

Installation

gem install radiodns

Usage

Add this to the top of your script

require 'radiodns'

Then if you already have the Fully Qualified Domain Name as specified in the RadioDNS spec, you can resolve it into a CNAME like so

service = RadioDNS::Resolver.resolve('09580.c586.ce1.fm.radiodns.org')
puts service.cname #=> 'rdns.musicradio.com'

You can also pass in the parameters required to construct the FQDN to the resolve method

params = {
  :freq => '09580',
  :pi => 'c586',
  :ecc => 'ce1',
  :bearer => 'fm'
}
service = RadioDNS::Resolver.resolve(params)

The bearers fm, dab, drm, amss and hd are supported.

Once you have a service you can perform application discovery

radiovis_application = service.radiovis

radiovis_application.host #=> "rdns.musicradio.com"
radiovis_application.port #=> 61613
radiovis_application.type #=> :radiovis

Or to get an array of supported applications

service.applications

which returns

[#<RadioDNS::Application @host="rdns.musicradio.com", @port=61613, @type=:radioepg>,
 #<RadioDNS::Application @host="rdns.musicradio.com", @port=61613, @type=:radiovis>]

In the future these may become instances of specific classes that implement application-specific behaviour, but I might make those separate gems.

TODO

  • better error checking of supplied parameters. The code current checks for mandatory parameters but not if the parameters themselves conform to the spec (e.g. pa should be between 0 and 1023)

  • return an appropriate error if DNS look-up does not resolve to CNAME.