"mtime >= $lastmt AND CID != 0";
};
- # FIXME: drop Host column with PMG 7.0
my $merge_sth = $dbh->prepare(PMG::DBTools::cgreylist_merge_sql());
my $mergefunc = sub {
my ($ref) = @_;
my $ipnet = $ref->{ipnet};
$ipnet .= '.0/24' if $ipnet !~ /\/\d+$/;
$merge_sth->execute(
- $ipnet, 0, $ref->{sender}, $ref->{receiver},
+ $ipnet, $ref->{sender}, $ref->{receiver},
$ref->{instance}, $ref->{rctime}, $ref->{extime}, $ref->{delay},
$ref->{blocked}, $ref->{passed}, 0, $ref->{cid});
};
our $default_db_name = "Proxmox_ruledb";
-# FIXME: drop Host column with PMG 7.0
sub cgreylist_merge_sql {
my ($with_mask) = @_;
my $network = $with_mask ? 'network(set_masklen(?, ?))' : '?';
my $sql =
- 'INSERT INTO CGREYLIST (IPNet,Host,Sender,Receiver,Instance,RCTime,' .
+ 'INSERT INTO CGREYLIST (IPNet,Sender,Receiver,Instance,RCTime,' .
'ExTime,Delay,Blocked,Passed,MTime,CID) ' .
- "VALUES ($network, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) " .
+ "VALUES ($network, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) " .
'ON CONFLICT (IPNet,Sender,Receiver) DO UPDATE SET ' .
- 'Host = CASE WHEN CGREYLIST.MTime >= excluded.MTime THEN CGREYLIST.Host ELSE excluded.Host END,' .
'CID = GREATEST(CGREYLIST.CID, excluded.CID), RCTime = LEAST(CGREYLIST.RCTime, excluded.RCTime),' .
'ExTime = GREATEST(CGREYLIST.ExTime, excluded.ExTime),' .
'Delay = GREATEST(CGREYLIST.Delay, excluded.Delay),' .
my $cgreylist_ctablecmd = <<__EOD;
CREATE TABLE CGreylist
(IPNet VARCHAR(49) NOT NULL,
- Host INTEGER NOT NULL,
Sender VARCHAR(255) NOT NULL,
Receiver VARCHAR(255) NOT NULL,
Instance VARCHAR(255),
"AND value = 'content-type:application/x-java-vm';");
};
- # FIXME: drop Host column with PMG 7.0
# increase column size of cgreylist.ipnet for ipv6 support and transfer data
eval {
my $sth = $dbh->prepare("SELECT character_maximum_length ".
die $err;
}
+ # drop greylist Host column with PMG 7.0
+ if (database_column_exists($dbh, 'CGreylist', 'Host')) {
+ eval {
+ $dbh->begin_work;
+ $dbh->do("ALTER TABLE CGreylist DROP COLUMN Host");
+ $dbh->commit;
+ };
+ if (my $err = $@) {
+ $dbh->rollback;
+ die $err;
+ }
+ }
+
foreach my $table (keys %$tables) {
eval { $dbh->do("ANALYZE $table"); };
warn $@ if $@;
# table later. We set 'blocked' to 100000 to identify those entries.
if (!defined($ref->{rctime})) {
-
- # FIXME: drop Host column with PMG 7.0
$dbh->do(PMG::DBTools::cgreylist_merge_sql(1), undef,
- $ip, $masklen, 0, $sender, $rcpt, $instance,
+ $ip, $masklen, $sender, $rcpt, $instance,
$ctime, $ctime + 10, 0, 100000, 0, $ctime, $self->{lcid});
}
$dbh->do(
PMG::DBTools::cgreylist_merge_sql(1), undef, $ip, $masklen,
- 0, $sender, $rcpt, $instance, $ctime, $ctime + $greylist_lifetime,
+ $sender, $rcpt, $instance, $ctime, $ctime + $greylist_lifetime,
0, 1, 0, $ctime, $self->{lcid}
);