Skip to content

Commit

Permalink
Add hostname (if any) to -L output
Browse files Browse the repository at this point in the history
  • Loading branch information
tlhackque committed May 14, 2021
1 parent 2a0c3bf commit 91a389a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Make sure that the directory containing `ipblock` is in your **PATH**
Read the disclaimer before running the `ipblock` command.

## License and Disclaimer
Copyright (c) 2017, 2018, 2019, 2020 Timothe Litt
Copyright (c) 2017, 2018, 2019, 2020, 2021 Timothe Litt

This is free software; the author disclaims all responsibility for its use, reliability and consequences. The name of the author may not be used to endorse any product, but must be retained in the documentation and code. Any modifications must be clearly documented and attributed, and are the responsibility of their author.

Expand Down
19 changes: 15 additions & 4 deletions ipblock
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

# Copyright (C) 2017, 2018, 2020 Timothe Litt litt at acm ddot org
# Copyright (C) 2017, 2018, 2020, 2021 Timothe Litt litt at acm ddot org

# Completely & quickly block specific ip address(es)

VERSION="1.004"
VERSION="1.005"

SELF="`basename $0`"

Expand Down Expand Up @@ -317,6 +317,17 @@ if [ "$ACTION" == "list" ]; then
while read LINE ; do
TOT=$(( $TOT + 1 ))
IP="`echo "$LINE" | sed -e's/^src=\([^ ]*\) .*$/\1/'`"
HN="`2>/dev/null host $IP`"
if [ "$?" -eq 0 ]; then
HN="`echo "$HN" | sed -e's/^.*\.arpa domain name pointer \(.*\).$/\1/'`"
if [ -n "$HN" ]; then
HN=" ($HN)"
else
HN=
fi
else
HN=
fi
# Last seen in jiffies
SEEN="$( echo "$LINE" | sed -e's/.*last_seen: *\([0-9][0-9]*\) .*$/\1/' )"
# Now in jiffies
Expand All @@ -331,9 +342,9 @@ if [ "$ACTION" == "list" ]; then
else # Use default (ctime) format
DATE="$( date -d@$SSE )"
fi
[ -n "$DEBUG" ] && echo "IP: $IP NOW: $NOW JIFF: $JIFF SEEN: $SEEN TICKS: $TICKS DATE: $DATE"
[ -n "$DEBUG" ] && echo "IP: $IP NOW: $NOW JIFF: $JIFF SEEN: $SEEN TICKS: $TICKS DATE: $DATE$HN"

echo "$IP $( expr substr $Dots 1 $( expr length $Dots - length $IP ) ) $DATE"
echo "$IP $( expr substr $Dots 1 $( expr length $Dots - length $IP ) ) $DATE$HN"
done

if [ -n "$V" ]; then
Expand Down

0 comments on commit 91a389a

Please sign in to comment.