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

Preventing some errors and showing all leases without search #39

Merged
merged 2 commits into from
Jan 7, 2020

Conversation

mhoffmann75
Copy link
Contributor

split would have caused errors on malformed dhcp data.
dhcp leases should be shown without searching.

if dhcp leases contain malformed data split would have caused errors
Fire up search automatically showing all leases without manually filtering
@@ -10,7 +10,7 @@ router.get('/', function (req, res, next) {

/* Mac OUI Lookup */
var mac_oui = "";
if (typeof dhcp_lease_data[key].mac.split(":").join("") !== "undefined") {
if (typeof dhcp_lease_data[key].mac !== "undefined") {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While when I wrote this the parser should always have a mac address going into this that is valid, but it doesn't hurt to validate before accessing.

I would check if mac is undefined and contains a : before doing the split again

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for you answer.
Yes, you're absolutely right in theory EVERY entry in the dhcp servers table should have a mac address (Doesnt make sense to have a lease with no mac at all). Guess how surprised i was that in our network suddenly a lease (IP) occured with no mac addrsss. Making glass failing with error "split on undefined". Don't know how this actually occured or if its a bug in isc dhcp. But i needed to solve this.
Thats why i made this patch.

Copy link

@dsgagi dsgagi Aug 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could happen if DHCP server is not located in the same subnet as the client (like when using dhcp helper/relay), and lease gets abandoned. Here is an example below.

lease 192.168.134.94 {
  starts 5 2019/08/30 10:26:33;
  ends 6 2019/08/31 10:26:33;
  tstp 6 2019/08/31 10:26:33;
  cltt 5 2019/08/30 10:26:33;
  binding state abandoned;
  next binding state free;
  rewind binding state free;
  client-hostname "HUAWEI_Mate_20_Pro-de3aae";
}

Copy link

@atownsend247 atownsend247 Dec 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've also come across this when setting up isc-dhcp-server with a failover pair as it adds backup leases in like the below as an example.

lease 10.0.0.127 {
  starts 3 2019/10/30 13:30:37;
  tstp 3 2019/10/30 13:30:37;
  tsfp 3 2019/10/30 13:30:37;
  atsfp 3 2019/10/30 13:30:37;
  binding state backup;
}

@Akkadius Akkadius merged commit 10102a6 into Akkadius:master Jan 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants