diff options
author | Simon Rettberg | 2019-10-28 18:13:13 +0100 |
---|---|---|
committer | Simon Rettberg | 2019-10-28 18:13:13 +0100 |
commit | 18eafbfbeb19833cc762d32e7435b40f51f8adf0 (patch) | |
tree | c0ff962cbe3fe0a3ccdd6f2eb0ff5733a363fd40 | |
parent | Add mem module (diff) | |
download | slx-tools-18eafbfbeb19833cc762d32e7435b40f51f8adf0.tar.gz slx-tools-18eafbfbeb19833cc762d32e7435b40f51f8adf0.tar.xz slx-tools-18eafbfbeb19833cc762d32e7435b40f51f8adf0.zip |
Add net module (net_resolve_v4 for now)v27
-rw-r--r-- | modules/net.inc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/modules/net.inc b/modules/net.inc new file mode 100644 index 0000000..e7c9dfc --- /dev/null +++ b/modules/net.inc @@ -0,0 +1,9 @@ +#!/bin/ash + +net_resolve_v4() { + if command -v dig &> /dev/null; then + printf "%s " $( busybox timeout -t 2 dig +short "$1" | grep -E '^[0-9.]+$' ) + elif command -v nslookup &> /dev/null; then + printf "%s " $( LC_ALL=C busybox timeout -t 2 nslookup "$1" 2>/dev/null | grep -A 4 '^Name:' | grep -E '^Address\s*[0-9]*: ' | awk -F': ' '{print $2}' | grep -oE '^[0-9]+\.[0-9.]+(\s|$)' ) + fi +} |