Skip to content

Commit

Permalink
Handle socketIOSecret for iOS lifecycle event
Browse files Browse the repository at this point in the history
  • Loading branch information
vinkabuki committed Oct 18, 2023
1 parent 3eaf916 commit f9fafbd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/backend/src/backendManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ console.log('options', options)
interface OpenServices {
torControlPort?: any
socketIOPort?: any
socketIOSecret?: any
httpTunnelPort?: any
authCookie?: any
}
Expand Down Expand Up @@ -123,6 +124,7 @@ export const runBackendMobile = async (): Promise<any> => {
app = await NestFactory.createApplicationContext(
AppModule.forOptions({
socketIOPort: msg.socketIOPort,
socketIOSecret: msg.socketIOSecret,
httpTunnelPort: msg.httpTunnelPort ? msg.httpTunnelPort : null,
torAuthCookie: msg.authCookie ? msg.authCookie : null,
torControlPort: msg.torControlPort ? msg.torControlPort : await getPort(),
Expand All @@ -136,7 +138,6 @@ export const runBackendMobile = async (): Promise<any> => {
}),
{ logger: ['warn', 'error', 'log', 'debug', 'verbose'] }
)
console.log('started backend wiktor little bastard ')
})
}

Expand Down
7 changes: 5 additions & 2 deletions packages/mobile/ios/Quiet/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ - (void) spinupBackend:(BOOL)init {
FindFreePort *findFreePort = [FindFreePort new];

self.dataPort = [findFreePort getFirstStartingFromPort:11000];
self.socketIOSecret = randomStringWithLength(20);
if (self.socketIOSecret == nil) {
self.socketIOSecret = randomStringWithLength(20);
}

uint16_t socksPort = [findFreePort getFirstStartingFromPort:12000];
uint16_t controlPort = [findFreePort getFirstStartingFromPort:14000];
Expand Down Expand Up @@ -215,11 +217,12 @@ - (void) launchBackend:(uint16_t)controlPort:(uint16_t)httpTunnelPort:(NSString

- (void) reviweServices:(uint16_t)controlPort:(uint16_t)httpTunnelPort:(NSString *)authCookie {
NSString * dataPortPayload = [NSString stringWithFormat:@"%@:%hu", @"socketIOPort", self.dataPort];
NSString * socketIOSecretPayload = [NSString stringWithFormat:@"%@:%@", @"socketIOSecret", self.socketIOSecret];
NSString * controlPortPayload = [NSString stringWithFormat:@"%@:%hu", @"torControlPort", controlPort];
NSString * httpTunnelPortPayload = [NSString stringWithFormat:@"%@:%hu", @"httpTunnelPort", httpTunnelPort];
NSString * authCookiePayload = [NSString stringWithFormat:@"%@:%@", @"authCookie", authCookie];

NSString * payload = [NSString stringWithFormat:@"%@|%@|%@|%@", dataPortPayload, controlPortPayload, httpTunnelPortPayload, authCookiePayload];
NSString * payload = [NSString stringWithFormat:@"%@|%@|%@|%@|%@", dataPortPayload, socketIOSecretPayload, controlPortPayload, httpTunnelPortPayload, authCookiePayload];
[self.nodeJsMobile sendMessageToNode:@"open":payload];
}

Expand Down

0 comments on commit f9fafbd

Please sign in to comment.