I know I'm overlooking something real simple here but I just don't see it:

The test:
    $ipt->_list_set({
      'name' => "test",
      'direction' => [qw/src dst/],
      'useipset' => 1,
    }),
    ['-m set --match-set test src,dst'],
    "Source and destination list",

Output:
#   Failed test 'Source and destination list'
#   at t/add.t line 150.
# 
+----+--------------------------------------------+-----------------------------------+
# | Elt|Got                                         |Expected
                 |
# 
+----+--------------------------------------------+-----------------------------------+
# *   0|'-m set --match-set test ARRAY(0x17f9f20)'  |'-m set
--match-set test src,dst'  *
# 
+----+--------------------------------------------+-----------------------------------+

And the method ('HERE' marking the branch that is having issues):
sub _list_set
{
  my ($self, $params) = @_;
  my $name = $params->{name};
  return undef unless (exists($self->{set}{$name}{list}) and
    ref($self->{set}{$name}{list}) eq 'ARRAY');
  my @return;

  my %hDirection;
  if (ref(\$params->{hDirection}) eq 'SCALAR')
  {
    %hDirection = map {$_ => 1} split(" ", $params->{direction});
  }
  elsif (ref($params->{direction}) eq 'ARRAY')
  {
    %hDirection = map {$_ => 1} @{$params->{direction}};  # <-- HERE
  }
  else
  {
    warn "Direction not defined - applying filter in both directions";
    %hDirection = (
      'src' => 1,
      'dst' => 1,
    );
  }

  if ($params->{useipset})
  {
    warn "Set [$name] has not been defined\n" unless ($self->is_set($name));
    push @return, "-m set --match-set $name " . join(",", keys(%hDirection));
  }
  else
  {
    my @list = @{$self->{set}{$name}{list}};
    if (exists($hDirection{src}))
    {
      push @return, map {"-s $_"} @list;
    }
    if (exists($hDirection{dst}))
    {
      push @return, map {"-d $_"} @list;
    }
  }

  return [@return];
}

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to