|
|
@ -318,28 +318,28 @@ static NSTimeInterval launchStartedAt;
|
|
|
|
[OWSAnalytics appLaunchDidBegin];
|
|
|
|
[OWSAnalytics appLaunchDidBegin];
|
|
|
|
|
|
|
|
|
|
|
|
// Loki
|
|
|
|
// Loki
|
|
|
|
self.lokiP2PServer = [LKP2PServer new];
|
|
|
|
// self.lokiP2PServer = [LKP2PServer new];
|
|
|
|
|
|
|
|
|
|
|
|
// We try to bind to 8081, if we can't then we just fallback to any random port
|
|
|
|
// We try to bind to 8081, if we can't then we just fallback to any random port
|
|
|
|
NSArray *ports = @[ @8081, @0 ];
|
|
|
|
// NSArray *ports = @[ @8081, @0 ];
|
|
|
|
for (NSNumber *port in ports) {
|
|
|
|
// for (NSNumber *port in ports) {
|
|
|
|
if (self.lokiP2PServer.isRunning) { break; }
|
|
|
|
// if (self.lokiP2PServer.isRunning) { break; }
|
|
|
|
BOOL isStarted = [self.lokiP2PServer startOnPort:port.unsignedIntegerValue];
|
|
|
|
// BOOL isStarted = [self.lokiP2PServer startOnPort:port.unsignedIntegerValue];
|
|
|
|
if (isStarted) {
|
|
|
|
// if (isStarted) {
|
|
|
|
NSURL *serverURL = self.lokiP2PServer.serverURL;
|
|
|
|
// NSURL *serverURL = self.lokiP2PServer.serverURL;
|
|
|
|
[LKP2PAPI setOurP2PAddressWithUrl:self.lokiP2PServer.serverURL];
|
|
|
|
// [LKP2PAPI setOurP2PAddressWithUrl:self.lokiP2PServer.serverURL];
|
|
|
|
NSString *serverURLDescription = serverURL.absoluteString;
|
|
|
|
// NSString *serverURLDescription = serverURL.absoluteString;
|
|
|
|
if ([serverURLDescription hasSuffix:@"/"]) {
|
|
|
|
// if ([serverURLDescription hasSuffix:@"/"]) {
|
|
|
|
serverURLDescription = [serverURLDescription substringToIndex:serverURLDescription.length - 1];
|
|
|
|
// serverURLDescription = [serverURLDescription substringToIndex:serverURLDescription.length - 1];
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
NSLog(@"[Loki] Started server at %@.", serverURLDescription);
|
|
|
|
// NSLog(@"[Loki] Started server at %@.", serverURLDescription);
|
|
|
|
break;
|
|
|
|
// break;
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
if (!self.lokiP2PServer.isRunning) {
|
|
|
|
// if (!self.lokiP2PServer.isRunning) {
|
|
|
|
NSLog(@"[Loki] Failed to start P2P server.");
|
|
|
|
// NSLog(@"[Loki] Failed to start P2P server.");
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
return YES;
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|