Added better error checking for IP version

master
Aadhavan Srinivasan 8 months ago
parent 05cc70412c
commit dda89963c8

@ -46,7 +46,7 @@ public:
this->address = std::string(address);
/* Check to see if the given IP address matches the given ip_ver */
if ((check_ip_ver(address) == 4 && ip_ver == 6) || (check_ip_ver(address) == 6 && ip_ver == 4)) {
if ((check_ip_ver(address) != 6 && ip_ver == 6) || (check_ip_ver(address) != 4 && ip_ver == 4)) {
throw std::invalid_argument("Invalid IP address for given type.");
}

@ -46,7 +46,7 @@ public:
this->address = std::string(address);
/* Check to see if the given IP address matches the given ip_ver */
if ((check_ip_ver(address) == 4 && ip_ver == 6) || (check_ip_ver(address) == 6 && ip_ver == 4)) {
if ((check_ip_ver(address) != 6 && ip_ver == 6) || (check_ip_ver(address) != 4 && ip_ver == 4)) {
throw std::invalid_argument("Invalid IP address for given type.");
}

Loading…
Cancel
Save