Add object detection, tracking, mobile notifications, and search to any security camera.
faster scan
roryclearab6da4be192d
diff --git a/clearcam/PortScanner.m b/clearcam/PortScanner.mindex 03e7874..aa2fd81 100644--- a/clearcam/PortScanner.m+++ b/clearcam/PortScanner.m@@ -105,23 +105,29 @@NSArray<NSString *> *ipList = [self getIPRangeFromIP:ipInfo[@"ip"] subnetMask:ipInfo[@"subnet"]];NSLog(@"Scanning %lu IPs for open port %d...", (unsigned long)ipList.count, port);-- BOOL found = NO;++ dispatch_group_t scanGroup = dispatch_group_create();+ dispatch_queue_t scanQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);++ __block BOOL found = NO;+for (NSString *ip in ipList) {- NSLog(@"Checking IP: %@", ip);-- if ([self isPortOpen:ip port:port]) {- NSLog(@"[+] Open port %d found at %@", port, ip);- found = YES;- }- }-- NSLog(@"Scan complete. Found: %@", found ? @"YES" : @"NO");-- if (completion) {- NSLog(@"Calling completion block...");- completion();+ dispatch_group_async(scanGroup, scanQueue, ^{+ if ([self isPortOpen:ip port:port]) {+ @synchronized(self) {+ NSLog(@"[+] Open port %d found at %@", port, ip);+ found = YES;+ }+ }+ });}++ dispatch_group_notify(scanGroup, dispatch_get_main_queue(), ^{+ NSLog(@"Scan complete. Found: %@", found ? @"YES" : @"NO");+ if (completion) {+ completion();+ }+ });}- (NSString *)getDeviceIPAddress {diff --git a/clearcam/ViewController.m b/clearcam/ViewController.mindex 0c20f0d..73608ce 100644--- a/clearcam/ViewController.m+++ b/clearcam/ViewController.m@@ -44,7 +44,6 @@ NSMutableDictionary *classColorMap;[scanner scanNetworkForPort:8080 completion:^{NSLog(@"Scan DONE!!!");}];- NSLog(@"This will NOT print until the scan is finished.");self.current_segment_squares = [[NSMutableArray alloc] init];self.digits = [NSMutableDictionary dictionary];