question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Several addons are not doing broadcast packets correctly

See original GitHub issue

Several addons are not doing discovery via broadcast packets correctly. They hardcode 255.255.255.255 which will not work on all networks. Since the method of getting the correct broadcast addresses is non-trivial to get right I’d propose putting it in a common location for use by addons needing to use broadcast packets.

Where would be the preferred location for this common code? Would it be preferred that the addon simply provides a packet contents and a callback function and the rest is handled by common code or would it be preferred that the common code just gets the broadcast addresses?

For reference, here is the code I came up with to find the addresses:

    private List<InetAddress> getBroadcastAddresses() {
        ArrayList<InetAddress> addresses = new ArrayList<>();

        System.setProperty("java.net.preferIPv4Stack", "true");

        try {
            for (NetworkInterface iface : Collections.list(NetworkInterface.getNetworkInterfaces())) {
                try {
                    if (iface.isLoopback()) {
                        logger.debug("Found loopback iface {}", iface.getName());
                        continue;
                    }

                    logger.debug("Found non-loopback iface {} with {} addresses", iface.getName(),
                            iface.getInterfaceAddresses().size());

                    for (InterfaceAddress address : iface.getInterfaceAddresses()) {
                        InetAddress broadcastAddress = address.getBroadcast();
                        if (broadcastAddress != null) {
                            logger.debug("Found broadcast address {} for iface {}", address.getBroadcast().toString(),
                                    iface.getName());
                            addresses.add(address.getBroadcast());
                        }
                    }
                } catch (SocketException e) {
                    logger.debug("Got exception in getBroadcastAddress", e);
                }
            }
        } catch (SocketException e) {
            logger.debug("Got exception in getBroadcastAddress", e);
        }

        try {
            // Add the default broadcast address as a fallback.
            addresses.add(InetAddress.getByName("255.255.255.255"));
        } catch (UnknownHostException e) {
        }
        return addresses;
    }

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
caffineehackercommented, Jan 7, 2018

Looks like Kai reverted my change (thanks!) so we’re at least not breaking anyone at the moment. I don’t know if it makes sense to have each and every addon decide if they want to broadcast on a single interface or all the interfaces as that would just leave a lot of inconsistency. In particular, anyone with multiple NICs might have a hard time using some addons while others would work fine. I’d push to have all addons iterate over the broadcast addresses and broadcast widely.

That said, since the change has been made to the NetUtil package we can probably roll forward again. I’ll create a pull release (probably not until next weekend) that incorporates my original changes unless there are objections.

0reactions
caffineehackercommented, Jan 15, 2018

I don’t have a personal use case that would require multiple broadcast addresses, just a theoretical case where the user has two subnets on their network that they need to broadcast to (or two network interfaces attached to the board such as would be the case if the user want to isolate their home automation network from their internet network and only have the openHab machine be in between). That said, these should be fairly uncommon examples so the current utility function should be good enough (also note that we could always put the standard UDP broadcast and handle code in a utility function which would make updating this kind of behavior much easier in the future if we do decide we want more than one network interface to be supported).

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I broadcast OSC messages to multiple RasPi's on my ...
I found an app released by ETCLabs called OSC Widgets. It has an option to send OSC packets over UDP. I tested it...
Read more >
Hide Message "Several add-ons aren't compatible with ...
Hi Tony Frernandes,. It seems that the add-ons are not compatible with the " Enhanced Protected Mode " feature of Internet Explorer ....
Read more >
Premium pack changelog | Broadcast - Plainview Plugins
The changelog for the Wordpress Broadcast Premium add-on pack. ... LearnDash: Fix quizzes not being properly broadcasted due to new database table names....
Read more >
Upgrading your account and add-ons - Zoom Support
You can upgrade your Zoom plan at any time. If you upgrade in the middle of the billing period, the account will be...
Read more >
Guidelines on firewalls and firewall policy - GovInfo
Generally, all inbound and outbound traffic not expressly permitted by the ... many technologies often associated with firewalls are more accurately part of....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found