Files
rap/lib/exec/unknown-peers
2020-06-10 20:54:57 -03:00

47 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# lib/exec/unknown-peers
#
# Copyright (c) 2020- RAP <contacto@partidopirata.com.ar>
# Copyright (c) 2011-2016 LibreVPN <vpn@hackcoop.com.ar>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# 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 Affero General
# Public License along with this program. If not, see
# <http://www.gnu.org/licenses/>.
#
#
# Lista los pares desconocidos
. "${LVPN_LIBDIR}"/common
requires sort uniq grep tr
while getopts "dhc" arg; do
case $arg in
h) help ${self} ; exit 0;;
c) count="-c" ;;
esac
done
let OPTIND--; shift ${OPTIND}
log="${1:-/var/log/tinc.${NETWORK}.log}"
if ! test -f "${log}"; then
fatal_error "El archivo de log no existe. Tip: Hay que iniciar tinc con --logfile"
fi
test ! -z "${count}" && msg "Pares desconocidos: ${count}"
grep "Peer .* had unknown identity " ${log} 2>/dev/null \
| grep -o "([^)]\+)" | sort | tr -d "[()]" | uniq ${count}
exit $?