
Show HN: DHCP as a file system – an experiment with Go and FUSE - hnlmorg
https://github.com/lmorg/dhcpdfs
======
vezzy-fnord
Any reason for preferring FUSE over 9P?

~~~
tobik
Yes, FUSE works on OS X, Android, the BSDs and Linux.

~~~
vezzy-fnord
So does 9P. It's just a protocol, at the end of the day.

FUSE is actually specific to the Linux VFS subsystem. However, there have been
many reimplementations on the API compatibility level, even though there is no
formal standard beyond the header file, which has seen several divergences.

------
mirceal
interesting idea. if it's an excuse to play with something all for it. that
being said: parsing isc dhcp lease files is a can of worms you probably don't
want to open.

to give you an example: what happens if the same machine appears twice in the
lease file? what happens if some of the fields you are reading are missing?
(let's say do you don't have a hostname)

~~~
hnlmorg
I do a lazy dedup using a map, so only the latest entry will be stored. As all
the data is output as ASCII, missing fields are just outputted as zero length
strings.

Those particular obstacles proved quiet easy to work around, but I fully
expect there's other hidden traps I've overlooked. So I'm welcome to other
suggestions for retrieving lease information :)

~~~
mirceal
sure. as a side project there're nothing wrong with it :)

I was just pointing out the pitfalls of lease parsing (i've been bitten by
this over the course of time - it looks trivial to do until you look at what
isc does under the covers)

side questions: what happens with 50000 leases? what about 50000 subnets - do
you have support for hierarchically displaying subnets :) how fast is the
whole thing? can you handle malformed input?

~~~
hnlmorg
It's really basic at the moment so there's no support for hierarchical
subnets, but it's something this that might suit this kind display.

Performance wise, it's definitely not ready for any serious use. However there
are some easy wins I didn't bother with that would dramatically speed things
up (eg the leases file is read with each FUSE API request - which happens _a
lot_. So I really should be running that as a separate thread that runs every
x minutes and caches the object.

if Im honest, scalability was a secondary concern. I was more interested in
building a working proof of concept and sadly only had one afternoon to do it
in. But I tried to keep the code clean enough (though you can be the judge of
that) so it could be scaled up at a later date if needed.

~~~
mirceal
it's cool. the leap from prototype to production-ready is always a big one.

------
therobot24
The readme doesn't have much to it, and since i'm not particularly network
savvy, can someone explain how this works exactly?

~~~
hnlmorg
Author here, the utility isn't that exciting to be honest. Basically it just
reads the _leases_ file that isc-dhcpd spits out, and displays the machines in
a directory hierarchy via a virtual file system (this is where FUSE comes into
play).

It's an alternative approach to the HTML output that home routers display on
their DHCP management pages. Arguably less useful approach, but I wanted an
excuse to play with FUSE.

