Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat 1706 conn status desktop #2494

Draft
wants to merge 46 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
fe4a5da
Add "Quiet is trying to connect..." panel
islathehut Mar 14, 2024
bc32de6
Most of the way to "Sending..." and graying out logic
islathehut Mar 15, 2024
4f6968e
Sending... and graying out text, files, and images when unsent as wel…
islathehut Mar 15, 2024
7df7ab0
Don't use this logic on fresh communities
islathehut Mar 15, 2024
b9e1371
Remove commented out code
islathehut Mar 15, 2024
d259f7b
Don't change display on info message
islathehut Mar 15, 2024
7d561f3
Formatting
islathehut Mar 15, 2024
926535a
Better peer disconnect/connect handling
islathehut Mar 17, 2024
f498f04
Update desktop tests
islathehut Mar 19, 2024
f89ce95
Merge branch 'develop' into feat/1706-connection-status-desktop
islathehut Mar 19, 2024
7079682
Linting
islathehut Mar 19, 2024
394d5dd
Remove unused luxon import
islathehut Mar 19, 2024
3b368de
Downgrade block scoping babel plugin to fix regression in their code
islathehut Mar 19, 2024
4103352
Merge branch 'develop' into feat/1706-connection-status-desktop
islathehut Mar 20, 2024
c868c9d
test updates
islathehut Mar 21, 2024
2ee6209
Merge branch 'develop' into feat/1706-connection-status-desktop
islathehut Mar 21, 2024
f7acbe1
Retries and more stable tests
islathehut Mar 22, 2024
cce5b24
Fix tests around registration messages
islathehut Mar 22, 2024
bb920fd
Fix bad conditions
islathehut Mar 22, 2024
efd0041
Update snapshots with new data-testids
islathehut Mar 22, 2024
cf23bf4
Wrong user
islathehut Mar 22, 2024
de76808
More test fixes
islathehut Mar 22, 2024
d07be65
More test fixes
islathehut Mar 22, 2024
418247f
Fix package changes I accidentally pushed
islathehut Mar 22, 2024
f93f74f
Update snapshot
islathehut Mar 22, 2024
3f1d20a
Why is this now failing?
islathehut Mar 22, 2024
ac1d851
Fix test
islathehut Mar 22, 2024
d2445fc
Update tests
islathehut Mar 23, 2024
2dc1385
Run all rtl tests again
islathehut Mar 23, 2024
e95a91e
E2E debugging
islathehut Mar 23, 2024
c2f6c74
Get logs from state manager and desktop renderer in node console
islathehut Mar 24, 2024
9ba0a33
Fix backwards compatibility tests
islathehut Mar 24, 2024
9fcae84
Fix issue with cypress not recognizing console constructor
islathehut Mar 24, 2024
5641cf3
Fix imports
islathehut Mar 24, 2024
fc34a09
Delete test.log that was added by mistake
Mar 25, 2024
210b9a7
Update changelogs
islathehut Mar 25, 2024
aae84af
Update CHANGELOG.md
islathehut Mar 25, 2024
21f0a3b
Mild logger refactor
islathehut Mar 25, 2024
5b4f4e3
Pull lfs in checkout
islathehut Mar 25, 2024
778158a
Share code for determining if message is unsent
islathehut Mar 27, 2024
24632d6
Updates from PR comments
islathehut Mar 27, 2024
ff6cea0
Merge branch 'develop' into feat/1706-connection-status-desktop
Mar 27, 2024
b8370ed
Add more desktop tests
islathehut Mar 27, 2024
f96aed5
Merge branch 'develop' into feat/1706-connection-status-desktop
islathehut Apr 4, 2024
af7844b
Delete files that were deleted on develop
islathehut Apr 4, 2024
c4f3d0a
merge from develop
islathehut Apr 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Add support for new format of invitation link: `c=<cid>&t=<token>&s=<serverAddress>&i=<inviterAddress>` ([#2310](https://github.com/TryQuiet/quiet/issues/2310))
* Use server for downloading initial community metadata if v2 invitation link is detected ([#2295](https://github.com/TryQuiet/quiet/issues/2295))
* Adds connection status information to messages panel on desktop when no peers are connected ([#1706](https://github.com/TryQuiet/quiet/

# Refactorings:

Expand All @@ -25,6 +26,7 @@
# Refactorings:

* Use ack for CREATE_NETWORK and simplify
* Logging from all sources can be written to node console
* Move Community model to the backend

# Fixes:
Expand Down
Empty file added bs.log
Empty file.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
"postpublish": "node copy-changelog.js && git add . && git commit -m 'Update packages CHANGELOG.md' && git push",
"start:desktop": "lerna run --scope @quiet/desktop start",
"lint:all": "lerna run lint",
"distAndRunE2ETests:mac:local": "lerna run --scope @quiet/desktop distMac:local && lerna run --scope e2e-tests test:localBinary --",
"clean": "lerna clean",
"bootstrap": "lerna bootstrap",
"bootstrap:clean": "npm run clean && npm run bootstrap",
"lerna:run:desktop": "lerna run --scope @quiet/desktop",
"distAndRunE2ETests:mac:local": "npm run lerna:run:desktop distMac:local && lerna run --scope e2e-tests test:localBinary --",
"e2e:linux:build": "lerna run --scope @quiet/backend webpack:prod && lerna run --scope @quiet/desktop distUbuntu && lerna run --scope e2e-tests linux:copy",
"e2e:linux:run": "lerna run --scope e2e-tests test --",
"prepare": "husky",
Expand Down
4 changes: 4 additions & 0 deletions packages/backend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

* Refactor: Consolidate profile photo validation and match magic byte check to type check

* Refactor: Updates peer connecting events to include updating peers DB and refactors some payload types ([#1706](https://github.com/TryQuiet/quiet/issues/1706))

* Refactor: Update Tor initialized status when Tor is connected ([#1706](https://github.com/TryQuiet/quiet/issues/1706))

[2.0.3-alpha.6]

* Fix: filter out invalid peer addresses in peer list. Update peer list in localdb.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
type SavedOwnerCertificatePayload,
type UserProfile,
type UserProfilesStoredEvent,
PeersNetworkDataPayload,
} from '@quiet/types'
import Logger from '../common/logger'
import { CONFIG_OPTIONS, QUIET_DIR, SERVER_IO_PROVIDER, SOCKS_PROXY_AGENT } from '../const'
Expand Down Expand Up @@ -565,7 +566,21 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI
await this.libp2pService.createInstance(params)

// Libp2p event listeners
this.libp2pService.on(Libp2pEvents.PEER_CONNECTED, (payload: { peers: string[] }) => {
this.libp2pService.on(Libp2pEvents.PEER_CONNECTED, async (payload: PeersNetworkDataPayload) => {
const peerStats: { [peerId: string]: NetworkStats } = await payload.peers.reduce(
async (updateObj, peer) => {
return {
...(await updateObj),
[peer.peer]: {
peerId: peer.peer,
lastSeen: peer.lastSeen,
connectionTime: peer.connectionDuration,
} as NetworkStats,
}
},
Promise.resolve({} as { [peerId: string]: NetworkStats })
)
await this.localDbService.update(LocalDBKeys.PEERS, peerStats)
this.serverIoProvider.io.emit(SocketActionTypes.PEER_CONNECTED, payload)
})

Expand Down
34 changes: 27 additions & 7 deletions packages/backend/src/nest/libp2p/libp2p.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import { mplex } from '@libp2p/mplex'
import { multiaddr } from '@multiformats/multiaddr'
import { Inject, Injectable } from '@nestjs/common'
import { createLibp2pAddress, createLibp2pListenAddress } from '@quiet/common'
import { ConnectionProcessInfo, type NetworkDataPayload, PeerId, SocketActionTypes } from '@quiet/types'
import {
ConnectionProcessInfo,
type NetworkDataPayload,
PeerId,
SocketActionTypes,
PeersNetworkDataPayload,
} from '@quiet/types'
import crypto from 'crypto'
import { EventEmitter } from 'events'
import { Agent } from 'https'
Expand Down Expand Up @@ -153,20 +159,32 @@ export class Libp2pService extends EventEmitter {
})

this.libp2pInstance.addEventListener('peer:connect', async peer => {
this.logger(`Connecting peer: ${JSON.stringify(peer)}`)
const remotePeerId = peer.detail.remotePeer.toString()
const localPeerId = peerId.toString()
this.logger(`${localPeerId} connected to ${remotePeerId}`)

this.connectedPeers.set(remotePeerId, DateTime.utc().valueOf())
this.logger(`${localPeerId} is connected to ${this.connectedPeers.size} peers`)
const now = DateTime.utc()
this.connectedPeers.set(remotePeerId, now.valueOf())
this.logger(`${localPeerId} is now connected to ${this.connectedPeers.size} peers`)
this.logger(`${localPeerId} has ${this.libp2pInstance?.getConnections().length} open connections`)

this.emit(Libp2pEvents.PEER_CONNECTED, {
peers: [remotePeerId],
})
const payload: PeersNetworkDataPayload = {
peers: [
{
peer: remotePeerId,
lastSeen: now.toSeconds(),
connectionDuration: 0,
},
],
}

this.logger(`Emitting ${Libp2pEvents.PEER_CONNECTED} event with payload ${JSON.stringify(payload)}`)
this.emit(Libp2pEvents.PEER_CONNECTED, payload)
})

this.libp2pInstance.addEventListener('peer:disconnect', async peer => {
this.logger(`Disconnecting peer: ${JSON.stringify(peer)}`)
const remotePeerId = peer.detail.remotePeer.toString()
const localPeerId = peerId.toString()
this.logger(`${localPeerId} disconnected from ${remotePeerId}`)
Expand All @@ -187,12 +205,14 @@ export class Libp2pService extends EventEmitter {
const connectionDuration: number = connectionEndTime - connectionStartTime

this.connectedPeers.delete(remotePeerId)
this.logger(`${localPeerId} is connected to ${this.connectedPeers.size} peers`)
this.logger(`${localPeerId} is now connected to ${this.connectedPeers.size} peers`)
const peerStat: NetworkDataPayload = {
peer: remotePeerId,
connectionDuration,
lastSeen: connectionEndTime,
}

this.logger(`Emitting ${Libp2pEvents.PEER_DISCONNECTED} event with payload ${JSON.stringify(peerStat)}`)
this.emit(Libp2pEvents.PEER_DISCONNECTED, peerStat)
})

Expand Down
9 changes: 6 additions & 3 deletions packages/backend/src/nest/tor/tor-control.service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Inject, Injectable } from '@nestjs/common'
import net from 'net'
import { CONFIG_OPTIONS, TOR_CONTROL_PARAMS } from '../const'
import { ConfigOptions } from '../types'
import { CONFIG_OPTIONS, SERVER_IO_PROVIDER, TOR_CONTROL_PARAMS } from '../const'
import { ConfigOptions, ServerIoProviderTypes } from '../types'
import { TorControlAuthType, TorControlParams } from './tor.types'
import Logger from '../common/logger'
import { SocketActionTypes } from '@quiet/types'

@Injectable()
export class TorControl {
Expand All @@ -14,7 +15,8 @@ export class TorControl {

constructor(
@Inject(TOR_CONTROL_PARAMS) public torControlParams: TorControlParams,
@Inject(CONFIG_OPTIONS) public configOptions: ConfigOptions
@Inject(CONFIG_OPTIONS) public configOptions: ConfigOptions,
@Inject(SERVER_IO_PROVIDER) public readonly serverIoProvider: ServerIoProviderTypes
) {
this.isSending = false
}
Expand Down Expand Up @@ -63,6 +65,7 @@ export class TorControl {
this.logger(`Connecting to Tor, host: ${this.torControlParams.host} port: ${this.torControlParams.port}`)
await this._connect()
this.logger('Tor connected')
this.serverIoProvider.io.emit(SocketActionTypes.TOR_INITIALIZED)
return
} catch (e) {
this.logger(e)
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"target": "ES2020",
"module": "ES2022",
"strict": true,
"declaration": true,
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
Expand Down
5 changes: 5 additions & 0 deletions packages/desktop/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

# New features:

* Adds connection status information to messages panel when no peers are connected ([#1706](https://github.com/TryQuiet/quiet/issues/1706))

# Refactorings:

* Updates all logging from renderer to write to the node console
* Updates usages of `act` in tests to use `@testing-library/react` to avoid errors/warnings

# Fixes:

[2.2.0]
Expand Down
139 changes: 128 additions & 11 deletions packages/desktop/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading