Top Level Namespace

Defined Under Namespace

Modules: Nesser

Instance Method Summary collapse

Instance Method Details

#hexhelperObject

unpacker.rb Created June 20, 2017 By Ron Bowes

See: LICENSE.md

DNS has some unusual properties that we have to handle, which is why I wrote this class. It handles building / parsing DNS packets and keeping track of where in the packet we currently are. The advantage, besides simpler unpacking, is that encoded names (with pointers to other parts of the packet) can be trivially handled.



16
# File 'lib/nesser/packets/unpacker.rb', line 16

require 'hexhelper'

#ipaddrObject

types.rb Created June 20, 2017 By Ron Bowes

See: LICENSE.md

These are implementations of resource records - ie, the records found in a DNS answer that contain, for example, an ip address, a mail exchange, etc.

Every one of these classes follows the same paradigm (I guess in Java you’d say they implement the same interface). They can be initialized with type-dependent parameters; they implement ‘self.unpack()`, which takes a `Nesser::Unpacker` and returns an instance of itself; they implement `pack()`, which serialized itself into a `Nesser::Packer` instance; and they have a `to_s()` function, which stringifies the record in a fairly user-friendly way.



24
# File 'lib/nesser.rb', line 24

require 'ipaddr'

#socketObject

transaction.rb Created June 20, 2017 By Ron Bowes

See: LICENSE.md

When a request comes in, a transaction is created to represent it. The transaction can be used to respond to the request at any point in the future - the trn_id and socket and stuff are all set up. Though, keep in mind, most clients will only wait like 3 seconds, so responding at any point, while technically true, isn’t really a useful distinction.

Any methods with a bang (‘!’) in their name will send the response back to the requester. Only one bang method can be called, any subsequent calls will throw an exception.

You’ll almost always want to use either ‘transaction.answer!()` or `transaction.error!()`. While it’s possible to change and/or add to ‘transaction.response` and send it with `transaction.reply!()`, that’s more complex and generally not needed.



25
# File 'lib/nesser/transaction.rb', line 25

require 'socket'