Wildcard IP support for "Exclude IPs from tracking" in MailWizz 1.9.48

gvero

Member
Hi,


I’m using MailWizz v1.9.48 and I’m trying to exclude Gmail image proxy IPs (like 66.249.x.x) from being tracked as opens.

In the backend settings under Campaigns > Exclude IPs from tracking, MailWizz only seems to support exact IPs, not wildcards like 66.249.*.*. That makes it hard to filter out all the proxy opens.

Does anyone know:
  1. How to make this support wildcards like 66.249.*.* or even CIDR blocks?
  2. Which file(s) control this logic in v1.9.48 so I can possibly customize it?
  3. Is there a plugin or hook that can do this without touching the core?

Moving to v2 is not an option for me at the moment. Just looking for a clean workaround to avoid false opens from bots/proxies.


Thanks in advance!
 
How to make this support wildcards like 66.249.*.* or even CIDR blocks?
As i can see this is already supported

PHP:
/**
     * Compares two IPv4 addresses.
     * In case a subnet is given, it checks if it contains the request IP.
     *
     * @author Fabien Potencier <fabien@symfony.com>
     * @param string $requestIp IPv4 address to check
     * @param string $ip        IPv4 address or subnet in CIDR notation
     *
     * @return bool Whether the request IP matches the IP, or whether the request IP is within the CIDR subnet
     */
    public static function checkIp4($requestIp, $ip)
    {
        if (!filter_var($requestIp, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
            return false;
        }

        if (false !== strpos($ip, '/')) {
            list($address, $netmask) = explode('/', $ip, 2);

            if ($netmask === '0') {
                return filter_var($address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
            }

            if ($netmask < 0 || $netmask > 32) {
                return false;
            }
        } else {
            $address = $ip;
            $netmask = 32;
        }

        return 0 === substr_compare(sprintf('%032b', ip2long($requestIp)), sprintf('%032b', ip2long($address)), 0, $netmask);
    }

Which file(s) control this logic in v1.9.48 so I can possibly customize it?
this is the file which handle this: apps/common/components/helpers/IpHelper.php


Is there a plugin or hook that can do this without touching the core?
No there is not.


Moving to v2 is not an option for me at the moment. Just looking for a clean workaround to avoid false opens from bots/proxies.
In v2 MailWizz have a Smart Tracking feature integrated which will filter out the bots opens/clicks.
 
Thanks for the quick reply!

I tried entering 66.249.*.* into the “Exclude IPs from tracking” field in the backend settings, but it doesn’t let me save it — the field clears out after I hit save. So maybe the logic supports it (in IpHelper.php), but the admin panel input validation or sanitization is blocking the wildcard format.

Is there a way around that? Or can I safely add the wildcard directly to the database (e.g., system.campaign.exclude_ips_from_tracking option in the option table)?


Thanks again!
 
I tried entering 66.249.*.* into the “Exclude IPs from tracking” field in the backend settings, but it doesn’t let me save it — the field clears out after I hit save. So maybe the logic supports it (in IpHelper.php), but the admin panel input validation or sanitization is blocking the wildcard format.
Sorry for this misunderstand, what I mean to say is that already support CIDR like: 192.168.1.0/24
Is there a way around that? Or can I safely add the wildcard directly to the database (e.g., system.campaign.exclude_ips_from_tracking option in the option table)?
Yes you can add manually in DB but these will not be handled, because are not supported by above function:
PHP:
public static function checkIp4($requestIp, $ip)
which will check for the IP's.
 
Back
Top