Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rinfo from the udp response to the service object #13

Merged
merged 3 commits into from
May 7, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add rinfo to the service
  • Loading branch information
jlucidar committed May 6, 2016
commit 4738037fc9f5d0997e14d8e6f692c1a12764600e
7 changes: 4 additions & 3 deletions lib/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Browser.prototype.start = function () {
var nameMap = {}
if (!this._wildcard) nameMap[this._name] = true

this._onresponse = function (packet) {
this._onresponse = function (packet, rinfo) {
if (self._wildcard) {
packet.answers.forEach(function (answer) {
if (answer.type !== 'PTR' || answer.name !== self._name || answer.name in nameMap) return
Expand All @@ -76,7 +76,7 @@ Browser.prototype.start = function () {
Object.keys(nameMap).forEach(function (name) {
goodbyes(name, packet).forEach(self._removeService.bind(self))

var matches = buildServicesFor(name, packet, self._txt)
var matches = buildServicesFor(name, packet, self._txt, rinfo)
if (matches.length === 0) return

matches.forEach(function (service) {
Expand Down Expand Up @@ -132,7 +132,7 @@ function goodbyes (name, packet) {
})
}

function buildServicesFor (name, packet, txt) {
function buildServicesFor (name, packet, txt, rinfo) {
var records = packet.answers.concat(packet.additionals).filter(function (rr) {
return rr.ttl > 0 // ignore goodbye messages
})
Expand All @@ -158,6 +158,7 @@ function buildServicesFor (name, packet, txt) {
service.name = name
service.fqdn = rr.name
service.host = rr.data.target
service.rinfo = rinfo
service.port = rr.data.port
service.type = types.name
service.protocol = types.protocol
Expand Down