| 460 | } |
| 461 | |
| 462 | static bool validateIp(const char* ip, size_t len) |
| 463 | { |
| 464 | if (len < 7) // if it's not long enough to hold 4 digits and 3 separators, it's too short. |
| 465 | return false; |
| 466 | |
| 467 | struct addrinfo *info; |
| 468 | if (getaddrinfo(ip, NULL, NULL, &info) == 0) // check it's a valid address first |
| 469 | { |
| 470 | dsaddr = ((struct sockaddr_in*)info->ai_addr)->sin_addr; |
| 471 | freeaddrinfo(info); |
| 472 | // this won't error, so 0.0.0.0 (the default ip) will return false and force the user to put something else |
| 473 | return inet_addr(ip) != 0; |
| 474 | } |
| 475 | |
| 476 | return false; |
| 477 | } |
| 478 | |
| 479 | static SwkbdCallbackResult callback(void *user, const char **ppMessage, const char *text, size_t textlen) |
| 480 | { |