Skip to content

Commit

Permalink
feat (openvpn_clients): add pfsense agent plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
gianlucastella1 authored Nov 24, 2023
1 parent 8d263fb commit fd5d3c9
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions openvpn_clients/agents/plugins/openvpn_clients.pfsense
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/local/bin/bash

# (c) 2022 Heinlein Support GmbH
# Robert Sander <[email protected]>
#
# pfSense edition by
# Gianluca Stella <gianluca (dot) stella (at) gmail . com>


# This is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation in version 2. This file is distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more de-
# ails. You should have received a copy of the GNU General Public
# License along with GNU Make; see the file COPYING. If not, write
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.

if ls /var/run/openvpn_*.pid 1> /dev/null 2>&1; then

for f in /var/etc/openvpn/server*/sock
do
conffile="`echo $f | sed -n -e 's/sock/config.ovpn/p'`"
insta="`cat $conffile | grep \"dev \" | sed -n -e \"s/dev //p\"`"

status="`( echo \"status\" ; sleep 1 ; echo \"quit\" ) | nc -U $f`"

echo '<<<openvpn_clients:sep(44)>>>'
echo "[[$insta]]"
echo "$status" | sed -n -e '/CLIENT LIST/,/ROUTING TABLE/p' | sed -e 1,3d -e '$d'
done
fi

0 comments on commit fd5d3c9

Please sign in to comment.