1
# Copyright (C) 2007 Warp Networks S.L.
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License, version 2, as
5
# published by the Free Software Foundation.
7
# This program is distributed in the hope that it will be useful,
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
# GNU General Public License for more details.
12
# You should have received a copy of the GNU General Public License
13
# along with this program; if not, write to the Free Software
14
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
package EBox::OpenVPN::Model::ExposedNetworks;
22
use base 'EBox::Model::DataTable';
29
use EBox::Validate qw(:all);
30
use EBox::Exceptions::External;
31
use EBox::Exceptions::DataExists;
33
use EBox::Types::IPNetwork;
35
# Group: Public methods
41
my $self = $class->SUPER::new(@_);
49
__PACKAGE__->nameFromClass(),
52
# Group: Protected methods
58
new EBox::Types::IPNetwork(
59
fieldName => 'network',
60
printableName => __('Advertised network'),
68
'tableName' => __PACKAGE__->name(),
69
'printableTableName' => __('List of Advertised Networks'),
70
'automaticRemove' => 1,
71
'defaultController' => '/ebox/OpenVPN/Controller/ExposedNetworks',
72
'defaultActions' => ['add', 'del', 'editField', 'changeView' ],
73
'tableDescription' => \@tableHead,
74
'class' => 'dataTable',
75
'printableRowName' => __('Advertised network'),
76
'sortedBy' => 'network',
77
'modelDomain' => 'OpenVPN',
88
my ($self, $action, $changedFields) = @_;
90
if (not exists $changedFields->{network}) {
94
my $net = $changedFields->{network}->printableValue();
96
$self->parentRow()->elementByName('configuration')->foreignModelInstance();
97
my $vpn = $serverConf->row()->elementByName('vpn')->printableValue();
100
throw EBox::Exceptions::External(
101
__('The advertised network address could not be the same than the VPN address' )
111
# Overrides <EBox::Model::DataTable::pageTitle>
112
# to show the name of the domain
117
return $self->parentRow()->printableValueByName('name');
121
# Group: Private methods
123
# Return the help message
126
return __x('{openpar}You can add here those networks which you want to make ' .
127
'available to clients connecting to this VPN.{closepar}' .
128
'{openpar}Typically, you will allow access to your LAN by advertising' .
129
' its network address here{closepar}',
130
openpar => '<p>', closepar => '</p>');