Added exit code and fixed bug in do_one function.

I reimplemented functionality to allow this script to be called directly from CLI.

I also added an exit code to have it be a bit more useful.

After forking your code, I found that there was a missing parameter in one of the times you called socket.inet_ntop(), so I added it.