antizapret icon indicating copy to clipboard operation
antizapret copied to clipboard

Сломался antizapret.pl, часть 2

Open atkrv opened this issue 11 months ago • 1 comments

Скрипт не может отработать:

user@device:~/antizapret # sh opnsense/install.sh
Stopping configd.
..done
Starting configd.
-                                                       32 kB   46 MBps    00s
Use of uninitialized value in unpack at /root/antizapret/opnsense/../antizapret.pl line 72.
no IP address found for <html
xargs: pfctl: exited with status 255; aborting

строка L72:

$ip_norm = join(":", unpack("H4H4H4H4H4H4H4H4", inet_pton(AF_INET6, $ip_norm))) if ($isv6);

весь блок целиком:

foreach my $ip (map {lc} @unique_ips) {
    next if ($ip eq "\n");
    $ip_norm = $ip;
    chomp($ip_norm);
    my $isv6 = ($ip_norm =~ /:/);
    $ip_norm = join(":", unpack("H4H4H4H4H4H4H4H4", inet_pton(AF_INET6, $ip_norm))) if ($isv6);
    if (defined $mask && substr($ip_norm, 0, length($mask)) eq $mask) {
        $buf .= $ip;
        $cnt++;
    }
    else {
        if ($cnt >= 10) {
            print($mask !~ /:/ ? "${mask}0/24\n" : "${mask}00/108\n");
        }
        else {
            print $buf;
        }
        if (!$isv6) {
            ($mask) = ($ip_norm =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.)/);
        }
        else {
            ($mask) = ($ip_norm =~ /^((?:[0-9a-f]{4}\:){7}[0-9a-f]{2})/);
        }
        $buf = $ip;
        $cnt = 1;
    }
}

Я не силён в Perl, если честно 🙁

atkrv avatar Dec 27 '24 15:12 atkrv

@Limych could you please take a look

atkrv avatar Dec 27 '24 15:12 atkrv