Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export default {
'tachyons',
'uint8arrays',

// babel-preset-react-app uses this without declaring it as a dependency
// see: https://github.com/facebook/create-react-app/issues/13325
'@babel/plugin-proposal-private-property-in-object',

// type-only deps
'ipfs',

Expand Down
61 changes: 31 additions & 30 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"it-first": "^1.0.6",
"it-last": "^1.0.5",
"it-map": "^1.0.5",
"kubo-rpc-client": "^5.2.0",
"kubo-rpc-client": "^5.3.0",
"milliseconds": "^1.0.3",
"money-clip": "^3.0.5",
"multiformats": "^13.4.0",
Expand Down Expand Up @@ -107,6 +107,7 @@
},
"devDependencies": {
"@babel/core": "^7.18.9",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@babel/preset-react": "^7.18.6",
"@ipld/dag-pb": "^4.0.8",
"@jest/globals": "^29.7.0",
Expand Down
1 change: 1 addition & 0 deletions public/locales/en/peers.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"localNetwork": "Local Network",
"nearby": "nearby",
"protocols": "Open streams",
"agentVersion": "Agent Version",
"addConnection": "Add connection",
"insertPeerAddress": "Insert the peer address you want to connect to.",
"addPermanentPeer": "Add to the permanent peering configuration",
Expand Down
11 changes: 9 additions & 2 deletions src/bundles/peer-locations.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ function createPeersLocations (opts) {
)).sort()
: []).join(', ')

// Get agent version (truncation will be handled upstream in kubo via https://github.com/ipfs/kubo/pull/9465)
const agentVersion = peer.identify?.AgentVersion

return {
peerId,
location,
Expand All @@ -101,7 +104,8 @@ function createPeersLocations (opts) {
direction,
latency,
isPrivate,
isNearby
isNearby,
agentVersion
}
}))
)
Expand Down Expand Up @@ -157,7 +161,10 @@ const toLocationString = loc => {
}

const parseConnection = (multiaddr) => {
return multiaddr.protoNames().join(' • ')
const protocols = multiaddr.protoNames()
.map(p => p.startsWith('quic-v') ? 'quic' : p) // shorten quic-v1, quic-v2, etc to just 'quic'
.join('/')
return protocols
}

const parseLatency = (latency) => {
Expand Down
13 changes: 9 additions & 4 deletions src/bundles/peer-locations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ describe('selectPeerLocationsForSwarm', () => {
expect(result).toEqual([
{
address: '1.test',
connection: '1/test • endOfTest',
agentVersion: undefined,
connection: '1/test/endOfTest',
coordinates: [1.11, 1.01],
direction: undefined,
flagCode: 'ROM',
Expand All @@ -202,7 +203,8 @@ describe('selectPeerLocationsForSwarm', () => {
},
{
address: '2.test',
connection: '2/test • endOfTest',
agentVersion: undefined,
connection: '2/test/endOfTest',
coordinates: [2.22, 2.02],
direction: undefined,
flagCode: 'ROM',
Expand Down Expand Up @@ -252,8 +254,10 @@ describe('selectPeerLocationsForSwarm', () => {
expect(result).toEqual([
{
address: '1.test',
connection: '1/test • endOfTest',
agentVersion: undefined,
connection: '1/test/endOfTest',
coordinates: [1.11, 1.01],
direction: undefined,
flagCode: 'ROM',
isNearby: false,
isPrivate: true,
Expand Down Expand Up @@ -292,7 +296,8 @@ describe('selectPeerLocationsForSwarm', () => {
expect(result).toEqual([
{
address: '1.test',
connection: '1/test • endOfTest',
agentVersion: undefined,
connection: '1/test/endOfTest',
direction: undefined,
coordinates: null,
flagCode: null,
Expand Down
2 changes: 1 addition & 1 deletion src/bundles/peers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const swarmPeersTTL = ms.seconds(10)
const bundle = createAsyncResourceBundle({
name: 'peers',
actionBaseType: 'PEERS',
getPromise: ({ getIpfs }) => getIpfs().swarm.peers({ verbose: true, timeout: swarmPeersTTL }),
getPromise: ({ getIpfs }) => getIpfs().swarm.peers({ verbose: true, identify: true, timeout: swarmPeersTTL }),
staleAfter: swarmPeersTTL,
persist: false,
checkIfOnline: false
Expand Down
33 changes: 26 additions & 7 deletions src/peers/PeersTable/PeersTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,22 @@ const protocolsCellRenderer = (t) => ({ rowData }) => {
)
}

const agentVersionCellRenderer = (t) => ({ rowData }) => {
const ref = React.createRef()
const { agentVersion } = rowData
if (!agentVersion) return (<span className='dib o-40 no-select'>-</span>)
return (
<CopyToClipboard text={agentVersion} onCopy={() => copyFeedback(ref, t)}>
<span
ref={ref}
className='copyable'
title={agentVersion}>
{ agentVersion }
</span>
</CopyToClipboard>
)
}

const connectionCellRenderer = (t) => ({ rowData }) => {
const ref = React.createRef()
const { address, direction, peerId } = rowData
Expand Down Expand Up @@ -140,7 +156,7 @@ export const PeersTable = ({ className, t, peerLocationsForSwarm, selectedPeers
const filteredPeerList = useMemo(() => {
const filterLower = filter.toLowerCase()
if (filterLower === '') return awaitedPeerLocationsForSwarm
return awaitedPeerLocationsForSwarm.filter(({ location, latency, peerId, connection, protocols }) => {
return awaitedPeerLocationsForSwarm.filter(({ location, latency, peerId, connection, protocols, agentVersion }) => {
if (location != null && location.toLowerCase().includes(filterLower)) {
return true
}
Expand All @@ -150,13 +166,15 @@ export const PeersTable = ({ className, t, peerLocationsForSwarm, selectedPeers
if (peerId != null && peerId.toString().includes(filter)) {
return true
}
console.log('connection: ', connection)
if (connection != null && connection.toLowerCase().includes(filterLower)) {
return true
}
if (protocols != null && protocols.toLowerCase().includes(filterLower)) {
return true
}
if (agentVersion != null && agentVersion.toLowerCase().includes(filterLower)) {
return true
}

return false
})
Expand Down Expand Up @@ -186,11 +204,12 @@ export const PeersTable = ({ className, t, peerLocationsForSwarm, selectedPeers
sort={sort}
sortBy={sortBy}
sortDirection={sortDirection}>
<Column label={t('app:terms.location')} cellRenderer={locationCellRenderer(t)} dataKey='location' width={450} className='f6 charcoal truncate pl2' />
<Column label={t('app:terms.latency')} cellRenderer={latencyCellRenderer} dataKey='latency' width={200} className='f6 charcoal pl2' />
<Column label={t('app:terms.peerId')} cellRenderer={peerIdCellRenderer(t)} dataKey='peerId' width={250} className='charcoal monospace truncate f6 pl2' />
<Column label={t('app:terms.connection')} cellRenderer={connectionCellRenderer(t)} dataKey='connection' width={250} className='f6 charcoal truncate pl2' />
<Column label={t('protocols')} cellRenderer={protocolsCellRenderer(t)} dataKey='protocols' width={520} className='charcoal monospace truncate f7 pl2' />
<Column label={t('app:terms.location')} cellRenderer={locationCellRenderer(t)} dataKey='location' width={350} className='f6 charcoal truncate pl2' />
<Column label={t('app:terms.latency')} cellRenderer={latencyCellRenderer} dataKey='latency' width={100} className='f6 charcoal pl2' />
<Column label={t('app:terms.peerId')} cellRenderer={peerIdCellRenderer(t)} dataKey='peerId' width={200} className='charcoal monospace truncate f6 pl2' />
<Column label={t('app:terms.connection')} cellRenderer={connectionCellRenderer(t)} dataKey='connection' width={200} className='charcoal monospace truncate f7 pl2' />
<Column label={t('agentVersion')} cellRenderer={agentVersionCellRenderer(t)} dataKey='agentVersion' width={250} className='charcoal monospace truncate f7 pl2' />
<Column label={t('protocols')} cellRenderer={protocolsCellRenderer(t)} dataKey='protocols' width={420} className='charcoal monospace truncate f7 pl2' />
</Table>
</>
)}
Expand Down