Permalink
Browse files

conslidate A and AAAA writing

  • Loading branch information...
1 parent 2a52ec7 commit afe33961917997494236815539f429468028688b @tjfontaine committed Feb 15, 2013
Showing with 5 additions and 9 deletions.
  1. +3 −2 examples/server.js
  2. +2 −7 lib/packet.js
View
@@ -5,6 +5,7 @@ var dns = require('../dns'),
server = dns.createServer();
var onMessage = function (request, response) {
+ console.log('request from:', request.address);
var i;
//console.log(request)
response.answer.push(dns.A({
@@ -17,9 +18,9 @@ var onMessage = function (request, response) {
address: '127.0.0.2',
ttl: 600,
}));
- response.additional.push(dns.A({
+ response.additional.push(dns.AAAA({
name: 'hostA.example.org',
- address: '127.0.0.3',
+ address: '::1',
ttl: 600,
}));
View
@@ -290,16 +290,11 @@ Packet.write = function(buff, packet) {
state = 'RESOURCE_RECORD';
break;
case 'A':
- val = ipaddr.parse(val.address).toByteArray();
- val.forEach(function(b) {
- buff.writeUInt8(b);
- });
- state = 'RESOURCE_DONE';
- break;
case 'AAAA':
+ //TODO XXX FIXME -- assert that address is of proper type
val = ipaddr.parse(val.address).toByteArray();
val.forEach(function(b) {
- buff.writeUInt16BE(b);
+ buff.writeUInt8(b);
});
state = 'RESOURCE_DONE';
break;

0 comments on commit afe3396

Please sign in to comment.