Firewall-Config-Element

 view release on metacpan or  search on metacpan

lib/Firewall/Config/Element/Rule/Topsec.pm  view on Meta::CPAN

package Firewall::Config::Element::Rule::Topsec;

#------------------------------------------------------------------------------
# 加载扩展模块
#------------------------------------------------------------------------------
use Moose;
use namespace::autoclean;
use Firewall::Config::Element::AddressGroup::Topsec;
use Firewall::Config::Element::ServiceGroup::Topsec;

#------------------------------------------------------------------------------
# 加载 Firewall::Config::Element::Rule::Role 角色
#------------------------------------------------------------------------------
with 'Firewall::Config::Element::Rule::Role';

#------------------------------------------------------------------------------
# Firewall::Config::Element::Rule::Netscreen 通用属性
#------------------------------------------------------------------------------
has policyId => ( is => 'ro', isa => 'Str', required => 1, );

has fromZone => ( is => 'ro', isa => 'HashRef[Undef]|Undef', );

has toZone => ( is => 'ro', isa => 'HashRef[Undef]|Undef', );

has fromVlan => ( is => 'ro', isa => 'HashRef[Str|Undef]Undef', );

has toVlan => ( is => 'ro', isa => 'HashRef[Str|Undef]|Undef', );

has fromInterface => ( is => 'ro', isa => 'Str', required => 0, );

has toInterface => ( is => 'ro', isa => 'Str', required => 0, );

has '+action' => ( is => 'ro', isa => 'Str', default => 'permit', );

#------------------------------------------------------------------------------
# 重写 Firewall::Config::Element::Role => _buildRange 方法
#------------------------------------------------------------------------------
sub _buildSign {
  my $self = shift;
  return $self->createSign( $self->policyId );
}

#------------------------------------------------------------------------------
# Firewall::Config::Element::Rule::Role _buildSrcAddressGroup 具体实现
#------------------------------------------------------------------------------
sub _buildSrcAddressGroup {
  my $self = shift;
  return Firewall::Config::Element::AddressGroup::Topsec->new( addrGroupName => "^" );
}

#------------------------------------------------------------------------------
# Firewall::Config::Element::Rule::Role _buildDstAddressGroup 具体实现
#------------------------------------------------------------------------------
sub _buildDstAddressGroup {
  my $self = shift;
  return Firewall::Config::Element::AddressGroup::Topsec->new( addrGroupName => "^" );
}

#------------------------------------------------------------------------------
# Firewall::Config::Element::Rule::Role _buildServiceGroup 具体实现
#------------------------------------------------------------------------------
sub _buildServiceGroup {
  my $self = shift;
  return Firewall::Config::Element::ServiceGroup::Topsec->new( srvGroupName => "^" );
}

#------------------------------------------------------------------------------
# 忽略 disable 状态的策略
#------------------------------------------------------------------------------
sub ignore {
  my $self = shift;
  return ( $self->isDisable eq 'disable' or ( $self->hasSchedule and $self->schedule->isExpired ) );
}

__PACKAGE__->meta->make_immutable;
1;



( run in 1.725 second using v1.01-cache-2.11-cpan-39bf76dae61 )