diff options
author | Angelo Naselli <anaselli@linux.it> | 2015-12-26 22:03:34 +0100 |
---|---|---|
committer | Angelo Naselli <anaselli@linux.it> | 2015-12-26 22:03:34 +0100 |
commit | 20c694e77d1e179a661f28784b389ac592d0393d (patch) | |
tree | be9a9912dd1c86e9820142188b7b0da7f731685c /lib/ManaTools/Module/Firewall.pm | |
parent | f428879ec78ce46c6cfdad84db0a18e2e0bf88d3 (diff) | |
download | manatools-20c694e77d1e179a661f28784b389ac592d0393d.tar manatools-20c694e77d1e179a661f28784b389ac592d0393d.tar.gz manatools-20c694e77d1e179a661f28784b389ac592d0393d.tar.bz2 manatools-20c694e77d1e179a661f28784b389ac592d0393d.tar.xz manatools-20c694e77d1e179a661f28784b389ac592d0393d.zip |
Acting as ConfigDirRole
Diffstat (limited to 'lib/ManaTools/Module/Firewall.pm')
-rw-r--r-- | lib/ManaTools/Module/Firewall.pm | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/lib/ManaTools/Module/Firewall.pm b/lib/ManaTools/Module/Firewall.pm index 8cfebb8e..0e409310 100644 --- a/lib/ManaTools/Module/Firewall.pm +++ b/lib/ManaTools/Module/Firewall.pm @@ -47,6 +47,32 @@ use XML::Simple; extends qw( ManaTools::Module ); +# configName, configDir as attributes, must be before "with 'ManaTools::ConfigDirRole'" +has 'configName' => ( + is => 'ro', + isa => 'Str', + init_arg => undef, + lazy => 1, + default => 'manawall', +); + +has 'configDir' => ( + is => 'ro', + isa => 'Str', + lazy => 1, + builder => '_configDirBuilder', +); + +sub _configDirBuilder { + my $self = shift(); + my $confDir = $self->commandline()->conf_dir() || $self->defaultConfigDir(); + + return $confDir; +} + +with 'ManaTools::ConfigDirRole'; + + has '+icon' => ( default => File::ShareDir::dist_file(ManaTools::Shared::distName(), 'images/manawall.png'), ); @@ -136,19 +162,19 @@ has 'aboutDialog' => ( builder => '_setupAboutDialog', ); + has 'conf' => ( is => 'ro', isa => 'Str', + lazy => 1, builder => '_confBuilder', ); sub _confBuilder { my $self = shift(); - my $confDir = $self->commandline()->conf_dir() || "/etc/manatools"; - chop $confDir if substr($confDir, -1) eq '/'; - $confDir .= "/manawall/spec.conf"; + my $confDir = $self->configPathName(); - return $confDir; + return $confDir . "/spec.conf"; } sub _setupAboutDialog { @@ -1067,9 +1093,14 @@ sub start { my @server = (); $self->wdg_servers(@server); - # init servers definitions - $self->all_servers($self->_initAllServers()); - + eval { + # init servers definitions + $self->all_servers($self->_initAllServers()); + }; + if ($@) { + warn $@; + return; + } # initialize ifw_rules here $self->ifw_rules($self->_initIFW()); |