Skip to content

Commit

Permalink
prevent erroring out when there is no local broadcast tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelBender committed Feb 27, 2021
1 parent 08504dd commit af20a04
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions samples/UDPConsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,17 @@ def indication(self, pdu):

# check the address
if addr == "*":
if not local_broadcast_tuple:
sys.stderr.write("err: no local broadcast\n")
return

dest = local_broadcast_tuple
elif ':' in addr:
addr, port = addr.split(':')
if addr == "*":
if not local_broadcast_tuple:
sys.stderr.write("err: no local broadcast\n")
return
dest = (local_broadcast_tuple[0], int(port))
else:
dest = (addr, int(port))
Expand Down Expand Up @@ -234,6 +241,9 @@ def main():
if args.noBroadcast:
_log.debug(" - skipping broadcast")

elif not local_broadcast_tuple:
_log.debug(" - no local broadcast")

elif local_unicast_tuple == local_broadcast_tuple:
_log.debug(" - identical unicast and broadcast tuples")

Expand Down

0 comments on commit af20a04

Please sign in to comment.