infusion / node-dhcp

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

Crashes or stops listening when all IPs reserved #78

Open kr4967 opened 11 months ago

kr4967 commented 11 months ago

Dhcp server crashes if all IP addresses are bound. In dhcp.js file _selectAddress function's random ip function gets in infinite loop or _selectAddress doesn't return anything, causing undefined in yiaddr.

kr4967 commented 11 months ago

In dhcp.js at rows 308 and 309 this._state[mac].leaseTime should be this._state[mac].bindTime? At row 319 the if statement (oldestMac !== null && lastIP - firstIP === leases) is wrong too. Doesn't work that way.