Skip to content

Commit

Permalink
Comment fix and better redial on resume
Browse files Browse the repository at this point in the history
  • Loading branch information
ikoenigsknecht committed May 6, 2024
1 parent f801c79 commit 71c3e8d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,20 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI
this.logger('Resuming!')
this.logger('Reopening socket!')
await this.openSocket()
this.logger('Dialing peers with info: ', this.peerInfo)
await this.libp2pService?.redialPeers(this.peerInfo)
this.logger('Attempting to redial peers!')
if (this.peerInfo && (this.peerInfo?.connected.length !== 0 || this.peerInfo?.dialed.length !== 0)) {
this.logger('Dialing peers with info from pause: ', this.peerInfo)
await this.libp2pService?.redialPeers([...this.peerInfo.connected, ...this.peerInfo.dialed])
} else {
this.logger('Dialing peers from stored community (if exists)')
const community = await this.localDbService.getCurrentCommunity()
if (!community) {
this.logger(`No community launched, can't redial`)
return
}
const sortedPeers = await this.localDbService.getSortedPeers(community.peerList ?? [])
await this.libp2pService?.redialPeers(sortedPeers)
}
}

// This method is only used on iOS through rn-bridge for reacting on lifecycle changes
Expand Down Expand Up @@ -638,7 +650,7 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI
this.tor.on(SocketActionTypes.REDIAL_PEERS, async data => {
this.logger(`Socket - ${SocketActionTypes.REDIAL_PEERS}`)
const peerInfo = this.libp2pService?.getCurrentPeerInfo()
await this.libp2pService?.redialPeers(peerInfo)
await this.libp2pService?.redialPeers([...peerInfo.connected, ...peerInfo.dialed])
})
this.socketService.on(SocketActionTypes.CONNECTION_PROCESS_INFO, data => {
this.serverIoProvider.io.emit(SocketActionTypes.CONNECTION_PROCESS_INFO, data)
Expand Down
8 changes: 3 additions & 5 deletions packages/backend/src/nest/libp2p/libp2p.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,9 @@ export class Libp2pService extends EventEmitter {
* iOS where Tor receives a new port when the app resumes from background and
* we want to close/re-open connections.
*/
public async redialPeers(peerInfo?: Libp2pPeerInfo) {
const dialed = peerInfo ? peerInfo.dialed : Array.from(this.dialedPeers)
const toDial = peerInfo
? [...peerInfo.connected, ...peerInfo.dialed]
: [...this.connectedPeers.keys(), ...this.dialedPeers]
public async redialPeers(peersToDial?: string[]) {
const dialed = peersToDial ?? Array.from(this.dialedPeers)
const toDial = peersToDial ?? [...this.connectedPeers.keys(), ...this.dialedPeers]

if (dialed.length === 0) {
this.logger('No peers to redial!')
Expand Down
8 changes: 1 addition & 7 deletions packages/backend/src/nest/tor/tor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,18 +279,12 @@ export class Tor extends EventEmitter implements OnModuleInit {
this.logger(data.toString())

const bootstrappedRegexp = /Bootstrapped 0/
// TODO: Figure out if there's a way to get this working in tests
// const bootstrappedRegexp = /Loaded enough directory info to build circuits/
if (bootstrappedRegexp.test(data.toString())) {
this.spawnHiddenServices()
resolve()
}

// const noMoreHsdirRegexp = /No more HSDir available to query/
// if (noMoreHsdirRegexp.test(data.toString())) {
// this.logger('We might have a bad circuit, switching to a clean one')
// this.switchToCleanCircuts()
// resolve()
// }
})

this.process.stderr.on('data', (data: any) => {
Expand Down
16 changes: 8 additions & 8 deletions packages/mobile/ios/Quiet/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,26 @@
<key>CFBundleVersion</key>
<string>372</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false />
<false/>
<key>LSRequiresIPhoneOS</key>
<true />
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<false />
<false/>
<key>NSAllowsLocalNetworking</key>
<true />
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true />
<true/>
</dict>
</dict>
</dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string />
<string></string>
<key>UIAppFonts</key>
<array>
<string>Rubik-Black.ttf</string>
Expand All @@ -74,7 +74,7 @@
<string>Rubik-SemiBoldItalic.ttf</string>
</array>
<key>UIBackgroundModes</key>
<array />
<array/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
Expand All @@ -88,6 +88,6 @@
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false />
<false/>
</dict>
</plist>

0 comments on commit 71c3e8d

Please sign in to comment.