summaryrefslogtreecommitdiff
path: root/src/op_mode/execute_bandwidth_test.sh
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-09-12 05:27:29 +0000
committerGitHub <noreply@github.com>2024-09-12 05:27:29 +0000
commitdc7abeb08f4bfe9bd1b3106ba45692c7490d20a6 (patch)
tree92bcae06233c5b1b1cb3f1f9661eacd5a99c5413 /src/op_mode/execute_bandwidth_test.sh
parent4d2d4311f12c7466edc904be41ec4e716021e791 (diff)
parent65622a733df80ecee2192f3cd5758a27e4324b3b (diff)
downloadvyos-1x-dc7abeb08f4bfe9bd1b3106ba45692c7490d20a6.tar.gz
vyos-1x-dc7abeb08f4bfe9bd1b3106ba45692c7490d20a6.zip
Merge pull request #4042 from natali-rs1985/T6694-current
op-mode: T6694: Move some op-mode commands to the "execute" family
Diffstat (limited to 'src/op_mode/execute_bandwidth_test.sh')
-rwxr-xr-xsrc/op_mode/execute_bandwidth_test.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/op_mode/execute_bandwidth_test.sh b/src/op_mode/execute_bandwidth_test.sh
new file mode 100755
index 000000000..a6ad0b42c
--- /dev/null
+++ b/src/op_mode/execute_bandwidth_test.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+#
+# Copyright (C) 2020 VyOS maintainers and contributors
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 or later as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+if ipaddrcheck --is-ipv6 $1; then
+ # Set address family to IPv6 when an IPv6 address was specified
+ OPT="-V"
+elif [[ $(dig $1 AAAA +short | grep -v '\.$' | wc -l) -gt 0 ]]; then
+ # CNAME is also part of the dig answer thus we must remove any
+ # CNAME response and only shot the AAAA response(s), this is done
+ # by grep -v '\.$'
+
+ # Set address family to IPv6 when FQDN has at least one AAAA record
+ OPT="-V"
+else
+ # It's not IPv6, no option needed
+ OPT=""
+fi
+
+/usr/bin/iperf $OPT -c $1 $2
+