Skip to content

Commit

Permalink
Merge branch 'main' into feat/add-auto-tls
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain authored Nov 6, 2024
2 parents c114661 + 9168799 commit 8751d89
Show file tree
Hide file tree
Showing 51 changed files with 2,331 additions and 4,308 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"packages/auto-tls":"0.0.0","packages/connection-encrypter-plaintext":"2.0.10","packages/connection-encrypter-tls":"2.0.10","packages/crypto":"5.0.6","packages/interface":"2.2.0","packages/interface-compliance-tests":"6.1.8","packages/interface-internal":"2.0.10","packages/kad-dht":"14.1.0","packages/keychain":"5.0.9","packages/libp2p":"2.2.1","packages/logger":"5.1.3","packages/metrics-devtools":"1.1.8","packages/metrics-prometheus":"4.2.4","packages/metrics-simple":"1.2.6","packages/multistream-select":"6.0.8","packages/peer-collections":"6.0.10","packages/peer-discovery-bootstrap":"11.0.10","packages/peer-discovery-mdns":"11.0.10","packages/peer-id":"5.0.7","packages/peer-record":"8.0.10","packages/peer-store":"11.0.10","packages/pnet":"2.0.10","packages/protocol-autonat":"2.0.10","packages/protocol-dcutr":"2.0.10","packages/protocol-echo":"2.1.1","packages/protocol-fetch":"2.0.10","packages/protocol-identify":"3.0.10","packages/protocol-perf":"4.0.10","packages/protocol-ping":"2.0.10","packages/pubsub":"10.0.10","packages/pubsub-floodsub":"10.1.8","packages/record":"4.0.4","packages/stream-multiplexer-mplex":"11.0.10","packages/transport-circuit-relay-v2":"3.1.0","packages/transport-tcp":"10.0.11","packages/transport-webrtc":"5.0.16","packages/transport-websockets":"9.0.11","packages/transport-webtransport":"5.0.16","packages/upnp-nat":"2.0.10","packages/utils":"6.1.3"}
{"packages/auto-tls":"0.0.0","packages/connection-encrypter-plaintext":"2.0.10","packages/connection-encrypter-tls":"2.0.10","packages/crypto":"5.0.6","packages/interface":"2.2.0","packages/interface-compliance-tests":"6.1.8","packages/interface-internal":"2.0.10","packages/kad-dht":"14.1.0","packages/keychain":"5.0.9","packages/libp2p":"2.2.1","packages/logger":"5.1.3","packages/metrics-devtools":"1.1.8","packages/metrics-prometheus":"4.2.4","packages/metrics-simple":"1.2.6","packages/multistream-select":"6.0.8","packages/peer-collections":"6.0.10","packages/peer-discovery-bootstrap":"11.0.10","packages/peer-discovery-mdns":"11.0.10","packages/peer-id":"5.0.7","packages/peer-record":"8.0.10","packages/peer-store":"11.0.10","packages/pnet":"2.0.10","packages/protocol-autonat":"2.0.10","packages/protocol-dcutr":"2.0.10","packages/protocol-echo":"2.1.1","packages/protocol-fetch":"2.0.10","packages/protocol-identify":"3.0.10","packages/protocol-perf":"4.0.10","packages/protocol-ping":"2.0.10","packages/pubsub":"10.0.10","packages/pubsub-floodsub":"10.1.8","packages/record":"4.0.4","packages/stream-multiplexer-mplex":"11.0.10","packages/transport-circuit-relay-v2":"3.1.0","packages/transport-memory":"0.0.0","packages/transport-tcp":"10.0.11","packages/transport-webrtc":"5.0.16","packages/transport-websockets":"9.0.11","packages/transport-webtransport":"5.0.16","packages/upnp-nat":"2.0.10","packages/utils":"6.1.3"}
1 change: 1 addition & 0 deletions .release-please.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"packages/record": {},
"packages/stream-multiplexer-mplex": {},
"packages/transport-circuit-relay-v2": {},
"packages/transport-memory": {},
"packages/transport-tcp": {},
"packages/transport-webrtc": {},
"packages/transport-websockets": {},
Expand Down
2 changes: 1 addition & 1 deletion doc/LIMITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This is important for [DoS](https://en.wikipedia.org/wiki/Denial-of-service_atta

## Connection limits

It's possible to limit the total amount of connections a node is able to make (combining incoming and outgoing). When this limit is reached and an attempt to open a new connection is made, existing connections may be closed to make room for the new connection (see [Closing connections][#closing-connections]).
It's possible to limit the total amount of connections a node is able to make (combining incoming and outgoing). When this limit is reached and an attempt to open a new connection is made, existing connections may be closed to make room for the new connection (see [Closing connections](#closing-connections)).

- Note: there currently isn't a way to specify different limits for incoming vs. outgoing. Connection limits are applied across both incoming and outgoing connections combined. There is a backlog item for this [here](https://github.com/libp2p/js-libp2p/issues/1508).

Expand Down
57 changes: 1 addition & 56 deletions packages/libp2p/.aegir.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,6 @@
/** @type {import('aegir').PartialOptions} */
export default {
build: {
bundlesizeMax: '147kB'
},
test: {
before: async () => {
// use dynamic import because we only want to reference these files during the test run, e.g. after building
const { webSockets } = await import('@libp2p/websockets')
const { mplex } = await import('@libp2p/mplex')
const { yamux } = await import('@chainsafe/libp2p-yamux')
const { WebSockets } = await import('@multiformats/mafmt')
const { createLibp2p } = await import('./dist/src/index.js')
const { plaintext } = await import('@libp2p/plaintext')
const { circuitRelayServer, circuitRelayTransport } = await import('@libp2p/circuit-relay-v2')
const { identify } = await import('@libp2p/identify')
const { echo } = await import('./dist/test/fixtures/echo-service.js')

const libp2p = await createLibp2p({
connectionManager: {
inboundConnectionThreshold: Infinity
},
addresses: {
listen: [
'/ip4/127.0.0.1/tcp/0/ws'
]
},
transports: [
circuitRelayTransport(),
webSockets()
],
streamMuxers: [
yamux(),
mplex()
],
connectionEncrypters: [
plaintext()
],
services: {
identify: identify(),
relay: circuitRelayServer({
reservations: {
maxReservations: Infinity
}
}),
echo: echo()
}
})

return {
libp2p,
env: {
RELAY_MULTIADDR: libp2p.getMultiaddrs().filter(ma => WebSockets.matches(ma)).pop()
}
}
},
after: async (_, before) => {
await before.libp2p.stop()
}
bundlesizeMax: '95KB'
}
}
24 changes: 7 additions & 17 deletions packages/libp2p/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@
"prepublishOnly": "node scripts/update-version.js && npm run build",
"build": "aegir build",
"test": "aegir test",
"test:node": "aegir test -t node -f \"./dist/test/**/*.{node,spec}.js\" --cov",
"test:chrome": "aegir test -t browser -f \"./dist/test/**/*.spec.js\" --cov",
"test:chrome-webworker": "aegir test -t webworker -f \"./dist/test/**/*.spec.js\"",
"test:firefox": "aegir test -t browser -f \"./dist/test/**/*.spec.js\" -- --browser firefox",
"test:firefox-webworker": "aegir test -t webworker -f \"./dist/test/**/*.spec.js\" -- --browser firefox",
"test:webkit": "aegir test -t browser -f \"./dist/test/**/*.spec.js\" -- --browser webkit"
"test:node": "aegir test -t node --cov",
"test:chrome": "aegir test -t browser --cov",
"test:chrome-webworker": "aegir test -t webworker",
"test:firefox": "aegir test -t browser -- --browser firefox",
"test:firefox-webworker": "aegir test -t webworker -- --browser firefox",
"test:webkit": "aegir test -t browser -- --browser webkit"
},
"dependencies": {
"@libp2p/crypto": "^5.0.6",
Expand Down Expand Up @@ -113,23 +113,13 @@
"uint8arrays": "^5.1.0"
},
"devDependencies": {
"@chainsafe/libp2p-yamux": "^7.0.0",
"@libp2p/circuit-relay-v2": "^3.1.0",
"@libp2p/identify": "^3.0.10",
"@libp2p/interface-compliance-tests": "^6.1.8",
"@libp2p/mplex": "^11.0.10",
"@libp2p/plaintext": "^2.0.10",
"@libp2p/tcp": "^10.0.11",
"@libp2p/websockets": "^9.0.11",
"@multiformats/mafmt": "^12.1.6",
"aegir": "^44.0.1",
"delay": "^6.0.0",
"it-all": "^3.0.6",
"it-drain": "^3.0.7",
"it-length-prefixed": "^9.1.0",
"it-map": "^3.1.0",
"it-pair": "^2.0.6",
"it-pipe": "^3.0.1",
"it-pushable": "^3.2.3",
"it-stream-types": "^2.0.1",
"it-take": "^3.0.5",
"p-event": "^6.0.1",
Expand Down
3 changes: 1 addition & 2 deletions packages/libp2p/src/registrar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ import { InvalidParametersError } from '@libp2p/interface'
import merge from 'merge-options'
import * as errorsJs from './errors.js'
import type { IdentifyResult, Libp2pEvents, Logger, PeerUpdate, TypedEventTarget, PeerId, PeerStore, Topology } from '@libp2p/interface'
import type { ConnectionManager, StreamHandlerOptions, StreamHandlerRecord, Registrar, StreamHandler } from '@libp2p/interface-internal'
import type { StreamHandlerOptions, StreamHandlerRecord, Registrar, StreamHandler } from '@libp2p/interface-internal'
import type { ComponentLogger } from '@libp2p/logger'

export const DEFAULT_MAX_INBOUND_STREAMS = 32
export const DEFAULT_MAX_OUTBOUND_STREAMS = 64

export interface RegistrarComponents {
peerId: PeerId
connectionManager: ConnectionManager
peerStore: PeerStore
events: TypedEventTarget<Libp2pEvents>
logger: ComponentLogger
Expand Down
2 changes: 1 addition & 1 deletion packages/libp2p/src/upgrader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export class DefaultUpgrader implements Upgrader {
accepted = await this.components.connectionManager.acceptIncomingConnection(maConn)

if (!accepted) {
throw new ConnectionDeniedError('connection denied')
throw new ConnectionDeniedError('Connection denied')
}

await this.shouldBlockConnection('denyInboundConnection', maConn)
Expand Down
Loading

0 comments on commit 8751d89

Please sign in to comment.