@libp2p/floodsub 11.0.24 → 11.0.25-3bf5d395c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +4 -4
- package/dist/src/decodeRpc.d.ts +22 -0
- package/dist/src/decodeRpc.d.ts.map +1 -0
- package/dist/src/decodeRpc.js +15 -0
- package/dist/src/decodeRpc.js.map +1 -0
- package/dist/src/floodsub.d.ts +1 -0
- package/dist/src/floodsub.d.ts.map +1 -1
- package/dist/src/floodsub.js +17 -7
- package/dist/src/floodsub.js.map +1 -1
- package/dist/src/index.d.ts +7 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/message/rpc.d.ts +1 -187
- package/dist/src/message/rpc.d.ts.map +1 -1
- package/dist/src/message/rpc.js +0 -650
- package/dist/src/message/rpc.js.map +1 -1
- package/dist/src/peer-streams.d.ts +2 -1
- package/dist/src/peer-streams.d.ts.map +1 -1
- package/dist/src/peer-streams.js +7 -2
- package/dist/src/peer-streams.js.map +1 -1
- package/package.json +9 -9
- package/src/decodeRpc.ts +33 -0
- package/src/floodsub.ts +19 -7
- package/src/index.ts +8 -0
- package/src/message/rpc.proto +3 -32
- package/src/message/rpc.ts +1 -934
- package/src/peer-streams.ts +8 -2
- package/dist/typedoc-urls.json +0 -41
package/src/peer-streams.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { pbStream } from '@libp2p/utils'
|
|
2
2
|
import { TypedEventEmitter } from 'main-event'
|
|
3
3
|
import { RPC } from './message/rpc.ts'
|
|
4
|
+
import type { RPCDecodeLimits } from './decodeRpc.ts'
|
|
4
5
|
import type { PubSubRPC } from './floodsub.ts'
|
|
5
6
|
import type { PeerStreamsEvents } from './index.ts'
|
|
6
7
|
import type { Stream, PeerId } from '@libp2p/interface'
|
|
@@ -38,7 +39,7 @@ export class PeerStreams extends TypedEventEmitter<PeerStreamsEvents> {
|
|
|
38
39
|
this.shutDownController = new AbortController()
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
attachInboundStream (stream: Stream, streamOpts?: Partial<ProtobufStreamOpts
|
|
42
|
+
attachInboundStream (stream: Stream, streamOpts?: Partial<ProtobufStreamOpts>, decodeRpcLimits?: RPCDecodeLimits): void {
|
|
42
43
|
this.inboundPb = pbStream(stream, streamOpts).pb(RPC)
|
|
43
44
|
|
|
44
45
|
Promise.resolve().then(async () => {
|
|
@@ -48,7 +49,8 @@ export class PeerStreams extends TypedEventEmitter<PeerStreamsEvents> {
|
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
const message = await this.inboundPb.read({
|
|
51
|
-
signal: this.shutDownController.signal
|
|
52
|
+
signal: this.shutDownController.signal,
|
|
53
|
+
limits: decodeRpcLimits
|
|
52
54
|
})
|
|
53
55
|
|
|
54
56
|
this.safeDispatchEvent('message', {
|
|
@@ -57,7 +59,11 @@ export class PeerStreams extends TypedEventEmitter<PeerStreamsEvents> {
|
|
|
57
59
|
}
|
|
58
60
|
})
|
|
59
61
|
.catch(err => {
|
|
62
|
+
// the inbound stream errored (e.g. a frame exceeded the decode limits):
|
|
63
|
+
// reset it and close the peer so floodsub removes it instead of leaving
|
|
64
|
+
// a half-open peer with a dead inbound stream
|
|
60
65
|
this.inboundPb?.unwrap().unwrap().abort(err)
|
|
66
|
+
this.close()
|
|
61
67
|
})
|
|
62
68
|
}
|
|
63
69
|
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"TopicValidatorResult": "https://libp2p.github.io/js-libp2p/enums/_libp2p_floodsub.TopicValidatorResult.html",
|
|
3
|
-
".:TopicValidatorResult": "https://libp2p.github.io/js-libp2p/enums/_libp2p_floodsub.TopicValidatorResult.html",
|
|
4
|
-
"FloodSub": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.FloodSub.html",
|
|
5
|
-
".:FloodSub": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.FloodSub.html",
|
|
6
|
-
"FloodSubComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.FloodSubComponents.html",
|
|
7
|
-
".:FloodSubComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.FloodSubComponents.html",
|
|
8
|
-
"FloodSubEvents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.FloodSubEvents.html",
|
|
9
|
-
".:FloodSubEvents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.FloodSubEvents.html",
|
|
10
|
-
"FloodSubInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.FloodSubInit.html",
|
|
11
|
-
".:FloodSubInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.FloodSubInit.html",
|
|
12
|
-
"PeerStreamsEvents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.PeerStreamsEvents.html",
|
|
13
|
-
".:PeerStreamsEvents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.PeerStreamsEvents.html",
|
|
14
|
-
"PublishResult": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.PublishResult.html",
|
|
15
|
-
".:PublishResult": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.PublishResult.html",
|
|
16
|
-
"SignedMessage": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.SignedMessage.html",
|
|
17
|
-
".:SignedMessage": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.SignedMessage.html",
|
|
18
|
-
"Subscription": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.Subscription.html",
|
|
19
|
-
".:Subscription": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.Subscription.html",
|
|
20
|
-
"SubscriptionChangeData": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.SubscriptionChangeData.html",
|
|
21
|
-
".:SubscriptionChangeData": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.SubscriptionChangeData.html",
|
|
22
|
-
"TopicValidatorFn": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.TopicValidatorFn.html",
|
|
23
|
-
".:TopicValidatorFn": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.TopicValidatorFn.html",
|
|
24
|
-
"UnsignedMessage": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.UnsignedMessage.html",
|
|
25
|
-
".:UnsignedMessage": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.UnsignedMessage.html",
|
|
26
|
-
"Message": "https://libp2p.github.io/js-libp2p/types/_libp2p_floodsub.Message.html",
|
|
27
|
-
".:Message": "https://libp2p.github.io/js-libp2p/types/_libp2p_floodsub.Message.html",
|
|
28
|
-
"SignaturePolicy": "https://libp2p.github.io/js-libp2p/types/_libp2p_floodsub.SignaturePolicy.html",
|
|
29
|
-
".:SignaturePolicy": "https://libp2p.github.io/js-libp2p/types/_libp2p_floodsub.SignaturePolicy.html",
|
|
30
|
-
"protocol": "https://libp2p.github.io/js-libp2p/variables/_libp2p_floodsub.protocol.html",
|
|
31
|
-
".:protocol": "https://libp2p.github.io/js-libp2p/variables/_libp2p_floodsub.protocol.html",
|
|
32
|
-
"pubSubSymbol": "https://libp2p.github.io/js-libp2p/variables/_libp2p_floodsub.pubSubSymbol.html",
|
|
33
|
-
"StrictNoSign": "https://libp2p.github.io/js-libp2p/variables/_libp2p_floodsub.StrictNoSign.html",
|
|
34
|
-
".:StrictNoSign": "https://libp2p.github.io/js-libp2p/variables/_libp2p_floodsub.StrictNoSign.html",
|
|
35
|
-
"StrictSign": "https://libp2p.github.io/js-libp2p/variables/_libp2p_floodsub.StrictSign.html",
|
|
36
|
-
".:StrictSign": "https://libp2p.github.io/js-libp2p/variables/_libp2p_floodsub.StrictSign.html",
|
|
37
|
-
"floodsub": "https://libp2p.github.io/js-libp2p/functions/_libp2p_floodsub.floodsub.html",
|
|
38
|
-
".:floodsub": "https://libp2p.github.io/js-libp2p/functions/_libp2p_floodsub.floodsub.html",
|
|
39
|
-
"isPubSub": "https://libp2p.github.io/js-libp2p/functions/_libp2p_floodsub.isPubSub.html",
|
|
40
|
-
".:isPubSub": "https://libp2p.github.io/js-libp2p/functions/_libp2p_floodsub.isPubSub.html"
|
|
41
|
-
}
|