diff options
Diffstat (limited to 'lib/network/vpn/vpnc.pm')
-rw-r--r-- | lib/network/vpn/vpnc.pm | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/lib/network/vpn/vpnc.pm b/lib/network/vpn/vpnc.pm new file mode 100644 index 0000000..c7a87c7 --- /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, + }, + 'NAT Traversal Mode' => { + label => N("NAT Mode"), + list => [ '', qw(natt none force-natt cisco-udp) ], + val => \$connection->{udp}, + advanced => 1, + }, + 'Cisco UDP Encapsulation Port' => { + label => N("Use specific UDP port"), + val => \$connection->{udp_port}, + advanced => 1, + }, + ); +} + +1; |