infusion / node-dhcp

A DHCP server and client written in pure JavaScript
https://raw.org/article/a-pure-javascript-dhcp-implementation/
MIT License
297 stars 75 forks source link

bootFile: function(){} arguments not passed #50

Closed mStirner closed 5 years ago

mStirner commented 5 years ago

Hello,

the options function doesnt work. The arguments are not passed.

// merge options
let options = merge({
  range: ["172.16.0.100", "172.16.0.200"],
  netmask: "255.255.255.0",
  router: ["172.16.0.254"],
 ...
  domainName: "magic-boot.lan",
  bootFile: function (req, res) {

  // req & res = undefined

    console.log("-- BOOTFILE", arguments);
    return "pxelinux.0"

  }
}, config.options);

So the example/server.js dosnt work neither:

if (req.clientId === 'foo bar') { ^ TypeError: Cannot read property 'clientId' of undefined

Problem seems for me this line: https://github.com/infusion/node-dhcp/blob/master/lib/dhcp.js#L144

infusion commented 5 years ago

Thanks a lot for bringing this up! I fixed it with the latest commit. Could you please test it? If it works, I will push a new release on npm.

mStirner commented 5 years ago

Hey, sorry, i was very bussy the last two days, and couldnt find any time to test it, until now.

Seems to work, but you have a console.log (for debugging?) here: https://github.com/infusion/node-dhcp/blob/master/lib/dhcp.js#L88

Thanks, for the fix!

infusion commented 5 years ago

Thanks for pointing out the console.log, removed