22 lines
781 B
PHP
22 lines
781 B
PHP
<?php
|
|
|
|
namespace IriksIT\Manager\Models;
|
|
|
|
/**
|
|
* What someone wrote down about an address: who or what it is, or why it was banned, and the
|
|
* group it belongs to (`group_name`: addresses with the same name are banned and let back in
|
|
* together). One note per address, kept until it is removed: unlike the audit log and an ended
|
|
* ban it is never deleted by the prune command, so a privacy policy has to say so.
|
|
*/
|
|
class IpNote extends Model
|
|
{
|
|
/** One spelling per address, so the note of an IPv6 address is found however it is written. */
|
|
public static function spell(string $ip): string
|
|
{
|
|
$packed = @inet_pton(trim($ip));
|
|
$spelled = $packed === false ? false : inet_ntop($packed);
|
|
|
|
return $spelled === false ? trim($ip) : $spelled;
|
|
}
|
|
}
|