MartijnBraam / python-isc-dhcp-leases

Small python module for reading /var/lib/dhcp/dhcpd.leases from isc-dhcp-server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Format host_identifier, iaid and duid as colon-separated hex strings

jjakob opened this issue · comments

This would then equal the format that dhcpd.conf takes as identifier, so the values could be used to directly transfer to host blocks.

We are using this library in vyos to display the leases in a user friendly format, which requires additional parsing inside our script to add the colons. show_dhcpv6.py#L49

I'll check if I can add that functionality without breaking the existing api

If you set

lease-id-format hex;

in dhcpd6.conf you will get the proper results, but it does seem that the parsing does not work in this library due to the regex match:

    regex_leaseblock6 = re.compile(
        r"ia-(?P<type>ta|na|pd) \"(?P<id>[^\"\\]*(?:\\.[^\"\\]*)*)\" {(?P<config>[\s\S]+?)\n}")

with a lease such as this:

ia-na 03:00:00:00:00:03:00:01:18:fd:74:8f:3e:46 {
  cltt 5 2024/05/31 01:28:56;
  iaaddr 2001:db8:3::ffbb {
    binding state active;
    preferred-life 604800;
    max-life 2592000;
    ends 0 2024/06/30 01:28:56;
    set cid = "b4fbe41b4a18/3/70a741336758/1:100";
    on release {
      log (error, 
          concat ("RELEASE6 from", cid));
    }
  }
}

while the previous octal output and match works. I'm hoping that @MartijnBraam could make that match work as well :-)