Skip to content

Commit

Permalink
Ip: Extend binary behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
yhabteab authored and nilmerg committed Apr 4, 2023
1 parent a832428 commit fea0564
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 4 additions & 2 deletions library/X509/Model/Behavior/Ip.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

namespace Icinga\Module\X509\Model\Behavior;

use ipl\Orm\Behavior\Binary;
use ipl\Orm\Contract\PropertyBehavior;

/**
* Support automatically transformation of human-readable IP addresses into their respective packed
* binary representation and vice versa.
*/
class Ip extends PropertyBehavior
class Ip extends Binary
{
public function fromDb($value, $key, $_)
{
$value = parent::fromDb($value, $key, $_);
if ($value === null) {
return null;
}
Expand All @@ -30,6 +32,6 @@ public function toDb($value, $key, $_)
return $value;
}

return str_pad(inet_pton($value), 16, "\0", STR_PAD_LEFT);
return parent::toDb(str_pad(inet_pton($value), 16, "\0", STR_PAD_LEFT), $key, $_);
}
}
1 change: 0 additions & 1 deletion library/X509/Model/X509Target.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public function getSearchColumns()
public function createBehaviors(Behaviors $behaviors)
{
$behaviors->add(new Ip(['ip']));
$behaviors->add(new Binary(['ip']));

$behaviors->add(new MillisecondTimestamp([
'ctime',
Expand Down

0 comments on commit fea0564

Please sign in to comment.