derkarnold/pylifx — pull request #2 by micolous (2014-03-30 01:22:11+00:00)
Title: Fix for Issue #1: Only select interfaces that have a broadcast address available

This patch fixes issue #1, by only selecting available interfaces that have a broadcast address.

Before the patch, this was the output from `pylifx.networking.get_interfaces()`:

```pycon
>>> pylifx.networking.get_interfaces()
{
'en1': {'broadcast': '172.20.0.255', 'netmask': '255.255.255.0', 'addr': '172.20.0.30'},
'lo0': {'peer': '127.0.0.1', 'netmask': '255.0.0.0', 'addr': '127.0.0.1'}
}
```

After this patch is applied, the loopback interface is now excluded:

```pycon
>>> pylifx.networking.get_interfaces()
{'en1': {'broadcast': '172.20.0.255', 'netmask': '255.255.255.0', 'addr': '172.20.0.30'}}
```

This will still only use the first address with a broadcast assigned to an interface, which can cause problems with some complicated network configurations. However it is slightly better than the old method which would only use the first address assigned to an interface, regardless of whether it had a broadcast address.