iOS web browser with a focus on security and privacy
at master 29 lines 492 B view raw
1/* 2 * Endless 3 * Copyright (c) 2014-2015 joshua stein <jcs@jcs.org> 4 * 5 * See LICENSE file for redistribution terms. 6 */ 7 8#import <Foundation/Foundation.h> 9 10#include <arpa/inet.h> 11 12@implementation NSString (IPAddress) 13 14- (BOOL)isValidIPAddress 15{ 16 struct in_addr dst; 17 int success; 18 const char *utf8 = [self UTF8String]; 19 20 success = inet_pton(AF_INET, utf8, &dst); 21 if (success != 1) { 22 struct in6_addr dst6; 23 success = inet_pton(AF_INET6, utf8, &dst6); 24 } 25 26 return (success == 1); 27} 28 29@end