From 1d37bfdbbe874abd6dcb5563eea19f531de09e1c Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Fri, 25 May 2007 15:39:46 +0000 Subject: sync with 2007.1 (because of SVN loss) --- lib/network/vpn/vpnc.pm | 74 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 lib/network/vpn/vpnc.pm (limited to 'lib/network/vpn/vpnc.pm') diff --git a/lib/network/vpn/vpnc.pm b/lib/network/vpn/vpnc.pm new file mode 100644 index 0000000..f0c8369 --- /dev/null +++ b/lib/network/vpn/vpnc.pm @@ -0,0 +1,74 @@ +package network::vpn::vpnc; + +use base qw(network::vpn); + +use strict; +use common; + +sub get_type { 'vpnc' } +sub get_description { N("Cisco VPN Concentrator") } +sub get_packages { 'vpnc' } + +sub read_config { + my ($connection) = @_; + my @fields = group_by2(list_fields($connection)); + foreach (cat_($connection->get_config_path)) { + foreach my $field (@fields) { + # all strings start exactly one space after the keyword string + /^$field->[0] (.*)/ and ${$field->[1]{val}} = $1; + } + } +} + +sub write_config { + my ($connection) = @_; + output_with_perm($connection->get_config_path, 0600, map { + if_(${$_->[1]{val}}, $_->[0], ' ', ${$_->[1]{val}}, "\n"); + } group_by2(list_fields($connection))); +} + +sub get_settings { + my ($connection) = @_; + second(list2kv(list_fields($connection))); +} + +sub list_fields { + my ($connection) = @_; + ( + 'IPSec gateway' => { + label => N("Gateway"), + val => \$connection->{gateway}, + }, + 'IPSec ID' => { + label => N("Group name"), + val => \$connection->{id}, + }, + 'IPSec secret' => { + label => N("Group secret"), + val => \$connection->{secret}, + hidden => 1, + }, + 'Xauth username' => { + label => N("Username"), + val => \$connection->{username}, + }, + 'Xauth password' => { + label => N("Password"), + val => \$connection->{password}, + hidden => 1, + }, + 'UDP Encapsulate' => { + text => N("Use Cisco-UDP encapsulation"), + type => 'bool', + val => \$connection->{udp}, + advanced => 1, + }, + 'UDP Encapsulation Port' => { + label => N("Use specific UDP port"), + val => \$connection->{udp_port}, + advanced => 1, + }, + ); +} + +1; -- cgit v1.2.1