]> git.nbdom.net Git - nb.git/commitdiff
resolve
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 30 Sep 2016 10:21:12 +0000 (11:21 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 30 Sep 2016 10:21:12 +0000 (11:21 +0100)
etc/profile.d/net.sh

index f0f5496d0cb341ac265ae65bc9938f3b7b3edbbd..c4c6c79f20060b28bfb31cce516091110f9eebfa 100644 (file)
@@ -1,3 +1,16 @@
+resolve() {
+  (
+    if [ -t 0 ]; then
+      while [ $# -gt 0 ]; do
+        printf '%s\n' "$1"
+        shift
+      done
+    else
+      cat
+    fi
+  ) | perl -MSocket -pe 's/(\b)(\d+(?:\.\d+){3})(\b)/$1.gethostbyaddr(inet_aton($2),AF_INET).$3/ge;'
+}
+
 mask2cdr ()
 {
    # Assumes there's no "255." after a non-255 byte in the mask