Skip to content

Commit

Permalink
Update proxy.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
roelbroersma authored Jun 8, 2024
1 parent d90ac9e commit 0cbfd1e
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions proxy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,22 @@ check_root_and_capabilities
if [ $? -eq 1 ]; then
echo "#########################################################################"
echo "### This script must be run as root or with CAP_NET_ADMIN capability. ###"
echo "### We will continue but are unable to set host routes. ###"
echo "### We will continue but host routes are probably no set correctly. ###"
echo "#########################################################################"
else
# BECAUSE THE RECEIVER MIGHT HAVE MULTIPLE INTERFACES, WE NEED TO MAKE SURE TO ROUTE OUT THE MULTICAST VIA THE CORRECT INTERFACE (WHICH IS THE $FROM_IP_OR_INTERFACE).
# (NOTE THAT THIS ROUTE WILL BE APPLIED TO THE WHOLE HOST BECAUSE IT USES THE HOST NETWORK INTERFACE)
echo "Adding route to $MULTICAST_ADDRESS via $FROM_IP_OR_INTERFACE..."
if echo "$FROM_IP_OR_INTERFACE" | grep -Eq '^([0-9]{1,3}\.){3}[0-9]{1,3}$'; then
route add -host $MULTICAST_ADDRESS gw $FROM_IP_OR_INTERFACE
else
route add -host $MULTICAST_ADDRESS dev $FROM_IP_OR_INTERFACE
fi
fi

# REMOVE THE ROUTES WHEN THIS SCRIPT OR DOCKER CONTAINER STOPS
trap remove_routes EXIT
# BECAUSE THE RECEIVER MIGHT HAVE MULTIPLE INTERFACES, WE NEED TO MAKE SURE TO ROUTE OUT THE MULTICAST VIA THE CORRECT INTERFACE (WHICH IS THE $FROM_IP_OR_INTERFACE).
# (NOTE THAT THIS ROUTE WILL BE APPLIED TO THE WHOLE HOST BECAUSE IT USES THE HOST NETWORK INTERFACE)
echo "Adding route to $MULTICAST_ADDRESS via $FROM_IP_OR_INTERFACE..."
if echo "$FROM_IP_OR_INTERFACE" | grep -Eq '^([0-9]{1,3}\.){3}[0-9]{1,3}$'; then
route add -host $MULTICAST_ADDRESS gw $FROM_IP_OR_INTERFACE
else
route add -host $MULTICAST_ADDRESS dev $FROM_IP_OR_INTERFACE
fi

# REMOVE THE ROUTES WHEN THIS SCRIPT OR DOCKER CONTAINER STOPS
trap remove_routes EXIT

# START SENDER AND RECEIVER
start_sender
start_receiver
Expand Down

0 comments on commit 0cbfd1e

Please sign in to comment.