mirror of
https://git.FreeBSD.org/ports.git
synced 2024-11-21 00:25:50 +00:00
Add Perl module for managing an OpenVPN process via its management port,
with custom patch that introduces new method to return active connection status information as a hash to hashes. Submitted by: Zeus Panchenko <zeus@gnu.org.ua>
This commit is contained in:
parent
d622d9caa6
commit
800d5ac014
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=393856
@ -217,6 +217,7 @@
|
||||
SUBDIR += p5-Net-IPv6Addr
|
||||
SUBDIR += p5-Net-NSCA-Client
|
||||
SUBDIR += p5-Net-Netmask
|
||||
SUBDIR += p5-Net-OpenVPN-Manage
|
||||
SUBDIR += p5-Net-SNMP
|
||||
SUBDIR += p5-Net-SNMP-Util
|
||||
SUBDIR += p5-Net-SNMPTrapd
|
||||
|
20
net-mgmt/p5-Net-OpenVPN-Manage/Makefile
Normal file
20
net-mgmt/p5-Net-OpenVPN-Manage/Makefile
Normal file
@ -0,0 +1,20 @@
|
||||
# $FreeBSD$
|
||||
|
||||
PORTNAME= Net-OpenVPN-Manage
|
||||
PORTVERSION= 0.02
|
||||
CATEGORIES= net-mgmt perl5
|
||||
MASTER_SITES= CPAN
|
||||
PKGNAMEPREFIX= p5-
|
||||
|
||||
MAINTAINER= perl@FreeBSD.org
|
||||
COMMENT= Manage an OpenVPN process via its management port
|
||||
|
||||
LICENSE= ART10 GPLv2
|
||||
LICENSE_COMB= dual
|
||||
|
||||
RUN_DEPENDS= p5-Net-Telnet>=0:${PORTSDIR}/net/p5-Net-Telnet
|
||||
|
||||
USES= perl5
|
||||
USE_PERL5= configure
|
||||
|
||||
.include <bsd.port.mk>
|
2
net-mgmt/p5-Net-OpenVPN-Manage/distinfo
Normal file
2
net-mgmt/p5-Net-OpenVPN-Manage/distinfo
Normal file
@ -0,0 +1,2 @@
|
||||
SHA256 (Net-OpenVPN-Manage-0.02.tar.gz) = b7fd691c24e4fbc78c2af992550abc96bf0db48d6f9e1406f0ebcb22ba0eeb57
|
||||
SIZE (Net-OpenVPN-Manage-0.02.tar.gz) = 12066
|
@ -0,0 +1,104 @@
|
||||
--- lib/Net/OpenVPN/Manage.pm.orig 2006-07-10 18:21:19 UTC
|
||||
+++ lib/Net/OpenVPN/Manage.pm
|
||||
@@ -1,3 +1,5 @@
|
||||
+# -*- mode: cperl; mode: follow; -*-
|
||||
+
|
||||
package Net::OpenVPN::Manage;
|
||||
|
||||
use strict;
|
||||
@@ -217,6 +219,84 @@ sub status_ref() {
|
||||
return $ref;
|
||||
}
|
||||
|
||||
+# $hash_ref = $vpn->status_hash();
|
||||
+sub status_hash() {
|
||||
+ my $ref;
|
||||
+ my $self = shift;
|
||||
+ my $arg = 2;
|
||||
+ my $telnet = $self->{objects}{_telnet_};
|
||||
+ my @output = $telnet->cmd(String => 'status '.$arg, Prompt => '/(SUCCESS:.*\n|ERROR:.*\n|END.*\n)/');
|
||||
+ unless ($telnet->last_prompt =~ /(SUCCESS:.*|END.*\n)/){
|
||||
+ $self->{error_msg} = $telnet->last_prompt();
|
||||
+ return 0;
|
||||
+ }
|
||||
+ unless ($telnet->last_prompt =~ /END.*\n/){
|
||||
+ return $telnet->last_prompt();
|
||||
+ }
|
||||
+ my ( $i, @arr );
|
||||
+ foreach my $ln ( @output ){
|
||||
+ chomp $ln;
|
||||
+ if (( $ln eq '' ) || ( $ln =~ /^\s*$/ )){
|
||||
+ next;
|
||||
+ } elsif ( $ln =~ s/^(CLIENT_LIST),// ) {
|
||||
+ @arr = split ',', $ln;
|
||||
+ chomp @arr;
|
||||
+ $ref->{$1}->{$arr[0]} = {
|
||||
+ ip_real => $arr[1],
|
||||
+ ip_virt => $arr[2],
|
||||
+ b_recv => $arr[3],
|
||||
+ b_sent => $arr[4],
|
||||
+ ts => $arr[5],
|
||||
+ ts_s => $arr[6],
|
||||
+ name => $arr[7],
|
||||
+ };
|
||||
+ undef @arr;
|
||||
+ } elsif ( $ln =~ s/^(ROUTING_TABLE),// ) {
|
||||
+ @arr = split ',', $ln;
|
||||
+ chomp @arr;
|
||||
+ $ref->{$1}->{$arr[1]} = {
|
||||
+ ip_virt => $arr[0],
|
||||
+ ip_real => $arr[2],
|
||||
+ ts => $arr[3],
|
||||
+ ts_s => $arr[4],
|
||||
+ };
|
||||
+ undef @arr;
|
||||
+ } elsif ( $ln =~ /^HEADER,ROUTING_TABLE/ ) {
|
||||
+ @arr = split ',', $ln;
|
||||
+ chomp @arr;
|
||||
+ $ref->{HEADER}->{$arr[1]} = {
|
||||
+ ip_virt => 'Virtual Address',
|
||||
+ cn => 'Common Name',
|
||||
+ ip_real => 'Real Address',
|
||||
+ ts => 'Last Ref',
|
||||
+ ts_s => 'Last Ref (time_t)',
|
||||
+ };
|
||||
+ undef @arr;
|
||||
+ } elsif ( $ln =~ /^HEADER,CLIENT_LIST/ ) {
|
||||
+ @arr = split ',', $ln;
|
||||
+ chomp @arr;
|
||||
+ $ref->{HEADER}->{$arr[1]} = {
|
||||
+ cn => 'Common Name',
|
||||
+ ip_real => 'Real Address',
|
||||
+ ip_virt => 'Virtual Address',
|
||||
+ b_recv => 'Bytes Received',
|
||||
+ b_sent => 'Bytes Sent',
|
||||
+ ts => 'Connected Since',
|
||||
+ ts_s => 'Connected Since (time_t)',
|
||||
+ name => 'Username',
|
||||
+ };
|
||||
+ undef @arr;
|
||||
+ } elsif ( $ln =~ s/^(TITLE),// ){
|
||||
+ $ref->{$1}=$ln;
|
||||
+ } elsif ( $ln =~ s/^(TIME),// ){
|
||||
+ $ref->{$1}=$ln;
|
||||
+ } elsif ( $ln =~ s/^(GLOBAL_STATS),// ){
|
||||
+ $ref->{$1}=$ln;
|
||||
+ }
|
||||
+ }
|
||||
+ return $ref;
|
||||
+}
|
||||
+
|
||||
# Not implemented
|
||||
sub test {
|
||||
my $self = shift;
|
||||
@@ -478,6 +558,10 @@ If called without an argument, it will r
|
||||
# Print the connection status page using the version 2 format.
|
||||
print $vpn->status(2);
|
||||
|
||||
+=item $vpn->status_hash( );
|
||||
+
|
||||
+Returns the active connections status information as a hash to hashes.
|
||||
+
|
||||
=item $vpn->status_ref( );
|
||||
|
||||
Returns the active connections status information as a reference to a hash of arrays.
|
4
net-mgmt/p5-Net-OpenVPN-Manage/pkg-descr
Normal file
4
net-mgmt/p5-Net-OpenVPN-Manage/pkg-descr
Normal file
@ -0,0 +1,4 @@
|
||||
This module connects to the OpenVPN management interface, executes commands
|
||||
on the interface, and returns the results or errors that result.
|
||||
|
||||
WWW: http://search.cpan.org/dist/Net-OpenVPN-Manage/
|
3
net-mgmt/p5-Net-OpenVPN-Manage/pkg-plist
Normal file
3
net-mgmt/p5-Net-OpenVPN-Manage/pkg-plist
Normal file
@ -0,0 +1,3 @@
|
||||
%%PERL5_MAN3%%/Net::OpenVPN::Manage.3.gz
|
||||
%%SITE_PERL%%/Net/OpenVPN/Manage.html
|
||||
%%SITE_PERL%%/Net/OpenVPN/Manage.pm
|
Loading…
Reference in New Issue
Block a user