diff options
-rw-r--r-- | libproxy/modules/ignore_ip.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/libproxy/modules/ignore_ip.cpp b/libproxy/modules/ignore_ip.cpp index 388c177..c019fec 100644 --- a/libproxy/modules/ignore_ip.cpp +++ b/libproxy/modules/ignore_ip.cpp @@ -135,13 +135,19 @@ public: if (ignore.find('/') != string::npos) { ign_ip = sockaddr_from_string(ignore.substr(0, ignore.find('/'))); - net_ip = sockaddr_from_string(ignore.substr(ignore.find('/') + 1)); - /* If CIDR notation was used, get the netmask */ - if (ign_ip && !net_ip) + uint32_t cidr = 0; + string mask = ignore.substr(ignore.find('/') + 1); + + if (mask.find('.') != string::npos) + { + /* A dotted netmask was used */ + net_ip = sockaddr_from_string(mask); + } + else { - uint32_t cidr = 0; - if (sscanf(ignore.substr(ignore.find('/') + 1).c_str(), "%d", &cidr) == 1) + /* If CIDR notation was used, get the netmask */ + if (sscanf(mask.c_str(), "%d", &cidr) == 1) net_ip = sockaddr_from_cidr(ign_ip->sa_family, cidr); } |