diff --git a/packages/mobile/ios/Quiet/AppDelegate.m b/packages/mobile/ios/Quiet/AppDelegate.m index 31e1d3cf65..0d57cef630 100644 --- a/packages/mobile/ios/Quiet/AppDelegate.m +++ b/packages/mobile/ios/Quiet/AppDelegate.m @@ -127,12 +127,13 @@ - (void) spinupBackend:(BOOL)init { // (1/6) Find ports to use in tor and backend configuration FindFreePort *findFreePort = [FindFreePort new]; + Utils *utils = [Utils new]; - self.dataPort = [findFreePort getFirstStartingFromPort:11000]; if (self.socketIOSecret == nil) { - self.socketIOSecret = randomStringWithLength(20); + self.socketIOSecret = [utils generateRandomStringWithLength:(20)]; } + self.dataPort = [findFreePort getFirstStartingFromPort:11000]; uint16_t socksPort = [findFreePort getFirstStartingFromPort:12000]; uint16_t controlPort = [findFreePort getFirstStartingFromPort:14000]; uint16_t httpTunnelPort = [findFreePort getFirstStartingFromPort:16000]; diff --git a/packages/mobile/ios/Utils.swift b/packages/mobile/ios/Utils.swift new file mode 100644 index 0000000000..55dc4b1d37 --- /dev/null +++ b/packages/mobile/ios/Utils.swift @@ -0,0 +1,17 @@ +@objc(Utils) +class Utils: NSObject { + + @objc + func generateRandomString(length: Int) -> String { + let letters = "0123456789" + var randomString = String() + + for _ in 0..