From c0b608289bc2d83c78060620d5b29e7e1e273fc9 Mon Sep 17 00:00:00 2001 From: phoomin2012 Date: Sun, 21 Feb 2021 11:03:07 +0700 Subject: [PATCH 1/3] Handle discover address is false If _selectAddress method return false. The server will ignore to reply to host. --- lib/dhcp.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/dhcp.js b/lib/dhcp.js index e009e81..dff669f 100644 --- a/lib/dhcp.js +++ b/lib/dhcp.js @@ -287,7 +287,10 @@ Server.prototype = { } else if (_static[clientMAC]) { return _static[clientMAC]; } - + + const _ignoreRange = this.config('ignoreRange'); + if(_ignoreRange) + return false; const randIP = this.config('randomIP'); const _tmp = this.config('range'); @@ -363,7 +366,9 @@ Server.prototype = { lease.server = this.config('server'); lease.state = 'OFFERED'; - this.sendOffer(req); + if(lease.addres) { + this.sendOffer(req); + } }, sendOffer: function(req) { @@ -408,7 +413,9 @@ Server.prototype = { lease.state = 'BOUND'; lease.bindTime = new Date; - this.sendAck(req); + if(lease.addres) { + this.sendAck(req); + } }, sendAck: function(req) { //console.log('Send ACK'); From e3995f7ea72c1da7cc4be26ee125fbee95348fb4 Mon Sep 17 00:00:00 2001 From: phoomin2012 Date: Sun, 21 Feb 2021 11:17:05 +0700 Subject: [PATCH 2/3] Fix miss spelling --- lib/dhcp.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/dhcp.js b/lib/dhcp.js index dff669f..68f4adb 100644 --- a/lib/dhcp.js +++ b/lib/dhcp.js @@ -366,7 +366,7 @@ Server.prototype = { lease.server = this.config('server'); lease.state = 'OFFERED'; - if(lease.addres) { + if(lease.address) { this.sendOffer(req); } }, @@ -413,7 +413,7 @@ Server.prototype = { lease.state = 'BOUND'; lease.bindTime = new Date; - if(lease.addres) { + if(lease.address) { this.sendAck(req); } }, From 7730a2b61f7dba201a5924f6936fcff8366c43a3 Mon Sep 17 00:00:00 2001 From: phoomin2012 Date: Sun, 21 Feb 2021 11:18:03 +0700 Subject: [PATCH 3/3] Add ignore range to options --- lib/options.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/options.js b/lib/options.js index b5f597a..5b0c168 100644 --- a/lib/options.js +++ b/lib/options.js @@ -537,6 +537,12 @@ const opts = { type: 'Bool', config: 'randomIP', default: true + }, + 9999: { + name: 'Ignore Range', + type: 'Bool', + config: 'ignoreRange', + default: false } };