libp2p 0.45.9-05abd49f → 0.45.9-2e561fe9
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/src/autonat/index.js +3 -3
- package/dist/src/circuit-relay/server/index.js +8 -8
- package/dist/src/circuit-relay/transport/index.js +5 -5
- package/dist/src/circuit-relay/transport/listener.js +1 -1
- package/dist/src/circuit-relay/transport/reservation-store.js +1 -1
- package/dist/src/connection-manager/dial-queue.js +5 -5
- package/dist/src/connection-manager/index.js +4 -4
- package/dist/src/connection-manager/index.js.map +1 -1
- package/dist/src/identify/identify.js +2 -2
- package/dist/src/identify/identify.js.map +1 -1
- package/dist/src/transport-manager.js +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +20 -20
- package/src/autonat/index.ts +3 -3
- package/src/circuit-relay/server/index.ts +8 -8
- package/src/circuit-relay/transport/index.ts +5 -5
- package/src/circuit-relay/transport/listener.ts +1 -1
- package/src/circuit-relay/transport/reservation-store.ts +1 -1
- package/src/connection-manager/dial-queue.ts +5 -5
- package/src/connection-manager/index.ts +4 -4
- package/src/identify/identify.ts +2 -2
- package/src/transport-manager.ts +1 -1
- package/src/version.ts +1 -1
package/dist/index.min.js
CHANGED
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
(?:${Me}:){1}(?:(?::${Me}){0,4}:${Kt}|(?::${Me}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
|
|
46
46
|
(?::(?:(?::${Me}){0,5}:${Kt}|(?::${Me}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
|
|
47
47
|
)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
|
|
48
|
-
`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),EI=new RegExp(`(?:^${Kt}$)|(?:^${Na}$)`),_I=new RegExp(`^${Kt}$`),SI=new RegExp(`^${Na}$`),Lf=t=>t&&t.exact?EI:new RegExp(`(?:${Qr(t)}${Kt}${Qr(t)})|(?:${Qr(t)}${Na}${Qr(t)})`,"g");Lf.v4=t=>t&&t.exact?_I:new RegExp(`${Qr(t)}${Kt}${Qr(t)}`,"g");Lf.v6=t=>t&&t.exact?SI:new RegExp(`${Qr(t)}${Na}${Qr(t)}`,"g");var Tg=Lf;var Ng=z(Lg(),1),{isValid:AI,parse:II}=Ng.default,RI=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"],CI=RI.map(t=>new Dg.Netmask(t));function TI(t){for(let e of CI)if(e.contains(t))return!0;return!1}function Pg(t){return/^::$/.test(t)||/^::1$/.test(t)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(t)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(t)||/^ff([0-9a-fA-F]{2,2}):/i.test(t)}var kg=t=>{if(AI(t)){let e=II(t);if(e.kind()==="ipv4")return TI(e.toNormalizedString());if(e.kind()==="ipv6")return Pg(t)}else if(Ai(t)&&Tg.v6().test(t))return Pg(t)};var Oa=kg;function Og(t={}){return{denyDialPeer:async()=>!1,denyDialMultiaddr:async e=>{let r=e.stringTuples();return r[0][0]===4||r[0][0]===41?!!Oa(`${r[0][1]}`):!1},denyInboundConnection:async()=>!1,denyOutboundConnection:async()=>!1,denyInboundEncryptedConnection:async()=>!1,denyOutboundEncryptedConnection:async()=>!1,denyInboundUpgradedConnection:async()=>!1,denyOutboundUpgradedConnection:async()=>!1,filterMultiaddrForPeer:async()=>!0,...t}}var J5=Symbol.for("@libp2p/transport");var Xr;(function(t){t[t.FATAL_ALL=0]="FATAL_ALL",t[t.NO_FATAL=1]="NO_FATAL"})(Xr||(Xr={}));function Pf(t){try{let{address:e}=t.nodeAddress();return!!Oa(e)}catch{return!0}}function Pi(t,e){let r=Pf(t.multiaddr),n=Pf(e.multiaddr);return r&&!n?1:!r&&n||t.isCertified&&!e.isCertified?-1:!t.isCertified&&e.isCertified?1:0}var Nf=z(al(),1),kf=z(Fg(),1);var Kg=globalThis.fetch,Vg=globalThis.Headers,sD=globalThis.Request,aD=globalThis.Response;function Ma(t,e,r){return`${t}?name=${e}&type=${r}`}async function qg(t,e){return await(await Kg(t,{headers:new Vg({accept:"application/dns-json"}),signal:e})).json()}function Tn(t,e){return`${e}_${t}`}var Df=Object.assign((0,Nf.default)("dns-over-http-resolver"),{error:(0,Nf.default)("dns-over-http-resolver:error")}),Of=class{constructor(e={}){this._cache=new kf.default({max:e?.maxCache??100}),this._TXTcache=new kf.default({max:e?.maxCache??100}),this._servers=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve"],this._request=e.request??qg,this._abortControllers=[]}cancel(){this._abortControllers.forEach(e=>e.abort())}getServers(){return this._servers}_getShuffledServers(){let e=[...this._servers];for(let r=e.length-1;r>0;r--){let n=Math.floor(Math.random()*r),i=e[r];e[r]=e[n],e[n]=i}return e}setServers(e){this._servers=e}async resolve(e,r="A"){switch(r){case"A":return await this.resolve4(e);case"AAAA":return await this.resolve6(e);case"TXT":return await this.resolveTxt(e);default:throw new Error(`${r} is not supported`)}}async resolve4(e){let r="A",n=this._cache.get(Tn(e,r));if(n!=null)return n;let i=!1;for(let o of this._getShuffledServers()){let s=new AbortController;this._abortControllers.push(s);try{let a=await this._request(Ma(o,e,r),s.signal),c=a.Answer.map(l=>l.data),u=Math.min(...a.Answer.map(l=>l.TTL));return this._cache.set(Tn(e,r),c,{ttl:u}),c}catch{s.signal.aborted&&(i=!0),Df.error(`${o} could not resolve ${e} record ${r}`)}finally{this._abortControllers=this._abortControllers.filter(a=>a!==s)}}throw i?Object.assign(new Error("queryA ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record ${r}`)}async resolve6(e){let r="AAAA",n=this._cache.get(Tn(e,r));if(n!=null)return n;let i=!1;for(let o of this._getShuffledServers()){let s=new AbortController;this._abortControllers.push(s);try{let a=await this._request(Ma(o,e,r),s.signal),c=a.Answer.map(l=>l.data),u=Math.min(...a.Answer.map(l=>l.TTL));return this._cache.set(Tn(e,r),c,{ttl:u}),c}catch{s.signal.aborted&&(i=!0),Df.error(`${o} could not resolve ${e} record ${r}`)}finally{this._abortControllers=this._abortControllers.filter(a=>a!==s)}}throw i?Object.assign(new Error("queryAaaa ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record ${r}`)}async resolveTxt(e){let r="TXT",n=this._TXTcache.get(Tn(e,r));if(n!=null)return n;let i=!1;for(let o of this._getShuffledServers()){let s=new AbortController;this._abortControllers.push(s);try{let a=await this._request(Ma(o,e,r),s.signal),c=a.Answer.map(l=>[l.data.replace(/['"]+/g,"")]),u=Math.min(...a.Answer.map(l=>l.TTL));return this._TXTcache.set(Tn(e,r),c,{ttl:u}),c}catch{s.signal.aborted&&(i=!0),Df.error(`${o} could not resolve ${e} record ${r}`)}finally{this._abortControllers=this._abortControllers.filter(a=>a!==s)}}throw i?Object.assign(new Error("queryTxt ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record ${r}`)}clearCache(){this._cache.clear(),this._TXTcache.clear()}},zg=Of;var $g=zg;var{code:NI}=le("dnsaddr");async function Di(t,e={}){let r=new $g;e.signal!=null&&e.signal.addEventListener("abort",()=>{r.cancel()});let n=t.getPeerId(),[,i]=t.stringTuples().find(([a])=>a===NI)??[];if(i==null)throw new Error("No hostname found in multiaddr");let s=(await r.resolveTxt(`_dnsaddr.${i}`)).flat().map(a=>a.split("=")[1]).filter(Boolean);return n!=null&&(s=s.filter(a=>a.includes(n))),s}var or;(function(t){t.NOT_STARTED_YET="The libp2p node is not started yet",t.DHT_DISABLED="DHT is not available",t.PUBSUB_DISABLED="PubSub is not available",t.CONN_ENCRYPTION_REQUIRED="At least one connection encryption module is required",t.ERR_TRANSPORTS_REQUIRED="At least one transport module is required",t.ERR_PROTECTOR_REQUIRED="Private network is enforced, but no protector was provided",t.NOT_FOUND="Not found"})(or||(or={}));var N;(function(t){t.DHT_DISABLED="ERR_DHT_DISABLED",t.ERR_PUBSUB_DISABLED="ERR_PUBSUB_DISABLED",t.PUBSUB_NOT_STARTED="ERR_PUBSUB_NOT_STARTED",t.DHT_NOT_STARTED="ERR_DHT_NOT_STARTED",t.CONN_ENCRYPTION_REQUIRED="ERR_CONN_ENCRYPTION_REQUIRED",t.ERR_TRANSPORTS_REQUIRED="ERR_TRANSPORTS_REQUIRED",t.ERR_PROTECTOR_REQUIRED="ERR_PROTECTOR_REQUIRED",t.ERR_PEER_DIAL_INTERCEPTED="ERR_PEER_DIAL_INTERCEPTED",t.ERR_CONNECTION_INTERCEPTED="ERR_CONNECTION_INTERCEPTED",t.ERR_INVALID_PROTOCOLS_FOR_STREAM="ERR_INVALID_PROTOCOLS_FOR_STREAM",t.ERR_CONNECTION_ENDED="ERR_CONNECTION_ENDED",t.ERR_CONNECTION_FAILED="ERR_CONNECTION_FAILED",t.ERR_NODE_NOT_STARTED="ERR_NODE_NOT_STARTED",t.ERR_ALREADY_ABORTED="ERR_ALREADY_ABORTED",t.ERR_TOO_MANY_ADDRESSES="ERR_TOO_MANY_ADDRESSES",t.ERR_NO_VALID_ADDRESSES="ERR_NO_VALID_ADDRESSES",t.ERR_RELAYED_DIAL="ERR_RELAYED_DIAL",t.ERR_DIALED_SELF="ERR_DIALED_SELF",t.ERR_DISCOVERED_SELF="ERR_DISCOVERED_SELF",t.ERR_DUPLICATE_TRANSPORT="ERR_DUPLICATE_TRANSPORT",t.ERR_ENCRYPTION_FAILED="ERR_ENCRYPTION_FAILED",t.ERR_HOP_REQUEST_FAILED="ERR_HOP_REQUEST_FAILED",t.ERR_INVALID_KEY="ERR_INVALID_KEY",t.ERR_INVALID_MESSAGE="ERR_INVALID_MESSAGE",t.ERR_INVALID_PARAMETERS="ERR_INVALID_PARAMETERS",t.ERR_INVALID_PEER="ERR_INVALID_PEER",t.ERR_MUXER_UNAVAILABLE="ERR_MUXER_UNAVAILABLE",t.ERR_NOT_FOUND="ERR_NOT_FOUND",t.ERR_TIMEOUT="ERR_TIMEOUT",t.ERR_TRANSPORT_UNAVAILABLE="ERR_TRANSPORT_UNAVAILABLE",t.ERR_TRANSPORT_DIAL_FAILED="ERR_TRANSPORT_DIAL_FAILED",t.ERR_UNSUPPORTED_PROTOCOL="ERR_UNSUPPORTED_PROTOCOL",t.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED="ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED",t.ERR_INVALID_MULTIADDR="ERR_INVALID_MULTIADDR",t.ERR_SIGNATURE_NOT_VALID="ERR_SIGNATURE_NOT_VALID",t.ERR_FIND_SELF="ERR_FIND_SELF",t.ERR_NO_ROUTERS_AVAILABLE="ERR_NO_ROUTERS_AVAILABLE",t.ERR_CONNECTION_NOT_MULTIPLEXED="ERR_CONNECTION_NOT_MULTIPLEXED",t.ERR_NO_DIAL_TOKENS="ERR_NO_DIAL_TOKENS",t.ERR_KEYCHAIN_REQUIRED="ERR_KEYCHAIN_REQUIRED",t.ERR_INVALID_CMS="ERR_INVALID_CMS",t.ERR_MISSING_KEYS="ERR_MISSING_KEYS",t.ERR_NO_KEY="ERR_NO_KEY",t.ERR_INVALID_KEY_NAME="ERR_INVALID_KEY_NAME",t.ERR_INVALID_KEY_TYPE="ERR_INVALID_KEY_TYPE",t.ERR_KEY_ALREADY_EXISTS="ERR_KEY_ALREADY_EXISTS",t.ERR_INVALID_KEY_SIZE="ERR_INVALID_KEY_SIZE",t.ERR_KEY_NOT_FOUND="ERR_KEY_NOT_FOUND",t.ERR_OLD_KEY_NAME_INVALID="ERR_OLD_KEY_NAME_INVALID",t.ERR_NEW_KEY_NAME_INVALID="ERR_NEW_KEY_NAME_INVALID",t.ERR_PASSWORD_REQUIRED="ERR_PASSWORD_REQUIRED",t.ERR_PEM_REQUIRED="ERR_PEM_REQUIRED",t.ERR_CANNOT_READ_KEY="ERR_CANNOT_READ_KEY",t.ERR_MISSING_PRIVATE_KEY="ERR_MISSING_PRIVATE_KEY",t.ERR_MISSING_PUBLIC_KEY="ERR_MISSING_PUBLIC_KEY",t.ERR_INVALID_OLD_PASS_TYPE="ERR_INVALID_OLD_PASS_TYPE",t.ERR_INVALID_NEW_PASS_TYPE="ERR_INVALID_NEW_PASS_TYPE",t.ERR_INVALID_PASS_LENGTH="ERR_INVALID_PASS_LENGTH",t.ERR_NOT_IMPLEMENTED="ERR_NOT_IMPLEMENTED",t.ERR_WRONG_PING_ACK="ERR_WRONG_PING_ACK",t.ERR_INVALID_RECORD="ERR_INVALID_RECORD",t.ERR_ALREADY_SUCCEEDED="ERR_ALREADY_SUCCEEDED",t.ERR_NO_HANDLER_FOR_PROTOCOL="ERR_NO_HANDLER_FOR_PROTOCOL",t.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS",t.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS",t.ERR_CONNECTION_DENIED="ERR_CONNECTION_DENIED",t.ERR_TRANSFER_LIMIT_EXCEEDED="ERR_TRANSFER_LIMIT_EXCEEDED"})(N||(N={}));var kI={addresses:{listen:[],announce:[],noAnnounce:[],announceFilter:t=>t},connectionManager:{resolvers:{dnsaddr:Di},addressSorter:Pi},transportManager:{faultTolerance:Xr.FATAL_ALL}};function Hg(t){let e=qr(kI,t);if(e.transports==null||e.transports.length<1)throw new v(or.ERR_TRANSPORTS_REQUIRED,N.ERR_TRANSPORTS_REQUIRED);if(e.connectionProtector===null&&globalThis.process?.env?.LIBP2P_FORCE_PNET!=null)throw new v(or.ERR_PROTECTOR_REQUIRED,N.ERR_PROTECTOR_REQUIRED);return e}var Gg="keep-alive";var H1=z(V1(),1);var gR=W("libp2p:get-peer");function Fa(t){if(Zs(t))return{peerId:t,multiaddrs:[]};Array.isArray(t)||(t=[t]);let e;if(t.length>0){let r=t[0].getPeerId();e=r==null?void 0:oe(r),t.forEach(n=>{if(!In(n))throw gR.error("multiaddr %s was invalid",n),new v("Invalid Multiaddr",N.ERR_INVALID_MULTIADDR);let i=n.getPeerId();if(i==null){if(e!=null)throw new v("Multiaddrs must all have the same peer id or have no peer id",N.ERR_INVALID_PARAMETERS)}else{let o=oe(i);if(e==null||!e.equals(o))throw new v("Multiaddrs must all have the same peer id or have no peer id",N.ERR_INVALID_PARAMETERS)}})}return{peerId:e,multiaddrs:t}}function xR(t,e,r){let n=0,i=t.length;for(;i>0;){let o=Math.trunc(i/2),s=n+o;r(t[s],e)<=0?(n=++s,i-=o+1):i=o}return n}var Xf=class{#e=[];enqueue(e,r){let n=r?.peerId,i=r?.priority??0;if(n==null)throw new v("missing peer id",N.ERR_INVALID_PARAMETERS);let o={priority:i,peerId:n,run:e};if(this.size>0&&this.#e[this.size-1].priority>=i){this.#e.push(o);return}let s=xR(this.#e,o,(a,c)=>c.priority-a.priority);this.#e.splice(s,0,o)}dequeue(){return this.#e.shift()?.run}filter(e){if(e.peerId!=null){let r=e.peerId;return this.#e.filter(n=>r.equals(n.peerId)).map(n=>n.run)}return this.#e.filter(r=>r.priority===e.priority).map(r=>r.run)}get size(){return this.#e.length}},Ka=class extends Ut{constructor(e={}){super({...e,queueClass:Xf})}hasJob(e){return this.sizeBy({peerId:e})>0}};var Xe=W("libp2p:connection-manager:auto-dial"),Go={minConnections:50,maxQueueLength:100,autoDialConcurrency:25,autoDialPriority:0,autoDialInterval:5e3},Va=class{connectionManager;peerStore;queue;minConnections;autoDialPriority;autoDialIntervalMs;autoDialMaxQueueLength;autoDialInterval;started;running;constructor(e,r){this.connectionManager=e.connectionManager,this.peerStore=e.peerStore,this.minConnections=r.minConnections??Go.minConnections,this.autoDialPriority=r.autoDialPriority??Go.autoDialPriority,this.autoDialIntervalMs=r.autoDialInterval??Go.autoDialInterval,this.autoDialMaxQueueLength=r.maxQueueLength??Go.maxQueueLength,this.started=!1,this.running=!1,this.queue=new Ka({concurrency:r.autoDialConcurrency??Go.autoDialConcurrency}),this.queue.addListener("error",n=>{Xe.error("error during auto-dial",n)}),e.events.addEventListener("connection:close",()=>{this.autoDial().catch(n=>{Xe.error(n)})})}isStarted(){return this.started}start(){this.autoDialInterval=setTimeout(()=>{this.autoDial().catch(e=>{Xe.error("error while autodialing",e)})},this.autoDialIntervalMs),this.started=!0}afterStart(){this.autoDial().catch(e=>{Xe.error("error while autodialing",e)})}stop(){this.queue.clear(),clearTimeout(this.autoDialInterval),this.started=!1,this.running=!1}async autoDial(){if(!this.started)return;let e=this.connectionManager.getConnectionsMap(),r=e.size;if(r>=this.minConnections){Xe.trace("have enough connections %d/%d",r,this.minConnections);return}if(this.queue.size>this.autoDialMaxQueueLength){Xe("not enough connections %d/%d but auto dial queue is full",r,this.minConnections);return}if(this.running){Xe("not enough connections %d/%d - but skipping autodial as it is already running",r,this.minConnections);return}this.running=!0,Xe("not enough connections %d/%d - will dial peers to increase the number of connections",r,this.minConnections);let n=new kt(this.connectionManager.getDialQueue().map(c=>c.peerId).filter(Boolean)),i=await this.peerStore.all({filters:[c=>c.addresses.length===0?(Xe.trace("not autodialing %p because they have no addresses"),!1):e.has(c.id)?(Xe.trace("not autodialing %p because they are already connected"),!1):n.has(c.id)?(Xe.trace("not autodialing %p because they are already being dialed"),!1):this.queue.hasJob(c.id)?(Xe.trace("not autodialing %p because they are already being autodialed"),!1):!0]}),o=i.sort(()=>Math.random()>.5?1:-1),s=new Nt;for(let c of o)s.has(c.id)||s.set(c.id,[...c.tags.values()].reduce((u,l)=>u+l.value,0));let a=o.sort((c,u)=>{let l=s.get(c.id)??0,f=s.get(u.id)??0;return l>f?-1:l<f?1:0});Xe("selected %d/%d peers to dial",a.length,i.length);for(let c of a)this.queue.add(async()=>{let u=this.connectionManager.getConnectionsMap().size;if(u>=this.minConnections){Xe("got enough connections now %d/%d",u,this.minConnections),this.queue.clear();return}Xe("connecting to a peerStore stored peer %p",c.id),await this.connectionManager.openConnection(c.id,{priority:this.autoDialPriority})},{peerId:c.id}).catch(u=>{Xe.error("could not connect to peerStore stored peer",u)});this.running=!1,this.started&&(this.autoDialInterval=setTimeout(()=>{this.autoDial().catch(c=>{Xe.error("error while autodialing",c)})},this.autoDialIntervalMs))}};var Ui=W("libp2p:connection-manager:connection-pruner"),q1={maxConnections:300,allow:[]},qa=class{maxConnections;connectionManager;peerStore;allow;events;constructor(e,r={}){this.maxConnections=r.maxConnections??q1.maxConnections,this.allow=r.allow??q1.allow,this.connectionManager=e.connectionManager,this.peerStore=e.peerStore,this.events=e.events,e.events.addEventListener("connection:open",()=>{this.maybePruneConnections().catch(n=>{Ui.error(n)})})}async maybePruneConnections(){let e=this.connectionManager.getConnections(),r=e.length,n=Math.max(r-this.maxConnections,0);if(Ui("checking max connections limit %d/%d",r,this.maxConnections),r<=this.maxConnections)return;Ui("max connections limit exceeded %d/%d, pruning %d connection(s)",r,this.maxConnections,n);let i=new Nt;for(let a of e){let c=a.remotePeer;if(!i.has(c)){i.set(c,0);try{let u=await this.peerStore.get(c);i.set(c,[...u.tags.values()].reduce((l,f)=>l+f.value,0))}catch(u){u.code!=="ERR_NOT_FOUND"&&Ui.error("error loading peer tags",u)}}}let o=e.sort((a,c)=>{let u=i.get(a.remotePeer)??0,l=i.get(c.remotePeer)??0;if(u>l)return 1;if(u<l)return-1;let f=a.stat.timeline.open,d=c.stat.timeline.open;return f<d?1:f>d?-1:0}),s=[];for(let a of o)if(Ui("too many connections open - closing a connection to %p",a.remotePeer),this.allow.some(u=>a.remoteAddr.toString().startsWith(u.toString()))||s.push(a),s.length===n)break;await Promise.all(s.map(async a=>{try{await a.close()}catch(c){Ui.error(c)}})),this.events.safeDispatchEvent("connection:prune",{detail:s})}};var ih=z($i(),1);function Fi(t){let e=new globalThis.AbortController;function r(){e.abort();for(let o of t)o?.removeEventListener!=null&&o.removeEventListener("abort",r)}for(let o of t){if(o?.aborted===!0){r();break}o?.addEventListener!=null&&o.addEventListener("abort",r)}function n(){for(let o of t)o?.removeEventListener!=null&&o.removeEventListener("abort",r)}let i=e.signal;return i.clear=n,i}function Yo(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}var rh=z($i(),1);var z1=W("libp2p:connection-manager:utils");async function nh(t,e){if(!t.protoNames().includes("dnsaddr"))return[t];let n=await bR(t,e),s=(await Promise.all(n.map(async a=>nh(a,e)))).flat().reduce((a,c)=>(a.find(u=>u.equals(c))==null&&a.push(c),a),[]);return z1("resolved %s to",t,s.map(a=>a.toString())),s}async function bR(t,e){try{return t=Ue(t.toString()),await t.resolve(e)}catch(r){return z1.error(`multiaddr ${t.toString()} could not be resolved`,r),[]}}function $1(...t){let e=[];for(let n of t)if(n!=null){try{(0,rh.setMaxListeners)?.(1/0,n)}catch{}e.push(n)}let r=Fi(e);try{(0,rh.setMaxListeners)?.(1/0,r)}catch{}return r}var je=W("libp2p:connection-manager:dial-queue"),Wo={addressSorter:Pi,maxParallelDials:100,maxPeerAddrsToDial:25,maxParallelDialsPerPeer:10,dialTimeout:3e4,resolvers:{dnsaddr:Di}},za=class{pendingDials;queue;peerId;peerStore;connectionGater;transportManager;addressSorter;maxPeerAddrsToDial;maxParallelDialsPerPeer;dialTimeout;inProgressDialCount;pendingDialCount;shutDownController;constructor(e,r={}){this.addressSorter=r.addressSorter??Wo.addressSorter,this.maxPeerAddrsToDial=r.maxPeerAddrsToDial??Wo.maxPeerAddrsToDial,this.maxParallelDialsPerPeer=r.maxParallelDialsPerPeer??Wo.maxParallelDialsPerPeer,this.dialTimeout=r.dialTimeout??Wo.dialTimeout,this.peerId=e.peerId,this.peerStore=e.peerStore,this.connectionGater=e.connectionGater,this.transportManager=e.transportManager,this.shutDownController=new AbortController;try{(0,ih.setMaxListeners)?.(1/0,this.shutDownController.signal)}catch{}this.pendingDialCount=e.metrics?.registerMetric("libp2p_dialler_pending_dials"),this.inProgressDialCount=e.metrics?.registerMetric("libp2p_dialler_in_progress_dials"),this.pendingDials=[];for(let[n,i]of Object.entries(r.resolvers??{}))of.set(n,i);this.queue=new Ut({concurrency:r.maxParallelDials??Wo.maxParallelDials}),this.queue.on("add",()=>{this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)}),this.queue.on("active",()=>{this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)}),this.queue.on("completed",()=>{this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)}),this.queue.on("error",n=>{je.error("error in dial queue",n),this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)}),this.queue.on("empty",()=>{this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)}),this.queue.on("idle",()=>{this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)})}stop(){this.shutDownController.abort()}async dial(e,r={}){let{peerId:n,multiaddrs:i}=Fa(e),o=i.map(l=>({multiaddr:l,isCertified:!1})),s=this.createDialAbortControllers(r.signal),a;try{a=await this.calculateMultiaddrs(n,o,{...r,signal:s})}catch(l){throw s.clear(),l}let c=this.pendingDials.find(l=>!!(l.peerId!=null&&n!=null&&l.peerId.equals(n)||a.map(({multiaddr:f})=>f.toString()).join()===l.multiaddrs.map(f=>f.toString()).join()));if(c!=null)return je("joining existing dial target for %p",n),s.clear(),c.promise;je("creating dial target for",a.map(({multiaddr:l})=>l.toString()));let u={id:ER(),status:"queued",peerId:n,multiaddrs:a.map(({multiaddr:l})=>l)};return u.promise=this.performDial(u,{...r,signal:s}).finally(()=>{this.pendingDials=this.pendingDials.filter(l=>l.id!==u.id),s.clear()}).catch(l=>{throw je.error("dial failed to %s",u.multiaddrs.map(f=>f.toString()).join(", "),l),s.aborted?new v(l.message,N.ERR_TIMEOUT):l}),this.pendingDials.push(u),u.promise}createDialAbortControllers(e){let r=Fi([AbortSignal.timeout(this.dialTimeout),this.shutDownController.signal,e]);try{(0,ih.setMaxListeners)?.(1/0,r)}catch{}return r}async calculateMultiaddrs(e,r=[],n={}){if(e!=null){if(this.peerId.equals(e))throw new v("Tried to dial self",N.ERR_DIALED_SELF);if(await this.connectionGater.denyDialPeer?.(e)===!0)throw new v("The dial request is blocked by gater.allowDialPeer",N.ERR_PEER_DIAL_INTERCEPTED);if(r.length===0){je("loading multiaddrs for %p",e);try{let l=await this.peerStore.get(e);r.push(...l.addresses),je("loaded multiaddrs for %p",e,r.map(({multiaddr:f})=>f.toString()))}catch(l){if(l.code!==N.ERR_NOT_FOUND)throw l}}}let i=(await Promise.all(r.map(async l=>{let f=await nh(l.multiaddr,n);return f.length===1&&f[0].equals(l.multiaddr)?l:f.map(d=>({multiaddr:d,isCertified:!1}))}))).flat(),o=i.filter(l=>!!this.transportManager.transportForMultiaddr(l.multiaddr)),s=new Map;for(let l of o){let f=l.multiaddr.toString(),d=s.get(f);if(d!=null){d.isCertified=d.isCertified||l.isCertified||!1;continue}s.set(f,l)}let a=[...s.values()];if((a.length===0||a.length>this.maxPeerAddrsToDial)&&(je("addresses for %p before filtering",e??"unknown peer",i.map(({multiaddr:l})=>l.toString())),je("addresses for %p after filtering",e??"unknown peer",a.map(({multiaddr:l})=>l.toString()))),a.length===0)throw new v("The dial request has no valid addresses",N.ERR_NO_VALID_ADDRESSES);if(a.length>this.maxPeerAddrsToDial)throw new v("dial with more addresses than allowed",N.ERR_TOO_MANY_ADDRESSES);if(e!=null){let l=`/p2p/${e.toString()}`;a=a.map(f=>{let d=f.multiaddr.getPeerId();return f.multiaddr.protos().pop()?.path===!0?f:d!==e.toString()?{multiaddr:f.multiaddr.encapsulate(l),isCertified:f.isCertified}:f})}let c=[];for(let l of a)this.connectionGater.denyDialMultiaddr!=null&&await this.connectionGater.denyDialMultiaddr(l.multiaddr)||c.push(l);let u=c.sort(this.addressSorter);if(u.length===0)throw new v("The connection gater denied all addresses in the dial request",N.ERR_NO_VALID_ADDRESSES);return u}async performDial(e,r={}){let n=e.multiaddrs.map(()=>new AbortController);try{let i=new Ut({concurrency:this.maxParallelDialsPerPeer});i.on("error",s=>{je.error("error dialling",s)});let o=await Promise.any(e.multiaddrs.map(async(s,a)=>{let c=n[a];if(c==null)throw new v("dialAction did not come with an AbortController",N.ERR_INVALID_PARAMETERS);let u=$1(c.signal,r.signal);u.addEventListener("abort",()=>{je("dial to %s aborted",s)});let l=Yo();return await i.add(async()=>{if(u.aborted){je("dial to %s was aborted before reaching the head of the peer dial queue",s),l.reject(new Cr);return}await this.queue.add(async()=>{try{if(u.aborted){je("dial to %s was aborted before reaching the head of the dial queue",s),l.reject(new Cr);return}e.status="active";let f=await this.transportManager.dial(s,{...r,signal:u});if(c.signal.aborted){je("multiple dials succeeded, closing superfluous connection"),f.close().catch(d=>{je.error("error closing superfluous connection",d)}),l.reject(new Cr);return}n[a]=void 0,n.forEach(d=>{d!==void 0&&d.abort()}),je("dial to %s succeeded",s),l.resolve(f)}catch(f){je.error("error during dial of %s",s,f),l.reject(f)}},{...r,signal:u}).catch(f=>{l.reject(f)})},{signal:u}).catch(f=>{l.reject(f)}).finally(()=>{u.clear()}),l.promise}));if(o==null)throw new v("successful dial led to empty object returned from peer dial queue",N.ERR_TRANSPORT_DIAL_FAILED);return e.status="success",o}catch(i){throw e.status="error",e.multiaddrs.length===1&&i.name==="AggregateError"?i.errors[0]:i}}};function ER(){return`${parseInt(String(Math.random()*1e9),10).toString()}${Date.now()}`}var xt=W("libp2p:connection-manager"),AR=50,Bn={minConnections:50,maxConnections:300,inboundConnectionThreshold:5,maxIncomingPendingConnections:10,autoDialConcurrency:25,autoDialPriority:0,autoDialMaxQueueLength:100},$a=class{started;connections;allow;deny;maxIncomingPendingConnections;incomingPendingConnections;maxConnections;dialQueue;autoDial;connectionPruner;inboundConnectionRateLimiter;peerStore;metrics;events;constructor(e,r={}){this.maxConnections=r.maxConnections??Bn.maxConnections;let n=r.minConnections??Bn.minConnections;if(this.maxConnections<n)throw new v("Connection Manager maxConnections must be greater than minConnections",N.ERR_INVALID_PARAMETERS);this.connections=new Nt,this.started=!1,this.peerStore=e.peerStore,this.metrics=e.metrics,this.events=e.events,this.onConnect=this.onConnect.bind(this),this.onDisconnect=this.onDisconnect.bind(this),this.events.addEventListener("connection:open",this.onConnect),this.events.addEventListener("connection:close",this.onDisconnect),this.allow=(r.allow??[]).map(i=>Ue(i)),this.deny=(r.deny??[]).map(i=>Ue(i)),this.incomingPendingConnections=0,this.maxIncomingPendingConnections=r.maxIncomingPendingConnections??Bn.maxIncomingPendingConnections,this.inboundConnectionRateLimiter=new H1.RateLimiterMemory({points:r.inboundConnectionThreshold??Bn.inboundConnectionThreshold,duration:1}),this.autoDial=new Va({connectionManager:this,peerStore:e.peerStore,events:e.events},{minConnections:n,autoDialConcurrency:r.autoDialConcurrency??Bn.autoDialConcurrency,autoDialPriority:r.autoDialPriority??Bn.autoDialPriority,maxQueueLength:r.autoDialMaxQueueLength??Bn.autoDialMaxQueueLength}),this.connectionPruner=new qa({connectionManager:this,peerStore:e.peerStore,events:e.events},{maxConnections:this.maxConnections,allow:this.allow}),this.dialQueue=new za({peerId:e.peerId,metrics:e.metrics,peerStore:e.peerStore,transportManager:e.transportManager,connectionGater:e.connectionGater},{addressSorter:r.addressSorter??Pi,maxParallelDials:r.maxParallelDials??100,maxPeerAddrsToDial:r.maxPeerAddrsToDial??25,dialTimeout:r.dialTimeout??3e4,resolvers:r.resolvers??{dnsaddr:Di}})}isStarted(){return this.started}async start(){this.metrics?.registerMetricGroup("libp2p_connection_manager_connections",{calculate:()=>{let e={inbound:0,outbound:0};for(let r of this.connections.values())for(let n of r)n.stat.direction==="inbound"?e.inbound++:e.outbound++;return e}}),this.metrics?.registerMetricGroup("libp2p_protocol_streams_total",{label:"protocol",calculate:()=>{let e={};for(let r of this.connections.values())for(let n of r)for(let i of n.streams){let o=`${i.stat.direction} ${i.stat.protocol??"unnegotiated"}`;e[o]=(e[o]??0)+1}return e}}),this.metrics?.registerMetricGroup("libp2p_connection_manager_protocol_streams_per_connection_90th_percentile",{label:"protocol",calculate:()=>{let e={};for(let n of this.connections.values())for(let i of n){let o={};for(let s of i.streams){let a=`${s.stat.direction} ${s.stat.protocol??"unnegotiated"}`;o[a]=(o[a]??0)+1}for(let[s,a]of Object.entries(o))e[s]=e[s]??[],e[s].push(a)}let r={};for(let[n,i]of Object.entries(e)){i=i.sort((s,a)=>s-a);let o=Math.floor(i.length*.9);r[n]=i[o]}return r}}),this.autoDial.start(),this.started=!0,xt("started")}async afterStart(){Promise.resolve().then(async()=>{let e=await this.peerStore.all({filters:[r=>r.tags.has(Gg)]});await Promise.all(e.map(async r=>{await this.openConnection(r.id).catch(n=>{xt.error(n)})}))}).catch(e=>{xt.error(e)}),this.autoDial.afterStart()}async stop(){this.dialQueue.stop(),this.autoDial.stop();let e=[];for(let r of this.connections.values())for(let n of r)e.push((async()=>{try{await n.close()}catch(i){xt.error(i)}})());xt("closing %d connections",e.length),await Promise.all(e),this.connections.clear(),xt("stopped")}onConnect(e){this._onConnect(e).catch(r=>{xt.error(r)})}async _onConnect(e){let{detail:r}=e;if(!this.started){await r.close();return}let n=r.remotePeer,i=this.connections.get(n),o=!1;i!=null?i.push(r):(o=!0,this.connections.set(n,[r])),n.publicKey!=null&&n.type==="RSA"&&await this.peerStore.patch(n,{publicKey:n.publicKey}),o&&this.events.safeDispatchEvent("peer:connect",{detail:r.remotePeer})}onDisconnect(e){let{detail:r}=e;if(!this.started)return;let n=r.remotePeer,i=this.connections.get(n);i!=null&&i.length>1?(i=i.filter(o=>o.id!==r.id),this.connections.set(n,i)):i!=null&&(this.connections.delete(n),this.events.safeDispatchEvent("peer:disconnect",{detail:r.remotePeer}))}getConnections(e){if(e!=null)return this.connections.get(e)??[];let r=[];for(let n of this.connections.values())r=r.concat(n);return r}getConnectionsMap(){return this.connections}async openConnection(e,r={}){if(!this.isStarted())throw new v("Not started",N.ERR_NODE_NOT_STARTED);let{peerId:n}=Fa(e);if(n!=null){xt("dial %p",n);let a=this.getConnections(n);if(a.length>0)return xt("had an existing connection to %p",n),a[0]}let i=await this.dialQueue.dial(e,{...r,priority:r.priority??AR}),o=this.connections.get(i.remotePeer);o==null&&(o=[],this.connections.set(i.remotePeer,o));let s=!1;for(let a of o)a.id===i.id&&(s=!0);return s||o.push(i),i}async closeConnections(e){let r=this.connections.get(e)??[];await Promise.all(r.map(async n=>{await n.close()}))}async acceptIncomingConnection(e){if(this.deny.some(i=>e.remoteAddr.toString().startsWith(i.toString())))return xt("connection from %s refused - connection remote address was in deny list",e.remoteAddr),!1;if(this.allow.some(i=>e.remoteAddr.toString().startsWith(i.toString())))return this.incomingPendingConnections++,!0;if(this.incomingPendingConnections===this.maxIncomingPendingConnections)return xt("connection from %s refused - incomingPendingConnections exceeded by peer %s",e.remoteAddr),!1;if(e.remoteAddr.isThinWaistAddress()){let i=e.remoteAddr.nodeAddress().address;try{await this.inboundConnectionRateLimiter.consume(i,1)}catch{return xt("connection from %s refused - inboundConnectionThreshold exceeded by host %s",i,e.remoteAddr),!1}}return this.getConnections().length<this.maxConnections?(this.incomingPendingConnections++,!0):(xt("connection from %s refused - maxConnections exceeded",e.remoteAddr),!1)}afterUpgradeInbound(){this.incomingPendingConnections--}getDialQueue(){return this.dialQueue.pendingDials}};var Ha=class{constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},Ki=class{constructor(e={}){this.hwm=e.splitLimit??16,this.head=new Ha(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let r=this.head;this.head=r.next=new Ha(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let r=this.tail.next;this.tail.next=null,this.tail=r,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};function Ln(t={}){return IR(r=>{let n=r.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},t)}function IR(t,e){e=e??{};let r=e.onEnd,n=new Ki,i,o,s,a=async()=>n.isEmpty()?s?{done:!0}:await new Promise((m,y)=>{o=g=>{o=null,n.push(g);try{m(t(n))}catch(x){y(x)}return i}}):t(n),c=m=>o!=null?o(m):(n.push(m),i),u=m=>(n=new Ki,o!=null?o({error:m}):(n.push({error:m}),i)),l=m=>{if(s)return i;if(e?.objectMode!==!0&&m?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return c({done:!1,value:m})},f=m=>s?i:(s=!0,m!=null?u(m):c({done:!0})),d=()=>(n=new Ki,f(),{done:!0}),p=m=>(f(m),{done:!0});if(i={[Symbol.asyncIterator](){return this},next:a,return:d,throw:p,push:l,end:f,get readableLength(){return n.size}},r==null)return i;let h=i;return i={[Symbol.asyncIterator](){return this},next(){return h.next()},throw(m){return h.throw(m),r!=null&&(r(m),r=void 0),{done:!0}},return(){return h.return(),r!=null&&(r(),r=void 0),{done:!0}},push:l,end(m){return h.end(m),r!=null&&(r(m),r=void 0),i},get readableLength(){return h.readableLength}},i}function RR(t){return t[Symbol.asyncIterator]!=null}function CR(...t){let e=[];for(let r of t)RR(r)||e.push(r);return e.length===t.length?function*(){for(let r of e)yield*r}():async function*(){let r=Ln({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(t.map(async n=>{for await(let i of n)r.push(i)})),r.end()}catch(n){r.end(n)}}),yield*r}()}var jr=CR;function Pn(t,...e){if(t==null)throw new Error("Empty pipeline");if(ch(t)){let n=t;t=()=>n.source}else if(Y1(t)||G1(t)){let n=t;t=()=>n}let r=[t,...e];if(r.length>1&&ch(r[r.length-1])&&(r[r.length-1]=r[r.length-1].sink),r.length>2)for(let n=1;n<r.length-1;n++)ch(r[n])&&(r[n]=BR(r[n]));return TR(...r)}var TR=(...t)=>{let e;for(;t.length>0;)e=t.shift()(e);return e},G1=t=>t?.[Symbol.asyncIterator]!=null,Y1=t=>t?.[Symbol.iterator]!=null,ch=t=>t==null?!1:t.sink!=null&&t.source!=null,BR=t=>e=>{let r=t.sink(e);if(r?.then!=null){let n=Ln({objectMode:!0});r.then(()=>{n.end()},s=>{n.end(s)});let i,o=t.source;if(G1(o))i=async function*(){yield*o,n.end()};else if(Y1(o))i=function*(){yield*o,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return jr(n,i())}return t.source};function LR(t){return t[Symbol.asyncIterator]!=null}function PR(t,e){if(LR(t))return async function*(){for await(let a of t)yield e(a)}();let r=Ba(t),{value:n,done:i}=r.next();if(i===!0)return function*(){}();let o=e(n);if(typeof o.then=="function")return async function*(){yield await o;for await(let a of r)yield e(a)}();let s=e;return function*(){yield o;for(let a of r)yield s(a)}()}var W1=PR;async function*Qo(t,e){yield*W1(t,async r=>(await e.merge(r.id,{multiaddrs:r.multiaddrs}),r))}function Ga(t){let e=new Set;return Ft(t,r=>e.has(r.id.toString())?!1:(e.add(r.id.toString()),!0))}async function*Ya(t,e=1){let r=0;for await(let n of t)r++,yield n;if(r<e)throw new v(`more peers required, seen: ${r} min: ${e}`,"NOT_FOUND")}var Wa=class{routers;started;components;constructor(e,r){this.routers=r.routers??[],this.started=!1,this.components=e}isStarted(){return this.started}async start(){this.started=!0}async stop(){this.started=!1}async*findProviders(e,r={}){if(this.routers.length===0)throw new v("No content routers available",N.ERR_NO_ROUTERS_AVAILABLE);yield*Pn(jr(...this.routers.map(n=>n.findProviders(e,r))),n=>Qo(n,this.components.peerStore),n=>Ga(n),n=>Ya(n))}async provide(e,r={}){if(this.routers.length===0)throw new v("No content routers available",N.ERR_NO_ROUTERS_AVAILABLE);await Promise.all(this.routers.map(async n=>{await n.provide(e,r)}))}async put(e,r,n){if(!this.isStarted())throw new v(or.NOT_STARTED_YET,N.DHT_NOT_STARTED);await Promise.all(this.routers.map(async i=>{await i.put(e,r,n)}))}async get(e,r){if(!this.isStarted())throw new v(or.NOT_STARTED_YET,N.DHT_NOT_STARTED);return Promise.any(this.routers.map(async n=>n.get(e,r)))}};function DR(t){return t[Symbol.asyncIterator]!=null}function NR(t){if(DR(t))return(async()=>{for await(let e of t)return e})();for(let e of t)return e}var Qa=NR;var kR=W("libp2p:peer-routing"),Xa=class{components;routers;constructor(e,r){this.components=e,this.routers=r.routers??[]}async findPeer(e,r){if(this.routers.length===0)throw new v("No peer routers available",N.ERR_NO_ROUTERS_AVAILABLE);if(e.toString()===this.components.peerId.toString())throw new v("Should not try to find self",N.ERR_FIND_SELF);let n=await Pn(jr(...this.routers.map(i=>async function*(){try{yield await i.findPeer(e,r)}catch(o){kR.error(o)}}())),i=>Ft(i,Boolean),i=>Qo(i,this.components.peerStore),async i=>Qa(i));if(n!=null)return n;throw new v(or.NOT_FOUND,N.ERR_NOT_FOUND)}async*getClosestPeers(e,r){if(this.routers.length===0)throw new v("No peer routers available",N.ERR_NO_ROUTERS_AVAILABLE);yield*Pn(jr(...this.routers.map(n=>n.getClosestPeers(e,r))),n=>Qo(n,this.components.peerStore),n=>Ga(n),n=>Ya(n))}};var uh=W("libp2p:registrar"),lh=32,fh=64,Za=class{topologies;handlers;components;constructor(e){this.topologies=new Map,this.handlers=new Map,this.components=e,this._onDisconnect=this._onDisconnect.bind(this),this._onPeerUpdate=this._onPeerUpdate.bind(this),this._onConnect=this._onConnect.bind(this),this.components.events.addEventListener("peer:disconnect",this._onDisconnect),this.components.events.addEventListener("peer:connect",this._onConnect),this.components.events.addEventListener("peer:update",this._onPeerUpdate)}getProtocols(){return Array.from(new Set([...this.handlers.keys()])).sort()}getHandler(e){let r=this.handlers.get(e);if(r==null)throw new v(`No handler registered for protocol ${e}`,N.ERR_NO_HANDLER_FOR_PROTOCOL);return r}getTopologies(e){let r=this.topologies.get(e);return r==null?[]:[...r.values()]}async handle(e,r,n){if(this.handlers.has(e))throw new v(`Handler already registered for protocol ${e}`,N.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED);let i=qr.bind({ignoreUndefined:!0})({maxInboundStreams:lh,maxOutboundStreams:fh},n);this.handlers.set(e,{handler:r,options:i}),await this.components.peerStore.merge(this.components.peerId,{protocols:[e]})}async unhandle(e){let r=Array.isArray(e)?e:[e];r.forEach(n=>{this.handlers.delete(n)}),await this.components.peerStore.patch(this.components.peerId,{protocols:r})}async register(e,r){if(r==null)throw new v("invalid topology",N.ERR_INVALID_PARAMETERS);let n=`${(Math.random()*1e9).toString(36)}${Date.now()}`,i=this.topologies.get(e);return i==null&&(i=new Map,this.topologies.set(e,i)),i.set(n,r),n}unregister(e){for(let[r,n]of this.topologies.entries())n.has(e)&&(n.delete(e),n.size===0&&this.topologies.delete(r))}_onDisconnect(e){let r=e.detail;this.components.peerStore.get(r).then(n=>{for(let i of n.protocols){let o=this.topologies.get(i);if(o!=null)for(let s of o.values())s.onDisconnect?.(r)}}).catch(n=>{n.code!==N.ERR_NOT_FOUND&&uh.error("could not inform topologies of disconnecting peer %p",r,n)})}_onConnect(e){let r=e.detail;this.components.peerStore.get(r).then(n=>{let i=this.components.connectionManager.getConnections(n.id)[0];if(i==null){uh("peer %p connected but the connection manager did not have a connection",n);return}for(let o of n.protocols){let s=this.topologies.get(o);if(s!=null)for(let a of s.values())a.onConnect?.(r,i)}}).catch(n=>{n.code!==N.ERR_NOT_FOUND&&uh.error("could not inform topologies of connecting peer %p",r,n)})}_onPeerUpdate(e){let{peer:r,previous:n}=e.detail,i=(n?.protocols??[]).filter(s=>!r.protocols.includes(s)),o=r.protocols.filter(s=>!(n?.protocols??[]).includes(s));for(let s of i){let a=this.topologies.get(s);if(a!=null)for(let c of a.values())c.onDisconnect?.(r.id)}for(let s of o){let a=this.topologies.get(s);if(a!=null)for(let c of a.values()){let u=this.components.connectionManager.getConnections(r.id)[0];u!=null&&c.onConnect?.(r.id,u)}}}};var hh=class extends Map{metric;constructor(e){super();let{name:r,metrics:n}=e;this.metric=n.registerMetric(r),this.updateComponentMetric()}set(e,r){return super.set(e,r),this.updateComponentMetric(),this}delete(e){let r=super.delete(e);return this.updateComponentMetric(),r}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function Q1(t){let{name:e,metrics:r}=t,n;return r!=null?n=new hh({name:e,metrics:r}):n=new Map,n}var Dn=W("libp2p:transports"),ja=class{components;transports;listeners;faultTolerance;started;constructor(e,r={}){this.components=e,this.started=!1,this.transports=new Map,this.listeners=Q1({name:"libp2p_transport_manager_listeners",metrics:this.components.metrics}),this.faultTolerance=r.faultTolerance??Xr.FATAL_ALL}add(e){let r=e[Symbol.toStringTag];if(r==null)throw new v("Transport must have a valid tag",N.ERR_INVALID_KEY);if(this.transports.has(r))throw new v(`There is already a transport with the tag ${r}`,N.ERR_DUPLICATE_TRANSPORT);Dn("adding transport %s",r),this.transports.set(r,e),this.listeners.has(r)||this.listeners.set(r,[])}isStarted(){return this.started}start(){this.started=!0}async afterStart(){let e=this.components.addressManager.getListenAddrs();await this.listen(e)}async stop(){let e=[];for(let[r,n]of this.listeners)for(Dn("closing listeners for %s",r);n.length>0;){let i=n.pop();i!=null&&e.push(i.close())}await Promise.all(e),Dn("all listeners closed");for(let r of this.listeners.keys())this.listeners.set(r,[]);this.started=!1}async dial(e,r){let n=this.transportForMultiaddr(e);if(n==null)throw new v(`No transport available for address ${String(e)}`,N.ERR_TRANSPORT_UNAVAILABLE);try{return await n.dial(e,{...r,upgrader:this.components.upgrader})}catch(i){throw i.code==null&&(i.code=N.ERR_TRANSPORT_DIAL_FAILED),i}}getAddrs(){let e=[];for(let r of this.listeners.values())for(let n of r)e=[...e,...n.getAddrs()];return e}getTransports(){return Array.of(...this.transports.values())}getListeners(){return Array.of(...this.listeners.values()).flat()}transportForMultiaddr(e){for(let r of this.transports.values())if(r.filter([e]).length>0)return r}async listen(e){if(e==null||e.length===0){Dn("no addresses were provided for listening, this node is dial only");return}let r=[];for(let[n,i]of this.transports.entries()){let o=i.filter(e),s=[];for(let u of o){Dn("creating listener for %s on %s",n,u);let l=i.createListener({upgrader:this.components.upgrader}),f=this.listeners.get(n)??[];f==null&&(f=[],this.listeners.set(n,f)),f.push(l),l.addEventListener("listening",()=>{this.components.events.safeDispatchEvent("transport:listening",{detail:l})}),l.addEventListener("close",()=>{let d=f.findIndex(p=>p===l);f.splice(d,1),this.components.events.safeDispatchEvent("transport:close",{detail:l})}),s.push(l.listen(u))}if(s.length===0){r.push(n);continue}if((await Promise.allSettled(s)).find(u=>u.status==="fulfilled")==null&&this.faultTolerance!==Xr.NO_FATAL)throw new v(`Transport (${n}) could not listen on any available address`,N.ERR_NO_VALID_ADDRESSES)}if(r.length===this.transports.size){let n=`no valid addresses were provided for transports [${r.join(", ")}]`;if(this.faultTolerance===Xr.FATAL_ALL)throw new v(n,N.ERR_NO_VALID_ADDRESSES);Dn(`libp2p in dial mode only: ${n}`)}}async remove(e){Dn("removing %s",e);for(let r of this.listeners.get(e)??[])await r.close();this.transports.delete(e),this.listeners.delete(e)}async removeAll(){let e=[];for(let r of this.transports.keys())e.push(this.remove(r));await Promise.all(e)}};var gh=z($i(),1);var _r="/multistream/1.0.0";function dh(t){let e=async function*(){let r=yield,n=new Te;for await(let i of t){if(r==null){n.append(i),r=yield n,n=new Te;continue}for(n.append(i);n.length>=r;){let o=n.sublist(0,r);if(n.consume(r),r=yield o,r==null){n.length>0&&(r=yield n,n=new Te);break}}}if(r!=null)throw Object.assign(new Error(`stream ended before ${r} bytes became available`),{code:"ERR_UNDER_READ",buffer:n})}();return e.next(),e}function Ja(t){let e=Ln(),r=dh(t.source),n=Yo(),i,o=t.sink(async function*(){yield*e,yield*await n.promise}());return o.catch(a=>{i=a}),{reader:r,writer:e,stream:{sink:async a=>{if(i!=null){await Promise.reject(i);return}n.resolve(a),await o},source:r},rest:()=>e.end(),write:e.push,read:async()=>{let a=await r.next();if(a.value!=null)return a.value}}}var Xo=class extends Error{constructor(e,r){super(e??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function X1(t){if(t!=null){if(typeof t[Symbol.iterator]=="function")return t[Symbol.iterator]();if(typeof t[Symbol.asyncIterator]=="function")return t[Symbol.asyncIterator]();if(typeof t.next=="function")return t}throw new Error("argument is not an iterator or iterable")}function ec(t,e,r){let n=r??{},i=X1(t);async function*o(){let s,a=()=>{s?.()};for(e.addEventListener("abort",a);;){let c;try{if(e.aborted){let{abortMessage:l,abortCode:f}=n;throw new Xo(l,f)}let u=new Promise((l,f)=>{s=()=>{let{abortMessage:d,abortCode:p}=n;f(new Xo(d,p))}});c=await Promise.race([u,i.next()]),s=null}catch(u){e.removeEventListener("abort",a);let l=u.type==="aborted"&&e.aborted;if(l&&n.onAbort!=null&&n.onAbort(t),typeof i.return=="function")try{let f=i.return();f instanceof Promise&&f.catch(d=>{n.onReturnError!=null&&n.onReturnError(d)})}catch(f){n.onReturnError!=null&&n.onReturnError(f)}if(l&&n.returnOnAbort===!0)return;throw u}if(c.done===!0)break;yield c.value}e.removeEventListener("abort",a)}return o()}function OR(t,e,r){return n=>t(ec(n,e,r))}function Z1(t,e,r){return{sink:OR(t.sink,e,{...r,onAbort:void 0}),source:ec(t.source,e,r)}}function tc(t){return t[Symbol.asyncIterator]!=null}var rc=t=>{let e=Ot.encodingLength(t),r=Ct(e);return Ot.encode(t,r),rc.bytes=e,r};rc.bytes=0;function nc(t,e){e=e??{};let r=e.lengthEncoder??rc;function*n(i){let o=r(i.byteLength);o instanceof Uint8Array?yield o:yield*o,i instanceof Uint8Array?yield i:yield*i}return tc(t)?async function*(){for await(let i of t)yield*n(i)}():function*(){for(let i of t)yield*n(i)}()}nc.single=(t,e)=>{e=e??{};let r=e.lengthEncoder??rc;return new Te(r(t.byteLength),t)};var Vi=z(Cf(),1);var MR=8,UR=1024*1024*4,Nn;(function(t){t[t.LENGTH=0]="LENGTH",t[t.DATA=1]="DATA"})(Nn||(Nn={}));var ph=t=>{let e=Ot.decode(t);return ph.bytes=Ot.encodingLength(e),e};ph.bytes=0;function Zo(t,e){let r=new Te,n=Nn.LENGTH,i=-1,o=e?.lengthDecoder??ph,s=e?.maxLengthLength??MR,a=e?.maxDataLength??UR;function*c(){for(;r.byteLength>0;){if(n===Nn.LENGTH)try{if(i=o(r),i<0)throw(0,Vi.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(i>a)throw(0,Vi.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let u=o.bytes;r.consume(u),e?.onLength!=null&&e.onLength(i),n=Nn.DATA}catch(u){if(u instanceof RangeError){if(r.byteLength>s)throw(0,Vi.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw u}if(n===Nn.DATA){if(r.byteLength<i)break;let u=r.sublist(0,i);r.consume(i),e?.onData!=null&&e.onData(u),yield u,n=Nn.LENGTH}}}return tc(t)?async function*(){for await(let u of t)r.append(u),yield*c();if(r.byteLength>0)throw(0,Vi.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(let u of t)r.append(u),yield*c();if(r.byteLength>0)throw(0,Vi.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}Zo.fromReader=(t,e)=>{let r=1,n=async function*(){for(;;)try{let{done:o,value:s}=await t.next(r);if(o===!0)return;s!=null&&(yield s)}catch(o){if(o.code==="ERR_UNDER_READ")return{done:!0,value:null};throw o}finally{r=1}}();return Zo(n,{...e??{},onLength:o=>{r=o}})};var VR=W("libp2p:mss"),j1=V(`
|
|
48
|
+
`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),EI=new RegExp(`(?:^${Kt}$)|(?:^${Na}$)`),_I=new RegExp(`^${Kt}$`),SI=new RegExp(`^${Na}$`),Lf=t=>t&&t.exact?EI:new RegExp(`(?:${Qr(t)}${Kt}${Qr(t)})|(?:${Qr(t)}${Na}${Qr(t)})`,"g");Lf.v4=t=>t&&t.exact?_I:new RegExp(`${Qr(t)}${Kt}${Qr(t)}`,"g");Lf.v6=t=>t&&t.exact?SI:new RegExp(`${Qr(t)}${Na}${Qr(t)}`,"g");var Tg=Lf;var Ng=z(Lg(),1),{isValid:AI,parse:II}=Ng.default,RI=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"],CI=RI.map(t=>new Dg.Netmask(t));function TI(t){for(let e of CI)if(e.contains(t))return!0;return!1}function Pg(t){return/^::$/.test(t)||/^::1$/.test(t)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(t)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(t)||/^ff([0-9a-fA-F]{2,2}):/i.test(t)}var kg=t=>{if(AI(t)){let e=II(t);if(e.kind()==="ipv4")return TI(e.toNormalizedString());if(e.kind()==="ipv6")return Pg(t)}else if(Ai(t)&&Tg.v6().test(t))return Pg(t)};var Oa=kg;function Og(t={}){return{denyDialPeer:async()=>!1,denyDialMultiaddr:async e=>{let r=e.stringTuples();return r[0][0]===4||r[0][0]===41?!!Oa(`${r[0][1]}`):!1},denyInboundConnection:async()=>!1,denyOutboundConnection:async()=>!1,denyInboundEncryptedConnection:async()=>!1,denyOutboundEncryptedConnection:async()=>!1,denyInboundUpgradedConnection:async()=>!1,denyOutboundUpgradedConnection:async()=>!1,filterMultiaddrForPeer:async()=>!0,...t}}var J5=Symbol.for("@libp2p/transport");var Xr;(function(t){t[t.FATAL_ALL=0]="FATAL_ALL",t[t.NO_FATAL=1]="NO_FATAL"})(Xr||(Xr={}));function Pf(t){try{let{address:e}=t.nodeAddress();return!!Oa(e)}catch{return!0}}function Pi(t,e){let r=Pf(t.multiaddr),n=Pf(e.multiaddr);return r&&!n?1:!r&&n||t.isCertified&&!e.isCertified?-1:!t.isCertified&&e.isCertified?1:0}var Nf=z(al(),1),kf=z(Fg(),1);var Kg=globalThis.fetch,Vg=globalThis.Headers,sD=globalThis.Request,aD=globalThis.Response;function Ma(t,e,r){return`${t}?name=${e}&type=${r}`}async function qg(t,e){return await(await Kg(t,{headers:new Vg({accept:"application/dns-json"}),signal:e})).json()}function Tn(t,e){return`${e}_${t}`}var Df=Object.assign((0,Nf.default)("dns-over-http-resolver"),{error:(0,Nf.default)("dns-over-http-resolver:error")}),Of=class{constructor(e={}){this._cache=new kf.default({max:e?.maxCache??100}),this._TXTcache=new kf.default({max:e?.maxCache??100}),this._servers=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve"],this._request=e.request??qg,this._abortControllers=[]}cancel(){this._abortControllers.forEach(e=>e.abort())}getServers(){return this._servers}_getShuffledServers(){let e=[...this._servers];for(let r=e.length-1;r>0;r--){let n=Math.floor(Math.random()*r),i=e[r];e[r]=e[n],e[n]=i}return e}setServers(e){this._servers=e}async resolve(e,r="A"){switch(r){case"A":return await this.resolve4(e);case"AAAA":return await this.resolve6(e);case"TXT":return await this.resolveTxt(e);default:throw new Error(`${r} is not supported`)}}async resolve4(e){let r="A",n=this._cache.get(Tn(e,r));if(n!=null)return n;let i=!1;for(let o of this._getShuffledServers()){let s=new AbortController;this._abortControllers.push(s);try{let a=await this._request(Ma(o,e,r),s.signal),c=a.Answer.map(l=>l.data),u=Math.min(...a.Answer.map(l=>l.TTL));return this._cache.set(Tn(e,r),c,{ttl:u}),c}catch{s.signal.aborted&&(i=!0),Df.error(`${o} could not resolve ${e} record ${r}`)}finally{this._abortControllers=this._abortControllers.filter(a=>a!==s)}}throw i?Object.assign(new Error("queryA ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record ${r}`)}async resolve6(e){let r="AAAA",n=this._cache.get(Tn(e,r));if(n!=null)return n;let i=!1;for(let o of this._getShuffledServers()){let s=new AbortController;this._abortControllers.push(s);try{let a=await this._request(Ma(o,e,r),s.signal),c=a.Answer.map(l=>l.data),u=Math.min(...a.Answer.map(l=>l.TTL));return this._cache.set(Tn(e,r),c,{ttl:u}),c}catch{s.signal.aborted&&(i=!0),Df.error(`${o} could not resolve ${e} record ${r}`)}finally{this._abortControllers=this._abortControllers.filter(a=>a!==s)}}throw i?Object.assign(new Error("queryAaaa ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record ${r}`)}async resolveTxt(e){let r="TXT",n=this._TXTcache.get(Tn(e,r));if(n!=null)return n;let i=!1;for(let o of this._getShuffledServers()){let s=new AbortController;this._abortControllers.push(s);try{let a=await this._request(Ma(o,e,r),s.signal),c=a.Answer.map(l=>[l.data.replace(/['"]+/g,"")]),u=Math.min(...a.Answer.map(l=>l.TTL));return this._TXTcache.set(Tn(e,r),c,{ttl:u}),c}catch{s.signal.aborted&&(i=!0),Df.error(`${o} could not resolve ${e} record ${r}`)}finally{this._abortControllers=this._abortControllers.filter(a=>a!==s)}}throw i?Object.assign(new Error("queryTxt ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record ${r}`)}clearCache(){this._cache.clear(),this._TXTcache.clear()}},zg=Of;var $g=zg;var{code:NI}=le("dnsaddr");async function Di(t,e={}){let r=new $g;e.signal!=null&&e.signal.addEventListener("abort",()=>{r.cancel()});let n=t.getPeerId(),[,i]=t.stringTuples().find(([a])=>a===NI)??[];if(i==null)throw new Error("No hostname found in multiaddr");let s=(await r.resolveTxt(`_dnsaddr.${i}`)).flat().map(a=>a.split("=")[1]).filter(Boolean);return n!=null&&(s=s.filter(a=>a.includes(n))),s}var or;(function(t){t.NOT_STARTED_YET="The libp2p node is not started yet",t.DHT_DISABLED="DHT is not available",t.PUBSUB_DISABLED="PubSub is not available",t.CONN_ENCRYPTION_REQUIRED="At least one connection encryption module is required",t.ERR_TRANSPORTS_REQUIRED="At least one transport module is required",t.ERR_PROTECTOR_REQUIRED="Private network is enforced, but no protector was provided",t.NOT_FOUND="Not found"})(or||(or={}));var N;(function(t){t.DHT_DISABLED="ERR_DHT_DISABLED",t.ERR_PUBSUB_DISABLED="ERR_PUBSUB_DISABLED",t.PUBSUB_NOT_STARTED="ERR_PUBSUB_NOT_STARTED",t.DHT_NOT_STARTED="ERR_DHT_NOT_STARTED",t.CONN_ENCRYPTION_REQUIRED="ERR_CONN_ENCRYPTION_REQUIRED",t.ERR_TRANSPORTS_REQUIRED="ERR_TRANSPORTS_REQUIRED",t.ERR_PROTECTOR_REQUIRED="ERR_PROTECTOR_REQUIRED",t.ERR_PEER_DIAL_INTERCEPTED="ERR_PEER_DIAL_INTERCEPTED",t.ERR_CONNECTION_INTERCEPTED="ERR_CONNECTION_INTERCEPTED",t.ERR_INVALID_PROTOCOLS_FOR_STREAM="ERR_INVALID_PROTOCOLS_FOR_STREAM",t.ERR_CONNECTION_ENDED="ERR_CONNECTION_ENDED",t.ERR_CONNECTION_FAILED="ERR_CONNECTION_FAILED",t.ERR_NODE_NOT_STARTED="ERR_NODE_NOT_STARTED",t.ERR_ALREADY_ABORTED="ERR_ALREADY_ABORTED",t.ERR_TOO_MANY_ADDRESSES="ERR_TOO_MANY_ADDRESSES",t.ERR_NO_VALID_ADDRESSES="ERR_NO_VALID_ADDRESSES",t.ERR_RELAYED_DIAL="ERR_RELAYED_DIAL",t.ERR_DIALED_SELF="ERR_DIALED_SELF",t.ERR_DISCOVERED_SELF="ERR_DISCOVERED_SELF",t.ERR_DUPLICATE_TRANSPORT="ERR_DUPLICATE_TRANSPORT",t.ERR_ENCRYPTION_FAILED="ERR_ENCRYPTION_FAILED",t.ERR_HOP_REQUEST_FAILED="ERR_HOP_REQUEST_FAILED",t.ERR_INVALID_KEY="ERR_INVALID_KEY",t.ERR_INVALID_MESSAGE="ERR_INVALID_MESSAGE",t.ERR_INVALID_PARAMETERS="ERR_INVALID_PARAMETERS",t.ERR_INVALID_PEER="ERR_INVALID_PEER",t.ERR_MUXER_UNAVAILABLE="ERR_MUXER_UNAVAILABLE",t.ERR_NOT_FOUND="ERR_NOT_FOUND",t.ERR_TIMEOUT="ERR_TIMEOUT",t.ERR_TRANSPORT_UNAVAILABLE="ERR_TRANSPORT_UNAVAILABLE",t.ERR_TRANSPORT_DIAL_FAILED="ERR_TRANSPORT_DIAL_FAILED",t.ERR_UNSUPPORTED_PROTOCOL="ERR_UNSUPPORTED_PROTOCOL",t.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED="ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED",t.ERR_INVALID_MULTIADDR="ERR_INVALID_MULTIADDR",t.ERR_SIGNATURE_NOT_VALID="ERR_SIGNATURE_NOT_VALID",t.ERR_FIND_SELF="ERR_FIND_SELF",t.ERR_NO_ROUTERS_AVAILABLE="ERR_NO_ROUTERS_AVAILABLE",t.ERR_CONNECTION_NOT_MULTIPLEXED="ERR_CONNECTION_NOT_MULTIPLEXED",t.ERR_NO_DIAL_TOKENS="ERR_NO_DIAL_TOKENS",t.ERR_KEYCHAIN_REQUIRED="ERR_KEYCHAIN_REQUIRED",t.ERR_INVALID_CMS="ERR_INVALID_CMS",t.ERR_MISSING_KEYS="ERR_MISSING_KEYS",t.ERR_NO_KEY="ERR_NO_KEY",t.ERR_INVALID_KEY_NAME="ERR_INVALID_KEY_NAME",t.ERR_INVALID_KEY_TYPE="ERR_INVALID_KEY_TYPE",t.ERR_KEY_ALREADY_EXISTS="ERR_KEY_ALREADY_EXISTS",t.ERR_INVALID_KEY_SIZE="ERR_INVALID_KEY_SIZE",t.ERR_KEY_NOT_FOUND="ERR_KEY_NOT_FOUND",t.ERR_OLD_KEY_NAME_INVALID="ERR_OLD_KEY_NAME_INVALID",t.ERR_NEW_KEY_NAME_INVALID="ERR_NEW_KEY_NAME_INVALID",t.ERR_PASSWORD_REQUIRED="ERR_PASSWORD_REQUIRED",t.ERR_PEM_REQUIRED="ERR_PEM_REQUIRED",t.ERR_CANNOT_READ_KEY="ERR_CANNOT_READ_KEY",t.ERR_MISSING_PRIVATE_KEY="ERR_MISSING_PRIVATE_KEY",t.ERR_MISSING_PUBLIC_KEY="ERR_MISSING_PUBLIC_KEY",t.ERR_INVALID_OLD_PASS_TYPE="ERR_INVALID_OLD_PASS_TYPE",t.ERR_INVALID_NEW_PASS_TYPE="ERR_INVALID_NEW_PASS_TYPE",t.ERR_INVALID_PASS_LENGTH="ERR_INVALID_PASS_LENGTH",t.ERR_NOT_IMPLEMENTED="ERR_NOT_IMPLEMENTED",t.ERR_WRONG_PING_ACK="ERR_WRONG_PING_ACK",t.ERR_INVALID_RECORD="ERR_INVALID_RECORD",t.ERR_ALREADY_SUCCEEDED="ERR_ALREADY_SUCCEEDED",t.ERR_NO_HANDLER_FOR_PROTOCOL="ERR_NO_HANDLER_FOR_PROTOCOL",t.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS",t.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS",t.ERR_CONNECTION_DENIED="ERR_CONNECTION_DENIED",t.ERR_TRANSFER_LIMIT_EXCEEDED="ERR_TRANSFER_LIMIT_EXCEEDED"})(N||(N={}));var kI={addresses:{listen:[],announce:[],noAnnounce:[],announceFilter:t=>t},connectionManager:{resolvers:{dnsaddr:Di},addressSorter:Pi},transportManager:{faultTolerance:Xr.FATAL_ALL}};function Hg(t){let e=qr(kI,t);if(e.transports==null||e.transports.length<1)throw new v(or.ERR_TRANSPORTS_REQUIRED,N.ERR_TRANSPORTS_REQUIRED);if(e.connectionProtector===null&&globalThis.process?.env?.LIBP2P_FORCE_PNET!=null)throw new v(or.ERR_PROTECTOR_REQUIRED,N.ERR_PROTECTOR_REQUIRED);return e}var Gg="keep-alive";var H1=z(V1(),1);var gR=W("libp2p:get-peer");function Fa(t){if(Zs(t))return{peerId:t,multiaddrs:[]};Array.isArray(t)||(t=[t]);let e;if(t.length>0){let r=t[0].getPeerId();e=r==null?void 0:oe(r),t.forEach(n=>{if(!In(n))throw gR.error("multiaddr %s was invalid",n),new v("Invalid Multiaddr",N.ERR_INVALID_MULTIADDR);let i=n.getPeerId();if(i==null){if(e!=null)throw new v("Multiaddrs must all have the same peer id or have no peer id",N.ERR_INVALID_PARAMETERS)}else{let o=oe(i);if(e==null||!e.equals(o))throw new v("Multiaddrs must all have the same peer id or have no peer id",N.ERR_INVALID_PARAMETERS)}})}return{peerId:e,multiaddrs:t}}function xR(t,e,r){let n=0,i=t.length;for(;i>0;){let o=Math.trunc(i/2),s=n+o;r(t[s],e)<=0?(n=++s,i-=o+1):i=o}return n}var Xf=class{#e=[];enqueue(e,r){let n=r?.peerId,i=r?.priority??0;if(n==null)throw new v("missing peer id",N.ERR_INVALID_PARAMETERS);let o={priority:i,peerId:n,run:e};if(this.size>0&&this.#e[this.size-1].priority>=i){this.#e.push(o);return}let s=xR(this.#e,o,(a,c)=>c.priority-a.priority);this.#e.splice(s,0,o)}dequeue(){return this.#e.shift()?.run}filter(e){if(e.peerId!=null){let r=e.peerId;return this.#e.filter(n=>r.equals(n.peerId)).map(n=>n.run)}return this.#e.filter(r=>r.priority===e.priority).map(r=>r.run)}get size(){return this.#e.length}},Ka=class extends Ut{constructor(e={}){super({...e,queueClass:Xf})}hasJob(e){return this.sizeBy({peerId:e})>0}};var Xe=W("libp2p:connection-manager:auto-dial"),Go={minConnections:50,maxQueueLength:100,autoDialConcurrency:25,autoDialPriority:0,autoDialInterval:5e3},Va=class{connectionManager;peerStore;queue;minConnections;autoDialPriority;autoDialIntervalMs;autoDialMaxQueueLength;autoDialInterval;started;running;constructor(e,r){this.connectionManager=e.connectionManager,this.peerStore=e.peerStore,this.minConnections=r.minConnections??Go.minConnections,this.autoDialPriority=r.autoDialPriority??Go.autoDialPriority,this.autoDialIntervalMs=r.autoDialInterval??Go.autoDialInterval,this.autoDialMaxQueueLength=r.maxQueueLength??Go.maxQueueLength,this.started=!1,this.running=!1,this.queue=new Ka({concurrency:r.autoDialConcurrency??Go.autoDialConcurrency}),this.queue.addListener("error",n=>{Xe.error("error during auto-dial",n)}),e.events.addEventListener("connection:close",()=>{this.autoDial().catch(n=>{Xe.error(n)})})}isStarted(){return this.started}start(){this.autoDialInterval=setTimeout(()=>{this.autoDial().catch(e=>{Xe.error("error while autodialing",e)})},this.autoDialIntervalMs),this.started=!0}afterStart(){this.autoDial().catch(e=>{Xe.error("error while autodialing",e)})}stop(){this.queue.clear(),clearTimeout(this.autoDialInterval),this.started=!1,this.running=!1}async autoDial(){if(!this.started)return;let e=this.connectionManager.getConnectionsMap(),r=e.size;if(r>=this.minConnections){Xe.trace("have enough connections %d/%d",r,this.minConnections);return}if(this.queue.size>this.autoDialMaxQueueLength){Xe("not enough connections %d/%d but auto dial queue is full",r,this.minConnections);return}if(this.running){Xe("not enough connections %d/%d - but skipping autodial as it is already running",r,this.minConnections);return}this.running=!0,Xe("not enough connections %d/%d - will dial peers to increase the number of connections",r,this.minConnections);let n=new kt(this.connectionManager.getDialQueue().map(c=>c.peerId).filter(Boolean)),i=await this.peerStore.all({filters:[c=>c.addresses.length===0?(Xe.trace("not autodialing %p because they have no addresses"),!1):e.has(c.id)?(Xe.trace("not autodialing %p because they are already connected"),!1):n.has(c.id)?(Xe.trace("not autodialing %p because they are already being dialed"),!1):this.queue.hasJob(c.id)?(Xe.trace("not autodialing %p because they are already being autodialed"),!1):!0]}),o=i.sort(()=>Math.random()>.5?1:-1),s=new Nt;for(let c of o)s.has(c.id)||s.set(c.id,[...c.tags.values()].reduce((u,l)=>u+l.value,0));let a=o.sort((c,u)=>{let l=s.get(c.id)??0,f=s.get(u.id)??0;return l>f?-1:l<f?1:0});Xe("selected %d/%d peers to dial",a.length,i.length);for(let c of a)this.queue.add(async()=>{let u=this.connectionManager.getConnectionsMap().size;if(u>=this.minConnections){Xe("got enough connections now %d/%d",u,this.minConnections),this.queue.clear();return}Xe("connecting to a peerStore stored peer %p",c.id),await this.connectionManager.openConnection(c.id,{priority:this.autoDialPriority})},{peerId:c.id}).catch(u=>{Xe.error("could not connect to peerStore stored peer",u)});this.running=!1,this.started&&(this.autoDialInterval=setTimeout(()=>{this.autoDial().catch(c=>{Xe.error("error while autodialing",c)})},this.autoDialIntervalMs))}};var Ui=W("libp2p:connection-manager:connection-pruner"),q1={maxConnections:300,allow:[]},qa=class{maxConnections;connectionManager;peerStore;allow;events;constructor(e,r={}){this.maxConnections=r.maxConnections??q1.maxConnections,this.allow=r.allow??q1.allow,this.connectionManager=e.connectionManager,this.peerStore=e.peerStore,this.events=e.events,e.events.addEventListener("connection:open",()=>{this.maybePruneConnections().catch(n=>{Ui.error(n)})})}async maybePruneConnections(){let e=this.connectionManager.getConnections(),r=e.length,n=Math.max(r-this.maxConnections,0);if(Ui("checking max connections limit %d/%d",r,this.maxConnections),r<=this.maxConnections)return;Ui("max connections limit exceeded %d/%d, pruning %d connection(s)",r,this.maxConnections,n);let i=new Nt;for(let a of e){let c=a.remotePeer;if(!i.has(c)){i.set(c,0);try{let u=await this.peerStore.get(c);i.set(c,[...u.tags.values()].reduce((l,f)=>l+f.value,0))}catch(u){u.code!=="ERR_NOT_FOUND"&&Ui.error("error loading peer tags",u)}}}let o=e.sort((a,c)=>{let u=i.get(a.remotePeer)??0,l=i.get(c.remotePeer)??0;if(u>l)return 1;if(u<l)return-1;let f=a.stat.timeline.open,d=c.stat.timeline.open;return f<d?1:f>d?-1:0}),s=[];for(let a of o)if(Ui("too many connections open - closing a connection to %p",a.remotePeer),this.allow.some(u=>a.remoteAddr.toString().startsWith(u.toString()))||s.push(a),s.length===n)break;await Promise.all(s.map(async a=>{try{await a.close()}catch(c){Ui.error(c)}})),this.events.safeDispatchEvent("connection:prune",{detail:s})}};var ih=z($i(),1);function Fi(t){let e=new globalThis.AbortController;function r(){e.abort();for(let o of t)o?.removeEventListener!=null&&o.removeEventListener("abort",r)}for(let o of t){if(o?.aborted===!0){r();break}o?.addEventListener!=null&&o.addEventListener("abort",r)}function n(){for(let o of t)o?.removeEventListener!=null&&o.removeEventListener("abort",r)}let i=e.signal;return i.clear=n,i}function Yo(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}var rh=z($i(),1);var z1=W("libp2p:connection-manager:utils");async function nh(t,e){if(!t.protoNames().includes("dnsaddr"))return[t];let n=await bR(t,e),s=(await Promise.all(n.map(async a=>nh(a,e)))).flat().reduce((a,c)=>(a.find(u=>u.equals(c))==null&&a.push(c),a),[]);return z1("resolved %s to",t,s.map(a=>a.toString())),s}async function bR(t,e){try{return t=Ue(t.toString()),await t.resolve(e)}catch(r){return z1.error(`multiaddr ${t.toString()} could not be resolved`,r),[]}}function $1(...t){let e=[];for(let n of t)if(n!=null){try{(0,rh.setMaxListeners)?.(1/0,n)}catch{}e.push(n)}let r=Fi(e);try{(0,rh.setMaxListeners)?.(1/0,r)}catch{}return r}var je=W("libp2p:connection-manager:dial-queue"),Wo={addressSorter:Pi,maxParallelDials:100,maxPeerAddrsToDial:25,maxParallelDialsPerPeer:10,dialTimeout:3e4,resolvers:{dnsaddr:Di}},za=class{pendingDials;queue;peerId;peerStore;connectionGater;transportManager;addressSorter;maxPeerAddrsToDial;maxParallelDialsPerPeer;dialTimeout;inProgressDialCount;pendingDialCount;shutDownController;constructor(e,r={}){this.addressSorter=r.addressSorter??Wo.addressSorter,this.maxPeerAddrsToDial=r.maxPeerAddrsToDial??Wo.maxPeerAddrsToDial,this.maxParallelDialsPerPeer=r.maxParallelDialsPerPeer??Wo.maxParallelDialsPerPeer,this.dialTimeout=r.dialTimeout??Wo.dialTimeout,this.peerId=e.peerId,this.peerStore=e.peerStore,this.connectionGater=e.connectionGater,this.transportManager=e.transportManager,this.shutDownController=new AbortController;try{(0,ih.setMaxListeners)?.(1/0,this.shutDownController.signal)}catch{}this.pendingDialCount=e.metrics?.registerMetric("libp2p_dialler_pending_dials"),this.inProgressDialCount=e.metrics?.registerMetric("libp2p_dialler_in_progress_dials"),this.pendingDials=[];for(let[n,i]of Object.entries(r.resolvers??{}))of.set(n,i);this.queue=new Ut({concurrency:r.maxParallelDials??Wo.maxParallelDials}),this.queue.on("add",()=>{this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)}),this.queue.on("active",()=>{this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)}),this.queue.on("completed",()=>{this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)}),this.queue.on("error",n=>{je.error("error in dial queue",n),this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)}),this.queue.on("empty",()=>{this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)}),this.queue.on("idle",()=>{this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)})}stop(){this.shutDownController.abort()}async dial(e,r={}){let{peerId:n,multiaddrs:i}=Fa(e),o=i.map(l=>({multiaddr:l,isCertified:!1})),s=this.createDialAbortControllers(r.signal),a;try{a=await this.calculateMultiaddrs(n,o,{...r,signal:s})}catch(l){throw s.clear(),l}let c=this.pendingDials.find(l=>!!(l.peerId!=null&&n!=null&&l.peerId.equals(n)||a.map(({multiaddr:f})=>f.toString()).join()===l.multiaddrs.map(f=>f.toString()).join()));if(c!=null)return je("joining existing dial target for %p",n),s.clear(),c.promise;je("creating dial target for",a.map(({multiaddr:l})=>l.toString()));let u={id:ER(),status:"queued",peerId:n,multiaddrs:a.map(({multiaddr:l})=>l)};return u.promise=this.performDial(u,{...r,signal:s}).finally(()=>{this.pendingDials=this.pendingDials.filter(l=>l.id!==u.id),s.clear()}).catch(l=>{throw je.error("dial failed to %s",u.multiaddrs.map(f=>f.toString()).join(", "),l),s.aborted?new v(l.message,N.ERR_TIMEOUT):l}),this.pendingDials.push(u),u.promise}createDialAbortControllers(e){let r=Fi([AbortSignal.timeout(this.dialTimeout),this.shutDownController.signal,e]);try{(0,ih.setMaxListeners)?.(1/0,r)}catch{}return r}async calculateMultiaddrs(e,r=[],n={}){if(e!=null){if(this.peerId.equals(e))throw new v("Tried to dial self",N.ERR_DIALED_SELF);if(await this.connectionGater.denyDialPeer?.(e)===!0)throw new v("The dial request is blocked by gater.allowDialPeer",N.ERR_PEER_DIAL_INTERCEPTED);if(r.length===0){je("loading multiaddrs for %p",e);try{let l=await this.peerStore.get(e);r.push(...l.addresses),je("loaded multiaddrs for %p",e,r.map(({multiaddr:f})=>f.toString()))}catch(l){if(l.code!==N.ERR_NOT_FOUND)throw l}}}let i=(await Promise.all(r.map(async l=>{let f=await nh(l.multiaddr,n);return f.length===1&&f[0].equals(l.multiaddr)?l:f.map(d=>({multiaddr:d,isCertified:!1}))}))).flat(),o=i.filter(l=>!!this.transportManager.transportForMultiaddr(l.multiaddr)),s=new Map;for(let l of o){let f=l.multiaddr.toString(),d=s.get(f);if(d!=null){d.isCertified=d.isCertified||l.isCertified||!1;continue}s.set(f,l)}let a=[...s.values()];if((a.length===0||a.length>this.maxPeerAddrsToDial)&&(je("addresses for %p before filtering",e??"unknown peer",i.map(({multiaddr:l})=>l.toString())),je("addresses for %p after filtering",e??"unknown peer",a.map(({multiaddr:l})=>l.toString()))),a.length===0)throw new v("The dial request has no valid addresses",N.ERR_NO_VALID_ADDRESSES);if(a.length>this.maxPeerAddrsToDial)throw new v("dial with more addresses than allowed",N.ERR_TOO_MANY_ADDRESSES);if(e!=null){let l=`/p2p/${e.toString()}`;a=a.map(f=>{let d=f.multiaddr.getPeerId();return f.multiaddr.protos().pop()?.path===!0?f:d!==e.toString()?{multiaddr:f.multiaddr.encapsulate(l),isCertified:f.isCertified}:f})}let c=[];for(let l of a)this.connectionGater.denyDialMultiaddr!=null&&await this.connectionGater.denyDialMultiaddr(l.multiaddr)||c.push(l);let u=c.sort(this.addressSorter);if(u.length===0)throw new v("The connection gater denied all addresses in the dial request",N.ERR_NO_VALID_ADDRESSES);return u}async performDial(e,r={}){let n=e.multiaddrs.map(()=>new AbortController);try{let i=new Ut({concurrency:this.maxParallelDialsPerPeer});i.on("error",s=>{je.error("error dialling",s)});let o=await Promise.any(e.multiaddrs.map(async(s,a)=>{let c=n[a];if(c==null)throw new v("dialAction did not come with an AbortController",N.ERR_INVALID_PARAMETERS);let u=$1(c.signal,r.signal);u.addEventListener("abort",()=>{je("dial to %a aborted",s)});let l=Yo();return await i.add(async()=>{if(u.aborted){je("dial to %a was aborted before reaching the head of the peer dial queue",s),l.reject(new Cr);return}await this.queue.add(async()=>{try{if(u.aborted){je("dial to %a was aborted before reaching the head of the dial queue",s),l.reject(new Cr);return}e.status="active";let f=await this.transportManager.dial(s,{...r,signal:u});if(c.signal.aborted){je("multiple dials succeeded, closing superfluous connection"),f.close().catch(d=>{je.error("error closing superfluous connection",d)}),l.reject(new Cr);return}n[a]=void 0,n.forEach(d=>{d!==void 0&&d.abort()}),je("dial to %a succeeded",s),l.resolve(f)}catch(f){je.error("error during dial of %a",s,f),l.reject(f)}},{...r,signal:u}).catch(f=>{l.reject(f)})},{signal:u}).catch(f=>{l.reject(f)}).finally(()=>{u.clear()}),l.promise}));if(o==null)throw new v("successful dial led to empty object returned from peer dial queue",N.ERR_TRANSPORT_DIAL_FAILED);return e.status="success",o}catch(i){throw e.status="error",e.multiaddrs.length===1&&i.name==="AggregateError"?i.errors[0]:i}}};function ER(){return`${parseInt(String(Math.random()*1e9),10).toString()}${Date.now()}`}var xt=W("libp2p:connection-manager"),AR=50,Bn={minConnections:50,maxConnections:300,inboundConnectionThreshold:5,maxIncomingPendingConnections:10,autoDialConcurrency:25,autoDialPriority:0,autoDialMaxQueueLength:100},$a=class{started;connections;allow;deny;maxIncomingPendingConnections;incomingPendingConnections;maxConnections;dialQueue;autoDial;connectionPruner;inboundConnectionRateLimiter;peerStore;metrics;events;constructor(e,r={}){this.maxConnections=r.maxConnections??Bn.maxConnections;let n=r.minConnections??Bn.minConnections;if(this.maxConnections<n)throw new v("Connection Manager maxConnections must be greater than minConnections",N.ERR_INVALID_PARAMETERS);this.connections=new Nt,this.started=!1,this.peerStore=e.peerStore,this.metrics=e.metrics,this.events=e.events,this.onConnect=this.onConnect.bind(this),this.onDisconnect=this.onDisconnect.bind(this),this.events.addEventListener("connection:open",this.onConnect),this.events.addEventListener("connection:close",this.onDisconnect),this.allow=(r.allow??[]).map(i=>Ue(i)),this.deny=(r.deny??[]).map(i=>Ue(i)),this.incomingPendingConnections=0,this.maxIncomingPendingConnections=r.maxIncomingPendingConnections??Bn.maxIncomingPendingConnections,this.inboundConnectionRateLimiter=new H1.RateLimiterMemory({points:r.inboundConnectionThreshold??Bn.inboundConnectionThreshold,duration:1}),this.autoDial=new Va({connectionManager:this,peerStore:e.peerStore,events:e.events},{minConnections:n,autoDialConcurrency:r.autoDialConcurrency??Bn.autoDialConcurrency,autoDialPriority:r.autoDialPriority??Bn.autoDialPriority,maxQueueLength:r.autoDialMaxQueueLength??Bn.autoDialMaxQueueLength}),this.connectionPruner=new qa({connectionManager:this,peerStore:e.peerStore,events:e.events},{maxConnections:this.maxConnections,allow:this.allow}),this.dialQueue=new za({peerId:e.peerId,metrics:e.metrics,peerStore:e.peerStore,transportManager:e.transportManager,connectionGater:e.connectionGater},{addressSorter:r.addressSorter??Pi,maxParallelDials:r.maxParallelDials??100,maxPeerAddrsToDial:r.maxPeerAddrsToDial??25,dialTimeout:r.dialTimeout??3e4,resolvers:r.resolvers??{dnsaddr:Di}})}isStarted(){return this.started}async start(){this.metrics?.registerMetricGroup("libp2p_connection_manager_connections",{calculate:()=>{let e={inbound:0,outbound:0};for(let r of this.connections.values())for(let n of r)n.stat.direction==="inbound"?e.inbound++:e.outbound++;return e}}),this.metrics?.registerMetricGroup("libp2p_protocol_streams_total",{label:"protocol",calculate:()=>{let e={};for(let r of this.connections.values())for(let n of r)for(let i of n.streams){let o=`${i.stat.direction} ${i.stat.protocol??"unnegotiated"}`;e[o]=(e[o]??0)+1}return e}}),this.metrics?.registerMetricGroup("libp2p_connection_manager_protocol_streams_per_connection_90th_percentile",{label:"protocol",calculate:()=>{let e={};for(let n of this.connections.values())for(let i of n){let o={};for(let s of i.streams){let a=`${s.stat.direction} ${s.stat.protocol??"unnegotiated"}`;o[a]=(o[a]??0)+1}for(let[s,a]of Object.entries(o))e[s]=e[s]??[],e[s].push(a)}let r={};for(let[n,i]of Object.entries(e)){i=i.sort((s,a)=>s-a);let o=Math.floor(i.length*.9);r[n]=i[o]}return r}}),this.autoDial.start(),this.started=!0,xt("started")}async afterStart(){Promise.resolve().then(async()=>{let e=await this.peerStore.all({filters:[r=>r.tags.has(Gg)]});await Promise.all(e.map(async r=>{await this.openConnection(r.id).catch(n=>{xt.error(n)})}))}).catch(e=>{xt.error(e)}),this.autoDial.afterStart()}async stop(){this.dialQueue.stop(),this.autoDial.stop();let e=[];for(let r of this.connections.values())for(let n of r)e.push((async()=>{try{await n.close()}catch(i){xt.error(i)}})());xt("closing %d connections",e.length),await Promise.all(e),this.connections.clear(),xt("stopped")}onConnect(e){this._onConnect(e).catch(r=>{xt.error(r)})}async _onConnect(e){let{detail:r}=e;if(!this.started){await r.close();return}let n=r.remotePeer,i=this.connections.get(n),o=!1;i!=null?i.push(r):(o=!0,this.connections.set(n,[r])),n.publicKey!=null&&n.type==="RSA"&&await this.peerStore.patch(n,{publicKey:n.publicKey}),o&&this.events.safeDispatchEvent("peer:connect",{detail:r.remotePeer})}onDisconnect(e){let{detail:r}=e;if(!this.started)return;let n=r.remotePeer,i=this.connections.get(n);i!=null&&i.length>1?(i=i.filter(o=>o.id!==r.id),this.connections.set(n,i)):i!=null&&(this.connections.delete(n),this.events.safeDispatchEvent("peer:disconnect",{detail:r.remotePeer}))}getConnections(e){if(e!=null)return this.connections.get(e)??[];let r=[];for(let n of this.connections.values())r=r.concat(n);return r}getConnectionsMap(){return this.connections}async openConnection(e,r={}){if(!this.isStarted())throw new v("Not started",N.ERR_NODE_NOT_STARTED);let{peerId:n}=Fa(e);if(n!=null){xt("dial %p",n);let a=this.getConnections(n);if(a.length>0)return xt("had an existing connection to %p",n),a[0]}let i=await this.dialQueue.dial(e,{...r,priority:r.priority??AR}),o=this.connections.get(i.remotePeer);o==null&&(o=[],this.connections.set(i.remotePeer,o));let s=!1;for(let a of o)a.id===i.id&&(s=!0);return s||o.push(i),i}async closeConnections(e){let r=this.connections.get(e)??[];await Promise.all(r.map(async n=>{await n.close()}))}async acceptIncomingConnection(e){if(this.deny.some(i=>e.remoteAddr.toString().startsWith(i.toString())))return xt("connection from %a refused - connection remote address was in deny list",e.remoteAddr),!1;if(this.allow.some(i=>e.remoteAddr.toString().startsWith(i.toString())))return this.incomingPendingConnections++,!0;if(this.incomingPendingConnections===this.maxIncomingPendingConnections)return xt("connection from %a refused - incomingPendingConnections exceeded by host",e.remoteAddr),!1;if(e.remoteAddr.isThinWaistAddress()){let i=e.remoteAddr.nodeAddress().address;try{await this.inboundConnectionRateLimiter.consume(i,1)}catch{return xt("connection from %a refused - inboundConnectionThreshold exceeded by host %s",e.remoteAddr,i),!1}}return this.getConnections().length<this.maxConnections?(this.incomingPendingConnections++,!0):(xt("connection from %a refused - maxConnections exceeded",e.remoteAddr),!1)}afterUpgradeInbound(){this.incomingPendingConnections--}getDialQueue(){return this.dialQueue.pendingDials}};var Ha=class{constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},Ki=class{constructor(e={}){this.hwm=e.splitLimit??16,this.head=new Ha(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let r=this.head;this.head=r.next=new Ha(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let r=this.tail.next;this.tail.next=null,this.tail=r,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};function Ln(t={}){return IR(r=>{let n=r.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},t)}function IR(t,e){e=e??{};let r=e.onEnd,n=new Ki,i,o,s,a=async()=>n.isEmpty()?s?{done:!0}:await new Promise((m,y)=>{o=g=>{o=null,n.push(g);try{m(t(n))}catch(x){y(x)}return i}}):t(n),c=m=>o!=null?o(m):(n.push(m),i),u=m=>(n=new Ki,o!=null?o({error:m}):(n.push({error:m}),i)),l=m=>{if(s)return i;if(e?.objectMode!==!0&&m?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return c({done:!1,value:m})},f=m=>s?i:(s=!0,m!=null?u(m):c({done:!0})),d=()=>(n=new Ki,f(),{done:!0}),p=m=>(f(m),{done:!0});if(i={[Symbol.asyncIterator](){return this},next:a,return:d,throw:p,push:l,end:f,get readableLength(){return n.size}},r==null)return i;let h=i;return i={[Symbol.asyncIterator](){return this},next(){return h.next()},throw(m){return h.throw(m),r!=null&&(r(m),r=void 0),{done:!0}},return(){return h.return(),r!=null&&(r(),r=void 0),{done:!0}},push:l,end(m){return h.end(m),r!=null&&(r(m),r=void 0),i},get readableLength(){return h.readableLength}},i}function RR(t){return t[Symbol.asyncIterator]!=null}function CR(...t){let e=[];for(let r of t)RR(r)||e.push(r);return e.length===t.length?function*(){for(let r of e)yield*r}():async function*(){let r=Ln({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(t.map(async n=>{for await(let i of n)r.push(i)})),r.end()}catch(n){r.end(n)}}),yield*r}()}var jr=CR;function Pn(t,...e){if(t==null)throw new Error("Empty pipeline");if(ch(t)){let n=t;t=()=>n.source}else if(Y1(t)||G1(t)){let n=t;t=()=>n}let r=[t,...e];if(r.length>1&&ch(r[r.length-1])&&(r[r.length-1]=r[r.length-1].sink),r.length>2)for(let n=1;n<r.length-1;n++)ch(r[n])&&(r[n]=BR(r[n]));return TR(...r)}var TR=(...t)=>{let e;for(;t.length>0;)e=t.shift()(e);return e},G1=t=>t?.[Symbol.asyncIterator]!=null,Y1=t=>t?.[Symbol.iterator]!=null,ch=t=>t==null?!1:t.sink!=null&&t.source!=null,BR=t=>e=>{let r=t.sink(e);if(r?.then!=null){let n=Ln({objectMode:!0});r.then(()=>{n.end()},s=>{n.end(s)});let i,o=t.source;if(G1(o))i=async function*(){yield*o,n.end()};else if(Y1(o))i=function*(){yield*o,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return jr(n,i())}return t.source};function LR(t){return t[Symbol.asyncIterator]!=null}function PR(t,e){if(LR(t))return async function*(){for await(let a of t)yield e(a)}();let r=Ba(t),{value:n,done:i}=r.next();if(i===!0)return function*(){}();let o=e(n);if(typeof o.then=="function")return async function*(){yield await o;for await(let a of r)yield e(a)}();let s=e;return function*(){yield o;for(let a of r)yield s(a)}()}var W1=PR;async function*Qo(t,e){yield*W1(t,async r=>(await e.merge(r.id,{multiaddrs:r.multiaddrs}),r))}function Ga(t){let e=new Set;return Ft(t,r=>e.has(r.id.toString())?!1:(e.add(r.id.toString()),!0))}async function*Ya(t,e=1){let r=0;for await(let n of t)r++,yield n;if(r<e)throw new v(`more peers required, seen: ${r} min: ${e}`,"NOT_FOUND")}var Wa=class{routers;started;components;constructor(e,r){this.routers=r.routers??[],this.started=!1,this.components=e}isStarted(){return this.started}async start(){this.started=!0}async stop(){this.started=!1}async*findProviders(e,r={}){if(this.routers.length===0)throw new v("No content routers available",N.ERR_NO_ROUTERS_AVAILABLE);yield*Pn(jr(...this.routers.map(n=>n.findProviders(e,r))),n=>Qo(n,this.components.peerStore),n=>Ga(n),n=>Ya(n))}async provide(e,r={}){if(this.routers.length===0)throw new v("No content routers available",N.ERR_NO_ROUTERS_AVAILABLE);await Promise.all(this.routers.map(async n=>{await n.provide(e,r)}))}async put(e,r,n){if(!this.isStarted())throw new v(or.NOT_STARTED_YET,N.DHT_NOT_STARTED);await Promise.all(this.routers.map(async i=>{await i.put(e,r,n)}))}async get(e,r){if(!this.isStarted())throw new v(or.NOT_STARTED_YET,N.DHT_NOT_STARTED);return Promise.any(this.routers.map(async n=>n.get(e,r)))}};function DR(t){return t[Symbol.asyncIterator]!=null}function NR(t){if(DR(t))return(async()=>{for await(let e of t)return e})();for(let e of t)return e}var Qa=NR;var kR=W("libp2p:peer-routing"),Xa=class{components;routers;constructor(e,r){this.components=e,this.routers=r.routers??[]}async findPeer(e,r){if(this.routers.length===0)throw new v("No peer routers available",N.ERR_NO_ROUTERS_AVAILABLE);if(e.toString()===this.components.peerId.toString())throw new v("Should not try to find self",N.ERR_FIND_SELF);let n=await Pn(jr(...this.routers.map(i=>async function*(){try{yield await i.findPeer(e,r)}catch(o){kR.error(o)}}())),i=>Ft(i,Boolean),i=>Qo(i,this.components.peerStore),async i=>Qa(i));if(n!=null)return n;throw new v(or.NOT_FOUND,N.ERR_NOT_FOUND)}async*getClosestPeers(e,r){if(this.routers.length===0)throw new v("No peer routers available",N.ERR_NO_ROUTERS_AVAILABLE);yield*Pn(jr(...this.routers.map(n=>n.getClosestPeers(e,r))),n=>Qo(n,this.components.peerStore),n=>Ga(n),n=>Ya(n))}};var uh=W("libp2p:registrar"),lh=32,fh=64,Za=class{topologies;handlers;components;constructor(e){this.topologies=new Map,this.handlers=new Map,this.components=e,this._onDisconnect=this._onDisconnect.bind(this),this._onPeerUpdate=this._onPeerUpdate.bind(this),this._onConnect=this._onConnect.bind(this),this.components.events.addEventListener("peer:disconnect",this._onDisconnect),this.components.events.addEventListener("peer:connect",this._onConnect),this.components.events.addEventListener("peer:update",this._onPeerUpdate)}getProtocols(){return Array.from(new Set([...this.handlers.keys()])).sort()}getHandler(e){let r=this.handlers.get(e);if(r==null)throw new v(`No handler registered for protocol ${e}`,N.ERR_NO_HANDLER_FOR_PROTOCOL);return r}getTopologies(e){let r=this.topologies.get(e);return r==null?[]:[...r.values()]}async handle(e,r,n){if(this.handlers.has(e))throw new v(`Handler already registered for protocol ${e}`,N.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED);let i=qr.bind({ignoreUndefined:!0})({maxInboundStreams:lh,maxOutboundStreams:fh},n);this.handlers.set(e,{handler:r,options:i}),await this.components.peerStore.merge(this.components.peerId,{protocols:[e]})}async unhandle(e){let r=Array.isArray(e)?e:[e];r.forEach(n=>{this.handlers.delete(n)}),await this.components.peerStore.patch(this.components.peerId,{protocols:r})}async register(e,r){if(r==null)throw new v("invalid topology",N.ERR_INVALID_PARAMETERS);let n=`${(Math.random()*1e9).toString(36)}${Date.now()}`,i=this.topologies.get(e);return i==null&&(i=new Map,this.topologies.set(e,i)),i.set(n,r),n}unregister(e){for(let[r,n]of this.topologies.entries())n.has(e)&&(n.delete(e),n.size===0&&this.topologies.delete(r))}_onDisconnect(e){let r=e.detail;this.components.peerStore.get(r).then(n=>{for(let i of n.protocols){let o=this.topologies.get(i);if(o!=null)for(let s of o.values())s.onDisconnect?.(r)}}).catch(n=>{n.code!==N.ERR_NOT_FOUND&&uh.error("could not inform topologies of disconnecting peer %p",r,n)})}_onConnect(e){let r=e.detail;this.components.peerStore.get(r).then(n=>{let i=this.components.connectionManager.getConnections(n.id)[0];if(i==null){uh("peer %p connected but the connection manager did not have a connection",n);return}for(let o of n.protocols){let s=this.topologies.get(o);if(s!=null)for(let a of s.values())a.onConnect?.(r,i)}}).catch(n=>{n.code!==N.ERR_NOT_FOUND&&uh.error("could not inform topologies of connecting peer %p",r,n)})}_onPeerUpdate(e){let{peer:r,previous:n}=e.detail,i=(n?.protocols??[]).filter(s=>!r.protocols.includes(s)),o=r.protocols.filter(s=>!(n?.protocols??[]).includes(s));for(let s of i){let a=this.topologies.get(s);if(a!=null)for(let c of a.values())c.onDisconnect?.(r.id)}for(let s of o){let a=this.topologies.get(s);if(a!=null)for(let c of a.values()){let u=this.components.connectionManager.getConnections(r.id)[0];u!=null&&c.onConnect?.(r.id,u)}}}};var hh=class extends Map{metric;constructor(e){super();let{name:r,metrics:n}=e;this.metric=n.registerMetric(r),this.updateComponentMetric()}set(e,r){return super.set(e,r),this.updateComponentMetric(),this}delete(e){let r=super.delete(e);return this.updateComponentMetric(),r}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function Q1(t){let{name:e,metrics:r}=t,n;return r!=null?n=new hh({name:e,metrics:r}):n=new Map,n}var Dn=W("libp2p:transports"),ja=class{components;transports;listeners;faultTolerance;started;constructor(e,r={}){this.components=e,this.started=!1,this.transports=new Map,this.listeners=Q1({name:"libp2p_transport_manager_listeners",metrics:this.components.metrics}),this.faultTolerance=r.faultTolerance??Xr.FATAL_ALL}add(e){let r=e[Symbol.toStringTag];if(r==null)throw new v("Transport must have a valid tag",N.ERR_INVALID_KEY);if(this.transports.has(r))throw new v(`There is already a transport with the tag ${r}`,N.ERR_DUPLICATE_TRANSPORT);Dn("adding transport %s",r),this.transports.set(r,e),this.listeners.has(r)||this.listeners.set(r,[])}isStarted(){return this.started}start(){this.started=!0}async afterStart(){let e=this.components.addressManager.getListenAddrs();await this.listen(e)}async stop(){let e=[];for(let[r,n]of this.listeners)for(Dn("closing listeners for %s",r);n.length>0;){let i=n.pop();i!=null&&e.push(i.close())}await Promise.all(e),Dn("all listeners closed");for(let r of this.listeners.keys())this.listeners.set(r,[]);this.started=!1}async dial(e,r){let n=this.transportForMultiaddr(e);if(n==null)throw new v(`No transport available for address ${String(e)}`,N.ERR_TRANSPORT_UNAVAILABLE);try{return await n.dial(e,{...r,upgrader:this.components.upgrader})}catch(i){throw i.code==null&&(i.code=N.ERR_TRANSPORT_DIAL_FAILED),i}}getAddrs(){let e=[];for(let r of this.listeners.values())for(let n of r)e=[...e,...n.getAddrs()];return e}getTransports(){return Array.of(...this.transports.values())}getListeners(){return Array.of(...this.listeners.values()).flat()}transportForMultiaddr(e){for(let r of this.transports.values())if(r.filter([e]).length>0)return r}async listen(e){if(e==null||e.length===0){Dn("no addresses were provided for listening, this node is dial only");return}let r=[];for(let[n,i]of this.transports.entries()){let o=i.filter(e),s=[];for(let u of o){Dn("creating listener for %s on %a",n,u);let l=i.createListener({upgrader:this.components.upgrader}),f=this.listeners.get(n)??[];f==null&&(f=[],this.listeners.set(n,f)),f.push(l),l.addEventListener("listening",()=>{this.components.events.safeDispatchEvent("transport:listening",{detail:l})}),l.addEventListener("close",()=>{let d=f.findIndex(p=>p===l);f.splice(d,1),this.components.events.safeDispatchEvent("transport:close",{detail:l})}),s.push(l.listen(u))}if(s.length===0){r.push(n);continue}if((await Promise.allSettled(s)).find(u=>u.status==="fulfilled")==null&&this.faultTolerance!==Xr.NO_FATAL)throw new v(`Transport (${n}) could not listen on any available address`,N.ERR_NO_VALID_ADDRESSES)}if(r.length===this.transports.size){let n=`no valid addresses were provided for transports [${r.join(", ")}]`;if(this.faultTolerance===Xr.FATAL_ALL)throw new v(n,N.ERR_NO_VALID_ADDRESSES);Dn(`libp2p in dial mode only: ${n}`)}}async remove(e){Dn("removing %s",e);for(let r of this.listeners.get(e)??[])await r.close();this.transports.delete(e),this.listeners.delete(e)}async removeAll(){let e=[];for(let r of this.transports.keys())e.push(this.remove(r));await Promise.all(e)}};var gh=z($i(),1);var _r="/multistream/1.0.0";function dh(t){let e=async function*(){let r=yield,n=new Te;for await(let i of t){if(r==null){n.append(i),r=yield n,n=new Te;continue}for(n.append(i);n.length>=r;){let o=n.sublist(0,r);if(n.consume(r),r=yield o,r==null){n.length>0&&(r=yield n,n=new Te);break}}}if(r!=null)throw Object.assign(new Error(`stream ended before ${r} bytes became available`),{code:"ERR_UNDER_READ",buffer:n})}();return e.next(),e}function Ja(t){let e=Ln(),r=dh(t.source),n=Yo(),i,o=t.sink(async function*(){yield*e,yield*await n.promise}());return o.catch(a=>{i=a}),{reader:r,writer:e,stream:{sink:async a=>{if(i!=null){await Promise.reject(i);return}n.resolve(a),await o},source:r},rest:()=>e.end(),write:e.push,read:async()=>{let a=await r.next();if(a.value!=null)return a.value}}}var Xo=class extends Error{constructor(e,r){super(e??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function X1(t){if(t!=null){if(typeof t[Symbol.iterator]=="function")return t[Symbol.iterator]();if(typeof t[Symbol.asyncIterator]=="function")return t[Symbol.asyncIterator]();if(typeof t.next=="function")return t}throw new Error("argument is not an iterator or iterable")}function ec(t,e,r){let n=r??{},i=X1(t);async function*o(){let s,a=()=>{s?.()};for(e.addEventListener("abort",a);;){let c;try{if(e.aborted){let{abortMessage:l,abortCode:f}=n;throw new Xo(l,f)}let u=new Promise((l,f)=>{s=()=>{let{abortMessage:d,abortCode:p}=n;f(new Xo(d,p))}});c=await Promise.race([u,i.next()]),s=null}catch(u){e.removeEventListener("abort",a);let l=u.type==="aborted"&&e.aborted;if(l&&n.onAbort!=null&&n.onAbort(t),typeof i.return=="function")try{let f=i.return();f instanceof Promise&&f.catch(d=>{n.onReturnError!=null&&n.onReturnError(d)})}catch(f){n.onReturnError!=null&&n.onReturnError(f)}if(l&&n.returnOnAbort===!0)return;throw u}if(c.done===!0)break;yield c.value}e.removeEventListener("abort",a)}return o()}function OR(t,e,r){return n=>t(ec(n,e,r))}function Z1(t,e,r){return{sink:OR(t.sink,e,{...r,onAbort:void 0}),source:ec(t.source,e,r)}}function tc(t){return t[Symbol.asyncIterator]!=null}var rc=t=>{let e=Ot.encodingLength(t),r=Ct(e);return Ot.encode(t,r),rc.bytes=e,r};rc.bytes=0;function nc(t,e){e=e??{};let r=e.lengthEncoder??rc;function*n(i){let o=r(i.byteLength);o instanceof Uint8Array?yield o:yield*o,i instanceof Uint8Array?yield i:yield*i}return tc(t)?async function*(){for await(let i of t)yield*n(i)}():function*(){for(let i of t)yield*n(i)}()}nc.single=(t,e)=>{e=e??{};let r=e.lengthEncoder??rc;return new Te(r(t.byteLength),t)};var Vi=z(Cf(),1);var MR=8,UR=1024*1024*4,Nn;(function(t){t[t.LENGTH=0]="LENGTH",t[t.DATA=1]="DATA"})(Nn||(Nn={}));var ph=t=>{let e=Ot.decode(t);return ph.bytes=Ot.encodingLength(e),e};ph.bytes=0;function Zo(t,e){let r=new Te,n=Nn.LENGTH,i=-1,o=e?.lengthDecoder??ph,s=e?.maxLengthLength??MR,a=e?.maxDataLength??UR;function*c(){for(;r.byteLength>0;){if(n===Nn.LENGTH)try{if(i=o(r),i<0)throw(0,Vi.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(i>a)throw(0,Vi.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let u=o.bytes;r.consume(u),e?.onLength!=null&&e.onLength(i),n=Nn.DATA}catch(u){if(u instanceof RangeError){if(r.byteLength>s)throw(0,Vi.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw u}if(n===Nn.DATA){if(r.byteLength<i)break;let u=r.sublist(0,i);r.consume(i),e?.onData!=null&&e.onData(u),yield u,n=Nn.LENGTH}}}return tc(t)?async function*(){for await(let u of t)r.append(u),yield*c();if(r.byteLength>0)throw(0,Vi.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(let u of t)r.append(u),yield*c();if(r.byteLength>0)throw(0,Vi.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}Zo.fromReader=(t,e)=>{let r=1,n=async function*(){for(;;)try{let{done:o,value:s}=await t.next(r);if(o===!0)return;s!=null&&(yield s)}catch(o){if(o.code==="ERR_UNDER_READ")return{done:!0,value:null};throw o}finally{r=1}}();return Zo(n,{...e??{},onLength:o=>{r=o}})};var VR=W("libp2p:mss"),j1=V(`
|
|
49
49
|
`);function jo(t){let e=new Te(t,j1);return nc.single(e)}function kn(t,e,r={}){let n=jo(e);r.writeBytes===!0?t.push(n.subarray()):t.push(n)}function J1(t,e,r={}){let n=new Te;for(let i of e)n.append(jo(i));r.writeBytes===!0?t.push(n.subarray()):t.push(n)}async function qR(t,e){let r=1,n={[Symbol.asyncIterator]:()=>n,next:async()=>t.next(r)},i=n;e?.signal!=null&&(i=ec(n,e.signal));let o=a=>{r=a},s=await Pn(i,a=>Zo(a,{onLength:o,maxDataLength:1024}),async a=>Qa(a));if(s==null||s.length===0)throw new v("no buffer returned","ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");if(s.get(s.byteLength-1)!==j1[0])throw VR.error("Invalid mss message - missing newline - %s",s.subarray()),new v("missing newline","ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return s.sublist(0,-1)}async function qi(t,e){let r=await qR(t,e);return G(r.subarray())}var Jo=W("libp2p:mss:select");async function es(t,e,r={}){e=Array.isArray(e)?[...e]:[e];let{reader:n,writer:i,rest:o,stream:s}=Ja(t),a=e.shift();if(a==null)throw new Error("At least one protocol must be specified");Jo.trace('select: write ["%s", "%s"]',_r,a);let c=V(_r),u=V(a);J1(i,[c,u],r);let l=await qi(n,r);if(Jo.trace('select: read "%s"',l),l===_r&&(l=await qi(n,r),Jo.trace('select: read "%s"',l)),l===a)return o(),{stream:s,protocol:a};for(let f of e){Jo.trace('select: write "%s"',f),kn(i,V(f),r);let d=await qi(n,r);if(Jo.trace('select: read "%s" for "%s"',d,f),d===f)return o(),{stream:s,protocol:f}}throw o(),new v("protocol selection failed","ERR_UNSUPPORTED_PROTOCOL")}var ts=W("libp2p:mss:handle");async function rs(t,e,r){e=Array.isArray(e)?e:[e];let{writer:n,reader:i,rest:o,stream:s}=Ja(t);for(;;){let a=await qi(i,r);if(ts.trace('read "%s"',a),a===_r){ts.trace('respond with "%s" for "%s"',_r,a),kn(n,V(_r),r);continue}if(e.includes(a))return kn(n,V(a),r),ts.trace('respond with "%s" for "%s"',a,a),o(),{stream:s,protocol:a};if(a==="ls"){kn(n,new Te(...e.map(c=>jo(V(c)))),r),ts.trace('respond with "%s" for %s',e,a);continue}kn(n,V("na"),r),ts('respond with "na" for "%s"',a)}}var tx=Symbol.for("@libp2p/connection");var rx="OPEN",mh="CLOSING",ic="CLOSED";var $R=W("libp2p:connection"),yh=class{id;remoteAddr;remotePeer;stat;tags;_newStream;_close;_getStreams;_closing;constructor(e){let{remoteAddr:r,remotePeer:n,newStream:i,close:o,getStreams:s,stat:a}=e;this.id=`${parseInt(String(Math.random()*1e9)).toString(36)}${Date.now()}`,this.remoteAddr=r,this.remotePeer=n,this.stat={...a,status:rx},this._newStream=i,this._close=o,this._getStreams=s,this.tags=[],this._closing=!1}[Symbol.toStringTag]="Connection";[tx]=!0;get streams(){return this._getStreams()}async newStream(e,r){if(this.stat.status===mh)throw new v("the connection is being closed","ERR_CONNECTION_BEING_CLOSED");if(this.stat.status===ic)throw new v("the connection is closed","ERR_CONNECTION_CLOSED");Array.isArray(e)||(e=[e]);let n=await this._newStream(e,r);return n.stat.direction="outbound",n}addStream(e){e.stat.direction="inbound"}removeStream(e){}async close(){if(!(this.stat.status===ic||this._closing)){this.stat.status=mh;try{this.streams.forEach(e=>{e.close()})}catch(e){$R.error(e)}this._closing=!0,await this._close(),this._closing=!1,this.stat.timeline.close=Date.now(),this.stat.status=ic}}};function nx(t){return new yh(t)}var ve=W("libp2p:upgrader");function GR(t,e){try{let{options:r}=e.getHandler(t);return r.maxInboundStreams}catch(r){if(r.code!==N.ERR_NO_HANDLER_FOR_PROTOCOL)throw r}return lh}function YR(t,e,r={}){try{let{options:n}=e.getHandler(t);if(n.maxOutboundStreams!=null)return n.maxOutboundStreams}catch(n){if(n.code!==N.ERR_NO_HANDLER_FOR_PROTOCOL)throw n}return r.maxOutboundStreams??fh}function ix(t,e,r){let n=0;return r.streams.forEach(i=>{i.stat.direction===e&&i.stat.protocol===t&&n++}),n}var oc=class{components;connectionEncryption;muxers;inboundUpgradeTimeout;events;constructor(e,r){this.components=e,this.connectionEncryption=new Map,r.connectionEncryption.forEach(n=>{this.connectionEncryption.set(n.protocol,n)}),this.muxers=new Map,r.muxers.forEach(n=>{this.muxers.set(n.protocol,n)}),this.inboundUpgradeTimeout=r.inboundUpgradeTimeout??3e4,this.events=e.events}async shouldBlockConnection(e,r,n){let i=this.components.connectionGater[n];if(i!==void 0&&await i(e,r))throw new v(`The multiaddr connection is blocked by gater.${n}`,N.ERR_CONNECTION_INTERCEPTED)}async upgradeInbound(e,r){if(!await this.components.connectionManager.acceptIncomingConnection(e))throw new v("connection denied",N.ERR_CONNECTION_DENIED);let i,o,s,a,c,u=Fi([AbortSignal.timeout(this.inboundUpgradeTimeout)]);try{(0,gh.setMaxListeners)?.(1/0,u)}catch{}try{let l=Z1(e,u);if(e.source=l.source,e.sink=l.sink,await this.components.connectionGater.denyInboundConnection?.(e)===!0)throw new v("The multiaddr connection is blocked by gater.acceptConnection",N.ERR_CONNECTION_INTERCEPTED);this.components.metrics?.trackMultiaddrConnection(e),ve("starting the inbound connection upgrade");let f=e;if(r?.skipProtection!==!0){let d=this.components.connectionProtector;d!=null&&(ve("protecting the inbound connection"),f=await d.protect(e))}try{if(i=f,r?.skipEncryption!==!0){({conn:i,remotePeer:o,protocol:c}=await this._encryptInbound(f));let d={...f,...i};await this.shouldBlockConnection(o,d,"denyInboundEncryptedConnection")}else{let d=e.remoteAddr.getPeerId();if(d==null)throw new v("inbound connection that skipped encryption must have a peer id",N.ERR_INVALID_MULTIADDR);let p=oe(d);c="native",o=p}if(s=i,r?.muxerFactory!=null)a=r.muxerFactory;else if(this.muxers.size>0){let d=await this._multiplexInbound({...f,...i},this.muxers);a=d.muxerFactory,s=d.stream}}catch(d){throw ve.error("Failed to upgrade inbound connection",d),d}return await this.shouldBlockConnection(o,e,"denyInboundUpgradedConnection"),ve("Successfully upgraded inbound connection"),this._createConnection({cryptoProtocol:c,direction:"inbound",maConn:e,upgradedConn:s,muxerFactory:a,remotePeer:o})}finally{this.components.connectionManager.afterUpgradeInbound(),u.clear()}}async upgradeOutbound(e,r){let n=e.remoteAddr.getPeerId(),i;n!=null&&(i=oe(n),await this.shouldBlockConnection(i,e,"denyOutboundConnection"));let o,s,a,c,u;this.components.metrics?.trackMultiaddrConnection(e),ve("Starting the outbound connection upgrade");let l=e;if(r?.skipProtection!==!0){let f=this.components.connectionProtector;f!=null&&(l=await f.protect(e))}try{if(o=l,r?.skipEncryption!==!0){({conn:o,remotePeer:s,protocol:c}=await this._encryptOutbound(l,i));let f={...l,...o};await this.shouldBlockConnection(s,f,"denyOutboundEncryptedConnection")}else{if(i==null)throw new v("Encryption was skipped but no peer id was passed",N.ERR_INVALID_PEER);c="native",s=i}if(a=o,r?.muxerFactory!=null)u=r.muxerFactory;else if(this.muxers.size>0){let f=await this._multiplexOutbound({...l,...o},this.muxers);u=f.muxerFactory,a=f.stream}}catch(f){throw ve.error("Failed to upgrade outbound connection",f),await e.close(f),f}return await this.shouldBlockConnection(s,e,"denyOutboundUpgradedConnection"),ve("Successfully upgraded outbound connection"),this._createConnection({cryptoProtocol:c,direction:"outbound",maConn:e,upgradedConn:a,muxerFactory:u,remotePeer:s})}_createConnection(e){let{cryptoProtocol:r,direction:n,maConn:i,upgradedConn:o,remotePeer:s,muxerFactory:a}=e,c,u,l;a!=null&&(c=a.createStreamMuxer({direction:n,onIncomingStream:p=>{l!=null&&Promise.resolve().then(async()=>{let h=this.components.registrar.getProtocols(),{stream:m,protocol:y}=await rs(p,h);if(ve("%s: incoming stream opened on %s",n,y),l==null)return;let g=GR(y,this.components.registrar);if(ix(y,"inbound",l)===g){let E=new v(`Too many inbound protocol streams for protocol "${y}" - limit ${g}`,N.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS);throw p.abort(E),E}p.source=m.source,p.sink=m.sink,p.stat.protocol=y,await this.components.peerStore.merge(s,{protocols:[y]}),l.addStream(p),this.components.metrics?.trackProtocolStream(p,l),this._onStream({connection:l,stream:p,protocol:y})}).catch(h=>{ve.error(h),p.stat.timeline.close==null&&p.close()})},onStreamEnd:p=>{l?.removeStream(p.id)}}),u=async(p,h={})=>{if(c==null)throw new v("Stream is not multiplexed",N.ERR_MUXER_UNAVAILABLE);ve("%s: starting new stream on %s",n,p);let m=await c.newStream();try{if(h.signal==null){ve("No abort signal was passed while trying to negotiate protocols %s falling back to default timeout",p),h.signal=AbortSignal.timeout(3e4);try{(0,gh.setMaxListeners)?.(1/0,h.signal)}catch{}}let{stream:y,protocol:g}=await es(m,p,h),x=YR(g,this.components.registrar,h);if(ix(g,"outbound",l)>=x){let T=new v(`Too many outbound protocol streams for protocol "${g}" - limit ${x}`,N.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS);throw m.abort(T),T}return await this.components.peerStore.merge(s,{protocols:[g]}),m.source=y.source,m.sink=y.sink,m.stat.protocol=g,this.components.metrics?.trackProtocolStream(m,l),m}catch(y){throw ve.error("could not create new stream",y),m.stat.timeline.close==null&&m.close(),y.code!=null?y:new v(String(y),N.ERR_UNSUPPORTED_PROTOCOL)}},Promise.all([c.sink(o.source),o.sink(c.source)]).catch(p=>{ve.error(p)}));let f=i.timeline;i.timeline=new Proxy(f,{set:(...p)=>(l!=null&&p[1]==="close"&&p[2]!=null&&f.close==null&&(async()=>{try{l.stat.status==="OPEN"&&await l.close()}catch(h){ve.error(h)}finally{this.events.safeDispatchEvent("connection:close",{detail:l})}})().catch(h=>{ve.error(h)}),Reflect.set(...p))}),i.timeline.upgraded=Date.now();let d=()=>{throw new v("connection is not multiplexed",N.ERR_CONNECTION_NOT_MULTIPLEXED)};return l=nx({remoteAddr:i.remoteAddr,remotePeer:s,stat:{status:"OPEN",direction:n,timeline:i.timeline,multiplexer:c?.protocol,encryption:r},newStream:u??d,getStreams:()=>c!=null?c.streams:d(),close:async()=>{await i.close(),c?.close()}}),this.events.safeDispatchEvent("connection:open",{detail:l}),l}_onStream(e){let{connection:r,stream:n,protocol:i}=e,{handler:o}=this.components.registrar.getHandler(i);o({connection:r,stream:n})}async _encryptInbound(e){let r=Array.from(this.connectionEncryption.keys());ve("handling inbound crypto protocol selection",r);try{let{stream:n,protocol:i}=await rs(e,r,{writeBytes:!0}),o=this.connectionEncryption.get(i);if(o==null)throw new Error(`no crypto module found for ${i}`);return ve("encrypting inbound connection..."),{...await o.secureInbound(this.components.peerId,n),protocol:i}}catch(n){throw new v(String(n),N.ERR_ENCRYPTION_FAILED)}}async _encryptOutbound(e,r){let n=Array.from(this.connectionEncryption.keys());ve("selecting outbound crypto protocol",n);try{let{stream:i,protocol:o}=await es(e,n,{writeBytes:!0}),s=this.connectionEncryption.get(o);if(s==null)throw new Error(`no crypto module found for ${o}`);return ve("encrypting outbound connection to %p",r),{...await s.secureOutbound(this.components.peerId,i,r),protocol:o}}catch(i){throw new v(String(i),N.ERR_ENCRYPTION_FAILED)}}async _multiplexOutbound(e,r){let n=Array.from(r.keys());ve("outbound selecting muxer %s",n);try{let{stream:i,protocol:o}=await es(e,n,{writeBytes:!0});ve("%s selected as muxer protocol",o);let s=r.get(o);return{stream:i,muxerFactory:s}}catch(i){throw ve.error("error multiplexing outbound stream",i),new v(String(i),N.ERR_MUXER_UNAVAILABLE)}}async _multiplexInbound(e,r){let n=Array.from(r.keys());ve("inbound handling muxers %s",n);try{let{stream:i,protocol:o}=await rs(e,n,{writeBytes:!0}),s=r.get(o);return{stream:i,muxerFactory:s}}catch(i){throw ve.error("error multiplexing inbound stream",i),new v(String(i),N.ERR_MUXER_UNAVAILABLE)}}};var ct=W("libp2p"),xh=class extends _o{peerId;peerStore;contentRouting;peerRouting;keychain;metrics;services;components;#e;constructor(e){super();let r=new _o,n=r.dispatchEvent.bind(r);r.dispatchEvent=c=>{let u=n(c),l=this.dispatchEvent(new nl(c.type,{detail:c.detail}));return u||l};try{(0,ox.setMaxListeners)?.(1/0,r)}catch{}this.#e=!1,this.peerId=e.peerId,this.services={};let i=this.components=Ig({peerId:e.peerId,events:r,datastore:e.datastore??new Pa,connectionGater:Og(e.connectionGater)});this.peerStore=this.configureComponent("peerStore",new Ta(i,{addressFilter:this.components.connectionGater.filterMultiaddrForPeer,...e.peerStore})),e.metrics!=null&&(this.metrics=this.configureComponent("metrics",e.metrics(this.components))),i.events.addEventListener("peer:update",c=>{c.detail.previous==null&&this.safeDispatchEvent("peer:discovery",{detail:c.detail.peer})}),e.connectionProtector!=null&&this.configureComponent("connectionProtector",e.connectionProtector(i)),this.components.upgrader=new oc(this.components,{connectionEncryption:(e.connectionEncryption??[]).map((c,u)=>this.configureComponent(`connection-encryption-${u}`,c(this.components))),muxers:(e.streamMuxers??[]).map((c,u)=>this.configureComponent(`stream-muxers-${u}`,c(this.components))),inboundUpgradeTimeout:e.connectionManager.inboundUpgradeTimeout}),this.configureComponent("transportManager",new ja(this.components,e.transportManager)),this.configureComponent("connectionManager",new $a(this.components,e.connectionManager)),this.configureComponent("registrar",new Za(this.components)),this.configureComponent("addressManager",new Da(this.components,e.addresses));let o=Sn.generateOptions();this.keychain=this.configureComponent("keyChain",new Sn(this.components,{...o,...e.keychain}));let s=(e.peerRouters??[]).map((c,u)=>this.configureComponent(`peer-router-${u}`,c(this.components)));this.peerRouting=this.components.peerRouting=this.configureComponent("peerRouting",new Xa(this.components,{routers:s}));let a=(e.contentRouters??[]).map((c,u)=>this.configureComponent(`content-router-${u}`,c(this.components)));if(this.contentRouting=this.components.contentRouting=this.configureComponent("contentRouting",new Wa(this.components,{routers:a})),(e.peerDiscovery??[]).forEach((c,u)=>{this.configureComponent(`peer-discovery-${u}`,c(this.components)).addEventListener("peer",f=>{this.#t(f)})}),e.transports.forEach((c,u)=>{this.components.transportManager.add(this.configureComponent(`transport-${u}`,c(this.components)))}),e.services!=null)for(let c of Object.keys(e.services)){let u=e.services[c],l=u(this.components);if(l==null){ct.error("service factory %s returned null or undefined instance",c);continue}this.services[c]=l,this.configureComponent(c,l),l[tl]!=null&&(ct("registering service %s for content routing",c),a.push(l[tl])),l[ol]!=null&&(ct("registering service %s for peer routing",c),s.push(l[ol])),l[il]!=null&&(ct("registering service %s for peer discovery",c),l[il].addEventListener("peer",f=>{this.#t(f)}))}}configureComponent(e,r){return r==null&&ct.error("component %s was null or undefined",e),this.components[e]=r,r}async start(){if(this.#e)return;this.#e=!0,ct("libp2p is starting"),(await this.keychain.listKeys()).find(r=>r.name==="self")==null&&(ct("importing self key into keychain"),await this.keychain.importPeer("self",this.components.peerId));try{await this.components.beforeStart?.(),await this.components.start(),await this.components.afterStart?.(),this.safeDispatchEvent("start",{detail:this}),ct("libp2p has started")}catch(r){throw ct.error("An error occurred starting libp2p",r),await this.stop(),r}}async stop(){this.#e&&(ct("libp2p is stopping"),this.#e=!1,await this.components.beforeStop?.(),await this.components.stop(),await this.components.afterStop?.(),this.safeDispatchEvent("stop",{detail:this}),ct("libp2p has stopped"))}isStarted(){return this.#e}getConnections(e){return this.components.connectionManager.getConnections(e)}getDialQueue(){return this.components.connectionManager.getDialQueue()}getPeers(){let e=new kt;for(let r of this.components.connectionManager.getConnections())e.add(r.remotePeer);return Array.from(e)}async dial(e,r={}){return this.components.connectionManager.openConnection(e,r)}async dialProtocol(e,r,n={}){if(r==null)throw new v("no protocols were provided to open a stream",N.ERR_INVALID_PROTOCOLS_FOR_STREAM);if(r=Array.isArray(r)?r:[r],r.length===0)throw new v("no protocols were provided to open a stream",N.ERR_INVALID_PROTOCOLS_FOR_STREAM);return(await this.dial(e,n)).newStream(r,n)}getMultiaddrs(){return this.components.addressManager.getAddresses()}getProtocols(){return this.components.registrar.getProtocols()}async hangUp(e){In(e)&&(e=oe(e.getPeerId()??"")),await this.components.connectionManager.closeConnections(e)}async getPublicKey(e,r={}){if(ct("getPublicKey %p",e),e.publicKey!=null)return e.publicKey;let n=await this.peerStore.get(e);if(n.id.publicKey!=null)return n.id.publicKey;let i=Pe([V("/pk/"),e.multihash.digest]),o=await this.contentRouting.get(i,r);return vo(o),await this.peerStore.patch(e,{publicKey:o}),o}async handle(e,r,n){Array.isArray(e)||(e=[e]),await Promise.all(e.map(async i=>{await this.components.registrar.handle(i,r,n)}))}async unhandle(e){Array.isArray(e)||(e=[e]),await Promise.all(e.map(async r=>{await this.components.registrar.unhandle(r)}))}async register(e,r){return this.components.registrar.register(e,r)}unregister(e){this.components.registrar.unregister(e)}#t(e){let{detail:r}=e;if(r.id.toString()===this.peerId.toString()){ct.error(new Error(N.ERR_DISCOVERED_SELF));return}this.components.peerStore.merge(r.id,{multiaddrs:r.multiaddrs,protocols:r.protocols}).catch(n=>{ct.error(n)})}};async function sx(t){if(t.peerId==null){let e=t.datastore;if(e!=null)try{let r=new Sn({datastore:e},qr(Sn.generateOptions(),t.keychain));t.peerId=await r.exportPeerId("self")}catch(r){if(r.code!=="ERR_NOT_FOUND")throw r}}return t.peerId==null&&(t.peerId=await ey()),new xh(Hg(t))}async function WR(t){let e=await sx(t);return t.start!==!1&&await e.start(),e}return dx(QR);})();
|
|
50
50
|
/*! Bundled license information:
|
|
51
51
|
|
|
@@ -165,7 +165,7 @@ class DefaultAutoNATService {
|
|
|
165
165
|
.map(buf => multiaddr(buf))
|
|
166
166
|
.filter(ma => {
|
|
167
167
|
const isFromSameHost = ma.toOptions().host === data.connection.remoteAddr.toOptions().host;
|
|
168
|
-
log.trace('request to dial %
|
|
168
|
+
log.trace('request to dial %a was sent from %a is same host %s', ma, data.connection.remoteAddr, isFromSameHost);
|
|
169
169
|
// skip any Multiaddrs where the target node's IP does not match the sending node's IP
|
|
170
170
|
return isFromSameHost;
|
|
171
171
|
})
|
|
@@ -185,7 +185,7 @@ class DefaultAutoNATService {
|
|
|
185
185
|
})
|
|
186
186
|
.filter(ma => {
|
|
187
187
|
const isSupportedTransport = Boolean(self.components.transportManager.transportForMultiaddr(ma));
|
|
188
|
-
log.trace('transport for %
|
|
188
|
+
log.trace('transport for %a is supported %s', ma, isSupportedTransport);
|
|
189
189
|
// skip any Multiaddrs that have transports we do not support
|
|
190
190
|
return isSupportedTransport;
|
|
191
191
|
})
|
|
@@ -219,7 +219,7 @@ class DefaultAutoNATService {
|
|
|
219
219
|
signal
|
|
220
220
|
});
|
|
221
221
|
if (!connection.remoteAddr.equals(multiaddr)) {
|
|
222
|
-
log.error('tried to dial %
|
|
222
|
+
log.error('tried to dial %a but dialed %a', multiaddr, connection.remoteAddr);
|
|
223
223
|
throw new Error('Unexpected remote address');
|
|
224
224
|
}
|
|
225
225
|
log('Success %p', peerId);
|
|
@@ -100,7 +100,7 @@ class CircuitRelayServer extends EventEmitter {
|
|
|
100
100
|
this.started = false;
|
|
101
101
|
}
|
|
102
102
|
async onHop({ connection, stream }) {
|
|
103
|
-
log('received circuit v2 hop protocol stream from %
|
|
103
|
+
log('received circuit v2 hop protocol stream from %p', connection.remotePeer);
|
|
104
104
|
const hopTimeoutPromise = pDefer();
|
|
105
105
|
const timeout = setTimeout(() => {
|
|
106
106
|
hopTimeoutPromise.reject('timed out');
|
|
@@ -146,14 +146,14 @@ class CircuitRelayServer extends EventEmitter {
|
|
|
146
146
|
await this.handleConnect({ stream, request, connection });
|
|
147
147
|
break;
|
|
148
148
|
default: {
|
|
149
|
-
log.error('invalid hop request type %s via peer %
|
|
149
|
+
log.error('invalid hop request type %s via peer %p', request.type, connection.remotePeer);
|
|
150
150
|
stream.pb(HopMessage).write({ type: HopMessage.Type.STATUS, status: Status.UNEXPECTED_MESSAGE });
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
async handleReserve({ stream, request, connection }) {
|
|
155
155
|
const hopstr = stream.pb(HopMessage);
|
|
156
|
-
log('hop reserve request from %
|
|
156
|
+
log('hop reserve request from %p', connection.remotePeer);
|
|
157
157
|
if (isRelayAddr(connection.remoteAddr)) {
|
|
158
158
|
log.error('relay reservation over circuit connection denied for peer: %p', connection.remotePeer);
|
|
159
159
|
hopstr.write({ type: HopMessage.Type.STATUS, status: Status.PERMISSION_DENIED });
|
|
@@ -219,7 +219,7 @@ class CircuitRelayServer extends EventEmitter {
|
|
|
219
219
|
hopstr.write({ type: HopMessage.Type.STATUS, status: Status.PERMISSION_DENIED });
|
|
220
220
|
return;
|
|
221
221
|
}
|
|
222
|
-
log('hop connect request from %
|
|
222
|
+
log('hop connect request from %p', connection.remotePeer);
|
|
223
223
|
let dstPeer;
|
|
224
224
|
try {
|
|
225
225
|
if (request.peer == null) {
|
|
@@ -262,7 +262,7 @@ class CircuitRelayServer extends EventEmitter {
|
|
|
262
262
|
}
|
|
263
263
|
});
|
|
264
264
|
if (destinationStream == null) {
|
|
265
|
-
log.error('failed to open stream to destination peer %
|
|
265
|
+
log.error('failed to open stream to destination peer %p', destinationConnection?.remotePeer);
|
|
266
266
|
hopstr.write({ type: HopMessage.Type.STATUS, status: Status.CONNECTION_FAILED });
|
|
267
267
|
return;
|
|
268
268
|
}
|
|
@@ -289,15 +289,15 @@ class CircuitRelayServer extends EventEmitter {
|
|
|
289
289
|
response = await stopstr.read();
|
|
290
290
|
}
|
|
291
291
|
catch (err) {
|
|
292
|
-
log.error('error parsing stop message response from %
|
|
292
|
+
log.error('error parsing stop message response from %p', connection.remotePeer);
|
|
293
293
|
}
|
|
294
294
|
if (response == null) {
|
|
295
|
-
log.error('could not read response from %
|
|
295
|
+
log.error('could not read response from %p', connection.remotePeer);
|
|
296
296
|
stream.close();
|
|
297
297
|
return;
|
|
298
298
|
}
|
|
299
299
|
if (response.status === Status.OK) {
|
|
300
|
-
log('stop request to %
|
|
300
|
+
log('stop request to %p was successful', connection.remotePeer);
|
|
301
301
|
return pbstr.unwrap();
|
|
302
302
|
}
|
|
303
303
|
log('stop request failed with code %d', response.status);
|
|
@@ -170,7 +170,7 @@ class CircuitRelayTransport {
|
|
|
170
170
|
remoteAddr: ma,
|
|
171
171
|
localAddr: relayAddr.encapsulate(`/p2p-circuit/p2p/${this.peerId.toString()}`)
|
|
172
172
|
});
|
|
173
|
-
log('new outbound connection %
|
|
173
|
+
log('new outbound connection %a', maConn.remoteAddr);
|
|
174
174
|
return await this.upgrader.upgradeOutbound(maConn);
|
|
175
175
|
}
|
|
176
176
|
catch (err) {
|
|
@@ -211,15 +211,15 @@ class CircuitRelayTransport {
|
|
|
211
211
|
return;
|
|
212
212
|
}
|
|
213
213
|
const stopstr = pbstr.pb(StopMessage);
|
|
214
|
-
log('new circuit relay v2 stop stream from %
|
|
214
|
+
log('new circuit relay v2 stop stream from %p', connection.remotePeer);
|
|
215
215
|
// Validate the STOP request has the required input
|
|
216
216
|
if (request.type !== StopMessage.Type.CONNECT) {
|
|
217
|
-
log.error('invalid stop connect request via peer %
|
|
217
|
+
log.error('invalid stop connect request via peer %p', connection.remotePeer);
|
|
218
218
|
stopstr.write({ type: StopMessage.Type.STATUS, status: Status.UNEXPECTED_MESSAGE });
|
|
219
219
|
return;
|
|
220
220
|
}
|
|
221
221
|
if (!isValidStop(request)) {
|
|
222
|
-
log.error('invalid stop connect request via peer %
|
|
222
|
+
log.error('invalid stop connect request via peer %p', connection.remotePeer);
|
|
223
223
|
stopstr.write({ type: StopMessage.Type.STATUS, status: Status.MALFORMED_MESSAGE });
|
|
224
224
|
return;
|
|
225
225
|
}
|
|
@@ -238,7 +238,7 @@ class CircuitRelayTransport {
|
|
|
238
238
|
});
|
|
239
239
|
log('new inbound connection %s', maConn.remoteAddr);
|
|
240
240
|
await this.upgrader.upgradeInbound(maConn);
|
|
241
|
-
log('%s connection %
|
|
241
|
+
log('%s connection %a upgraded', 'inbound', maConn.remoteAddr);
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
export function circuitRelayTransport(init = {}) {
|
|
@@ -20,7 +20,7 @@ class CircuitRelayTransportListener extends EventEmitter {
|
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
async listen(addr) {
|
|
23
|
-
log('listen on %
|
|
23
|
+
log('listen on %a', addr);
|
|
24
24
|
const relayPeerStr = addr.getPeerId();
|
|
25
25
|
let relayConn;
|
|
26
26
|
// check if we already have a connection to the relay
|
|
@@ -151,7 +151,7 @@ export class ReservationStore extends EventEmitter {
|
|
|
151
151
|
return this.reservations.get(peerId)?.reservation;
|
|
152
152
|
}
|
|
153
153
|
async #createReservation(connection) {
|
|
154
|
-
log('requesting reservation from %
|
|
154
|
+
log('requesting reservation from %p', connection.remotePeer);
|
|
155
155
|
const stream = await connection.newStream(RELAY_V2_HOP_CODEC);
|
|
156
156
|
const pbstr = pbStream(stream);
|
|
157
157
|
const hopstr = pbstr.pb(HopMessage);
|
|
@@ -311,12 +311,12 @@ export class DialQueue {
|
|
|
311
311
|
// let any signal abort the dial
|
|
312
312
|
const signal = combineSignals(controller.signal, options.signal);
|
|
313
313
|
signal.addEventListener('abort', () => {
|
|
314
|
-
log('dial to %
|
|
314
|
+
log('dial to %a aborted', addr);
|
|
315
315
|
});
|
|
316
316
|
const deferred = pDefer();
|
|
317
317
|
await peerDialQueue.add(async () => {
|
|
318
318
|
if (signal.aborted) {
|
|
319
|
-
log('dial to %
|
|
319
|
+
log('dial to %a was aborted before reaching the head of the peer dial queue', addr);
|
|
320
320
|
deferred.reject(new AbortError());
|
|
321
321
|
return;
|
|
322
322
|
}
|
|
@@ -324,7 +324,7 @@ export class DialQueue {
|
|
|
324
324
|
await this.queue.add(async () => {
|
|
325
325
|
try {
|
|
326
326
|
if (signal.aborted) {
|
|
327
|
-
log('dial to %
|
|
327
|
+
log('dial to %a was aborted before reaching the head of the dial queue', addr);
|
|
328
328
|
deferred.reject(new AbortError());
|
|
329
329
|
return;
|
|
330
330
|
}
|
|
@@ -351,13 +351,13 @@ export class DialQueue {
|
|
|
351
351
|
c.abort();
|
|
352
352
|
}
|
|
353
353
|
});
|
|
354
|
-
log('dial to %
|
|
354
|
+
log('dial to %a succeeded', addr);
|
|
355
355
|
// resolve the connection promise
|
|
356
356
|
deferred.resolve(conn);
|
|
357
357
|
}
|
|
358
358
|
catch (err) {
|
|
359
359
|
// something only went wrong if our signal was not aborted
|
|
360
|
-
log.error('error during dial of %
|
|
360
|
+
log.error('error during dial of %a', addr, err);
|
|
361
361
|
deferred.reject(err);
|
|
362
362
|
}
|
|
363
363
|
}, {
|
|
@@ -342,7 +342,7 @@ export class DefaultConnectionManager {
|
|
|
342
342
|
return maConn.remoteAddr.toString().startsWith(ma.toString());
|
|
343
343
|
});
|
|
344
344
|
if (denyConnection) {
|
|
345
|
-
log('connection from %
|
|
345
|
+
log('connection from %a refused - connection remote address was in deny list', maConn.remoteAddr);
|
|
346
346
|
return false;
|
|
347
347
|
}
|
|
348
348
|
// check allow list
|
|
@@ -355,7 +355,7 @@ export class DefaultConnectionManager {
|
|
|
355
355
|
}
|
|
356
356
|
// check pending connections
|
|
357
357
|
if (this.incomingPendingConnections === this.maxIncomingPendingConnections) {
|
|
358
|
-
log('connection from %
|
|
358
|
+
log('connection from %a refused - incomingPendingConnections exceeded by host', maConn.remoteAddr);
|
|
359
359
|
return false;
|
|
360
360
|
}
|
|
361
361
|
if (maConn.remoteAddr.isThinWaistAddress()) {
|
|
@@ -364,7 +364,7 @@ export class DefaultConnectionManager {
|
|
|
364
364
|
await this.inboundConnectionRateLimiter.consume(host, 1);
|
|
365
365
|
}
|
|
366
366
|
catch {
|
|
367
|
-
log('connection from %
|
|
367
|
+
log('connection from %a refused - inboundConnectionThreshold exceeded by host %s', maConn.remoteAddr, host);
|
|
368
368
|
return false;
|
|
369
369
|
}
|
|
370
370
|
}
|
|
@@ -372,7 +372,7 @@ export class DefaultConnectionManager {
|
|
|
372
372
|
this.incomingPendingConnections++;
|
|
373
373
|
return true;
|
|
374
374
|
}
|
|
375
|
-
log('connection from %
|
|
375
|
+
log('connection from %a refused - maxConnections exceeded', maConn.remoteAddr);
|
|
376
376
|
return false;
|
|
377
377
|
}
|
|
378
378
|
afterUpgradeInbound() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connection-manager/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,EAAiC,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC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B;QAC5B,IAAI,IAAI,CAAC,0BAA0B,KAAK,IAAI,CAAC,6BAA6B,EAAE;YAC1E,GAAG,CAAC,0EAA0E,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;YAClG,OAAO,KAAK,CAAA;SACb;QAED,IAAI,MAAM,CAAC,UAAU,CAAC,kBAAkB,EAAE,EAAE;YAC1C,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,OAAO,CAAA;YAEpD,IAAI;gBACF,MAAM,IAAI,CAAC,4BAA4B,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;aACzD;YAAC,MAAM;gBACN,GAAG,CAAC,6EAA6E,EAAE,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;gBAC3G,OAAO,KAAK,CAAA;aACb;SACF;QAED,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE;YACtD,IAAI,CAAC,0BAA0B,EAAE,CAAA;YAEjC,OAAO,IAAI,CAAA;SACZ;QAED,GAAG,CAAC,sDAAsD,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;QAC9E,OAAO,KAAK,CAAA;IACd,CAAC;IAED,mBAAmB;QACjB,IAAI,CAAC,0BAA0B,EAAE,CAAA;IACnC,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,CAAA;IACpC,CAAC;CACF"}
|
|
@@ -249,10 +249,10 @@ export class DefaultIdentifyService {
|
|
|
249
249
|
// Get the observedAddr if there is one
|
|
250
250
|
const cleanObservedAddr = getCleanMultiaddr(observedAddr);
|
|
251
251
|
log('identify completed for peer %p and protocols %o', id, protocols);
|
|
252
|
-
log('our observed address is %
|
|
252
|
+
log('our observed address is %a', cleanObservedAddr);
|
|
253
253
|
if (cleanObservedAddr != null &&
|
|
254
254
|
this.addressManager.getObservedAddrs().length < (this.maxObservedAddresses ?? Infinity)) {
|
|
255
|
-
log('storing our observed address %
|
|
255
|
+
log('storing our observed address %a', cleanObservedAddr);
|
|
256
256
|
this.addressManager.addObservedAddr(cleanObservedAddr);
|
|
257
257
|
}
|
|
258
258
|
const signedPeerRecord = await this.#consumeIdentifyMessage(connection.remotePeer, message);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identify.js","sourceRoot":"","sources":["../../../src/identify/identify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,EAAkB,SAAS,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B,OAAO,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC9G,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACpC,OAAO,EACL,aAAa,EACb,yBAAyB,EACzB,iCAAiC,EACjC,sCAAsC,EACtC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AY,CAAC,kBAAkB,CAAA;qBACrD;iBACF;aACF;YAED,wCAAwC;YACxC,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;YAE5C,2DAA2D;YAC3D,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;gBACvD,WAAW,EAAE,IAAI;gBACjB,SAAS;aACV,CAAC,CAAC,CAAA;YAEH,MAAM,GAAG;gBACP,GAAG,EAAE,UAAU,CAAC,SAAS;gBACzB,SAAS,EAAE,UAAU,CAAC,UAAU;aACjC,CAAA;SACF;aAAM;YACL,GAAG,CAAC,sCAAsC,EAAE,UAAU,CAAC,CAAA;SACxD;QAED,IAAI,OAAO,CAAC,YAAY,IAAI,IAAI,EAAE;YAChC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,cAAc,EAAE,oBAAoB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAA;SAC9E;QAED,IAAI,OAAO,CAAC,eAAe,IAAI,IAAI,EAAE;YACnC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAA;SACpF;QAED,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;QAE5C,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAED;;GAEG;AACH,SAAS,iBAAiB,CAAE,IAA4C;IACtE,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;QACnC,IAAI;YACF,OAAO,SAAS,CAAC,IAAI,CAAC,CAAA;SACvB;QAAC,MAAM;SAEP;KACF;AACH,CAAC"}
|
|
@@ -140,7 +140,7 @@ export class DefaultTransportManager {
|
|
|
140
140
|
const tasks = [];
|
|
141
141
|
// For each supported multiaddr, create a listener
|
|
142
142
|
for (const addr of supportedAddrs) {
|
|
143
|
-
log('creating listener for %s on %
|
|
143
|
+
log('creating listener for %s on %a', key, addr);
|
|
144
144
|
const listener = transport.createListener({
|
|
145
145
|
upgrader: this.components.upgrader
|
|
146
146
|
});
|
package/dist/src/version.d.ts
CHANGED
package/dist/src/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libp2p",
|
|
3
|
-
"version": "0.45.9-
|
|
3
|
+
"version": "0.45.9-2e561fe9",
|
|
4
4
|
"description": "JavaScript implementation of libp2p, a modular peer to peer network stack",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/master/packages/libp2p#readme",
|
|
@@ -115,18 +115,18 @@
|
|
|
115
115
|
},
|
|
116
116
|
"dependencies": {
|
|
117
117
|
"@achingbrain/nat-port-mapper": "^1.0.9",
|
|
118
|
-
"@libp2p/crypto": "1.0.17-
|
|
119
|
-
"@libp2p/interface": "0.0.1-
|
|
120
|
-
"@libp2p/interface-internal": "0.0.1-
|
|
121
|
-
"@libp2p/keychain": "2.0.1-
|
|
122
|
-
"@libp2p/logger": "2.1.1-
|
|
123
|
-
"@libp2p/multistream-select": "3.1.9-
|
|
124
|
-
"@libp2p/peer-collections": "3.0.2-
|
|
125
|
-
"@libp2p/peer-id": "2.0.3-
|
|
126
|
-
"@libp2p/peer-id-factory": "2.0.3-
|
|
127
|
-
"@libp2p/peer-record": "5.0.4-
|
|
128
|
-
"@libp2p/peer-store": "8.2.1-
|
|
129
|
-
"@libp2p/utils": "3.0.12-
|
|
118
|
+
"@libp2p/crypto": "1.0.17-2e561fe9",
|
|
119
|
+
"@libp2p/interface": "0.0.1-2e561fe9",
|
|
120
|
+
"@libp2p/interface-internal": "0.0.1-2e561fe9",
|
|
121
|
+
"@libp2p/keychain": "2.0.1-2e561fe9",
|
|
122
|
+
"@libp2p/logger": "2.1.1-2e561fe9",
|
|
123
|
+
"@libp2p/multistream-select": "3.1.9-2e561fe9",
|
|
124
|
+
"@libp2p/peer-collections": "3.0.2-2e561fe9",
|
|
125
|
+
"@libp2p/peer-id": "2.0.3-2e561fe9",
|
|
126
|
+
"@libp2p/peer-id-factory": "2.0.3-2e561fe9",
|
|
127
|
+
"@libp2p/peer-record": "5.0.4-2e561fe9",
|
|
128
|
+
"@libp2p/peer-store": "8.2.1-2e561fe9",
|
|
129
|
+
"@libp2p/utils": "3.0.12-2e561fe9",
|
|
130
130
|
"@multiformats/mafmt": "^12.1.2",
|
|
131
131
|
"@multiformats/multiaddr": "^12.1.3",
|
|
132
132
|
"abortable-iterator": "^5.0.1",
|
|
@@ -163,17 +163,17 @@
|
|
|
163
163
|
"@chainsafe/libp2p-gossipsub": "^8.0.0",
|
|
164
164
|
"@chainsafe/libp2p-noise": "^12.0.0",
|
|
165
165
|
"@chainsafe/libp2p-yamux": "^4.0.1",
|
|
166
|
-
"@libp2p/bootstrap": "8.0.0-
|
|
166
|
+
"@libp2p/bootstrap": "8.0.0-2e561fe9",
|
|
167
167
|
"@libp2p/daemon-client": "^6.0.2",
|
|
168
168
|
"@libp2p/daemon-server": "^5.0.2",
|
|
169
169
|
"@libp2p/floodsub": "^7.0.1",
|
|
170
|
-
"@libp2p/interface-compliance-tests": "3.0.7-
|
|
170
|
+
"@libp2p/interface-compliance-tests": "3.0.7-2e561fe9",
|
|
171
171
|
"@libp2p/interop": "^8.0.0",
|
|
172
|
-
"@libp2p/kad-dht": "9.3.6-
|
|
173
|
-
"@libp2p/mdns": "8.0.0-
|
|
174
|
-
"@libp2p/mplex": "8.0.4-
|
|
175
|
-
"@libp2p/tcp": "7.0.3-
|
|
176
|
-
"@libp2p/websockets": "6.0.3-
|
|
172
|
+
"@libp2p/kad-dht": "9.3.6-2e561fe9",
|
|
173
|
+
"@libp2p/mdns": "8.0.0-2e561fe9",
|
|
174
|
+
"@libp2p/mplex": "8.0.4-2e561fe9",
|
|
175
|
+
"@libp2p/tcp": "7.0.3-2e561fe9",
|
|
176
|
+
"@libp2p/websockets": "6.0.3-2e561fe9",
|
|
177
177
|
"@types/varint": "^6.0.0",
|
|
178
178
|
"@types/xsalsa20": "^1.1.0",
|
|
179
179
|
"aegir": "^39.0.10",
|
package/src/autonat/index.ts
CHANGED
|
@@ -258,7 +258,7 @@ class DefaultAutoNATService implements Startable {
|
|
|
258
258
|
.filter(ma => {
|
|
259
259
|
const isFromSameHost = ma.toOptions().host === data.connection.remoteAddr.toOptions().host
|
|
260
260
|
|
|
261
|
-
log.trace('request to dial %
|
|
261
|
+
log.trace('request to dial %a was sent from %a is same host %s', ma, data.connection.remoteAddr, isFromSameHost)
|
|
262
262
|
// skip any Multiaddrs where the target node's IP does not match the sending node's IP
|
|
263
263
|
return isFromSameHost
|
|
264
264
|
})
|
|
@@ -281,7 +281,7 @@ class DefaultAutoNATService implements Startable {
|
|
|
281
281
|
.filter(ma => {
|
|
282
282
|
const isSupportedTransport = Boolean(self.components.transportManager.transportForMultiaddr(ma))
|
|
283
283
|
|
|
284
|
-
log.trace('transport for %
|
|
284
|
+
log.trace('transport for %a is supported %s', ma, isSupportedTransport)
|
|
285
285
|
// skip any Multiaddrs that have transports we do not support
|
|
286
286
|
return isSupportedTransport
|
|
287
287
|
})
|
|
@@ -324,7 +324,7 @@ class DefaultAutoNATService implements Startable {
|
|
|
324
324
|
})
|
|
325
325
|
|
|
326
326
|
if (!connection.remoteAddr.equals(multiaddr)) {
|
|
327
|
-
log.error('tried to dial %
|
|
327
|
+
log.error('tried to dial %a but dialed %a', multiaddr, connection.remoteAddr)
|
|
328
328
|
throw new Error('Unexpected remote address')
|
|
329
329
|
}
|
|
330
330
|
|
|
@@ -193,7 +193,7 @@ class CircuitRelayServer extends EventEmitter<RelayServerEvents> implements Star
|
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
async onHop ({ connection, stream }: IncomingStreamData): Promise<void> {
|
|
196
|
-
log('received circuit v2 hop protocol stream from %
|
|
196
|
+
log('received circuit v2 hop protocol stream from %p', connection.remotePeer)
|
|
197
197
|
|
|
198
198
|
const hopTimeoutPromise = pDefer<HopMessage>()
|
|
199
199
|
const timeout = setTimeout(() => {
|
|
@@ -239,7 +239,7 @@ class CircuitRelayServer extends EventEmitter<RelayServerEvents> implements Star
|
|
|
239
239
|
case HopMessage.Type.RESERVE: await this.handleReserve({ stream, request, connection }); break
|
|
240
240
|
case HopMessage.Type.CONNECT: await this.handleConnect({ stream, request, connection }); break
|
|
241
241
|
default: {
|
|
242
|
-
log.error('invalid hop request type %s via peer %
|
|
242
|
+
log.error('invalid hop request type %s via peer %p', request.type, connection.remotePeer)
|
|
243
243
|
stream.pb(HopMessage).write({ type: HopMessage.Type.STATUS, status: Status.UNEXPECTED_MESSAGE })
|
|
244
244
|
}
|
|
245
245
|
}
|
|
@@ -247,7 +247,7 @@ class CircuitRelayServer extends EventEmitter<RelayServerEvents> implements Star
|
|
|
247
247
|
|
|
248
248
|
async handleReserve ({ stream, request, connection }: HopProtocolOptions): Promise<void> {
|
|
249
249
|
const hopstr = stream.pb(HopMessage)
|
|
250
|
-
log('hop reserve request from %
|
|
250
|
+
log('hop reserve request from %p', connection.remotePeer)
|
|
251
251
|
|
|
252
252
|
if (isRelayAddr(connection.remoteAddr)) {
|
|
253
253
|
log.error('relay reservation over circuit connection denied for peer: %p', connection.remotePeer)
|
|
@@ -329,7 +329,7 @@ class CircuitRelayServer extends EventEmitter<RelayServerEvents> implements Star
|
|
|
329
329
|
return
|
|
330
330
|
}
|
|
331
331
|
|
|
332
|
-
log('hop connect request from %
|
|
332
|
+
log('hop connect request from %p', connection.remotePeer)
|
|
333
333
|
|
|
334
334
|
let dstPeer: PeerId
|
|
335
335
|
|
|
@@ -381,7 +381,7 @@ class CircuitRelayServer extends EventEmitter<RelayServerEvents> implements Star
|
|
|
381
381
|
})
|
|
382
382
|
|
|
383
383
|
if (destinationStream == null) {
|
|
384
|
-
log.error('failed to open stream to destination peer %
|
|
384
|
+
log.error('failed to open stream to destination peer %p', destinationConnection?.remotePeer)
|
|
385
385
|
hopstr.write({ type: HopMessage.Type.STATUS, status: Status.CONNECTION_FAILED })
|
|
386
386
|
return
|
|
387
387
|
}
|
|
@@ -414,17 +414,17 @@ class CircuitRelayServer extends EventEmitter<RelayServerEvents> implements Star
|
|
|
414
414
|
try {
|
|
415
415
|
response = await stopstr.read()
|
|
416
416
|
} catch (err) {
|
|
417
|
-
log.error('error parsing stop message response from %
|
|
417
|
+
log.error('error parsing stop message response from %p', connection.remotePeer)
|
|
418
418
|
}
|
|
419
419
|
|
|
420
420
|
if (response == null) {
|
|
421
|
-
log.error('could not read response from %
|
|
421
|
+
log.error('could not read response from %p', connection.remotePeer)
|
|
422
422
|
stream.close()
|
|
423
423
|
return
|
|
424
424
|
}
|
|
425
425
|
|
|
426
426
|
if (response.status === Status.OK) {
|
|
427
|
-
log('stop request to %
|
|
427
|
+
log('stop request to %p was successful', connection.remotePeer)
|
|
428
428
|
return pbstr.unwrap()
|
|
429
429
|
}
|
|
430
430
|
|
|
@@ -266,7 +266,7 @@ class CircuitRelayTransport implements Transport {
|
|
|
266
266
|
localAddr: relayAddr.encapsulate(`/p2p-circuit/p2p/${this.peerId.toString()}`)
|
|
267
267
|
})
|
|
268
268
|
|
|
269
|
-
log('new outbound connection %
|
|
269
|
+
log('new outbound connection %a', maConn.remoteAddr)
|
|
270
270
|
return await this.upgrader.upgradeOutbound(maConn)
|
|
271
271
|
} catch (err) {
|
|
272
272
|
log.error(`Circuit relay dial to destination ${destinationPeer.toString()} via relay ${connection.remotePeer.toString()} failed`, err)
|
|
@@ -312,17 +312,17 @@ class CircuitRelayTransport implements Transport {
|
|
|
312
312
|
}
|
|
313
313
|
|
|
314
314
|
const stopstr = pbstr.pb(StopMessage)
|
|
315
|
-
log('new circuit relay v2 stop stream from %
|
|
315
|
+
log('new circuit relay v2 stop stream from %p', connection.remotePeer)
|
|
316
316
|
|
|
317
317
|
// Validate the STOP request has the required input
|
|
318
318
|
if (request.type !== StopMessage.Type.CONNECT) {
|
|
319
|
-
log.error('invalid stop connect request via peer %
|
|
319
|
+
log.error('invalid stop connect request via peer %p', connection.remotePeer)
|
|
320
320
|
stopstr.write({ type: StopMessage.Type.STATUS, status: Status.UNEXPECTED_MESSAGE })
|
|
321
321
|
return
|
|
322
322
|
}
|
|
323
323
|
|
|
324
324
|
if (!isValidStop(request)) {
|
|
325
|
-
log.error('invalid stop connect request via peer %
|
|
325
|
+
log.error('invalid stop connect request via peer %p', connection.remotePeer)
|
|
326
326
|
stopstr.write({ type: StopMessage.Type.STATUS, status: Status.MALFORMED_MESSAGE })
|
|
327
327
|
return
|
|
328
328
|
}
|
|
@@ -346,7 +346,7 @@ class CircuitRelayTransport implements Transport {
|
|
|
346
346
|
|
|
347
347
|
log('new inbound connection %s', maConn.remoteAddr)
|
|
348
348
|
await this.upgrader.upgradeInbound(maConn)
|
|
349
|
-
log('%s connection %
|
|
349
|
+
log('%s connection %a upgraded', 'inbound', maConn.remoteAddr)
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
352
|
|
|
@@ -37,7 +37,7 @@ class CircuitRelayTransportListener extends EventEmitter<ListenerEvents> impleme
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
async listen (addr: Multiaddr): Promise<void> {
|
|
40
|
-
log('listen on %
|
|
40
|
+
log('listen on %a', addr)
|
|
41
41
|
|
|
42
42
|
const relayPeerStr = addr.getPeerId()
|
|
43
43
|
let relayConn: Connection | undefined
|
|
@@ -237,7 +237,7 @@ export class ReservationStore extends EventEmitter<ReservationStoreEvents> imple
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
async #createReservation (connection: Connection): Promise<Reservation> {
|
|
240
|
-
log('requesting reservation from %
|
|
240
|
+
log('requesting reservation from %p', connection.remotePeer)
|
|
241
241
|
const stream = await connection.newStream(RELAY_V2_HOP_CODEC)
|
|
242
242
|
const pbstr = pbStream(stream)
|
|
243
243
|
const hopstr = pbstr.pb(HopMessage)
|
|
@@ -418,13 +418,13 @@ export class DialQueue {
|
|
|
418
418
|
// let any signal abort the dial
|
|
419
419
|
const signal = combineSignals(controller.signal, options.signal)
|
|
420
420
|
signal.addEventListener('abort', () => {
|
|
421
|
-
log('dial to %
|
|
421
|
+
log('dial to %a aborted', addr)
|
|
422
422
|
})
|
|
423
423
|
const deferred = pDefer<Connection>()
|
|
424
424
|
|
|
425
425
|
await peerDialQueue.add(async () => {
|
|
426
426
|
if (signal.aborted) {
|
|
427
|
-
log('dial to %
|
|
427
|
+
log('dial to %a was aborted before reaching the head of the peer dial queue', addr)
|
|
428
428
|
deferred.reject(new AbortError())
|
|
429
429
|
return
|
|
430
430
|
}
|
|
@@ -433,7 +433,7 @@ export class DialQueue {
|
|
|
433
433
|
await this.queue.add(async () => {
|
|
434
434
|
try {
|
|
435
435
|
if (signal.aborted) {
|
|
436
|
-
log('dial to %
|
|
436
|
+
log('dial to %a was aborted before reaching the head of the dial queue', addr)
|
|
437
437
|
deferred.reject(new AbortError())
|
|
438
438
|
return
|
|
439
439
|
}
|
|
@@ -468,13 +468,13 @@ export class DialQueue {
|
|
|
468
468
|
}
|
|
469
469
|
})
|
|
470
470
|
|
|
471
|
-
log('dial to %
|
|
471
|
+
log('dial to %a succeeded', addr)
|
|
472
472
|
|
|
473
473
|
// resolve the connection promise
|
|
474
474
|
deferred.resolve(conn)
|
|
475
475
|
} catch (err: any) {
|
|
476
476
|
// something only went wrong if our signal was not aborted
|
|
477
|
-
log.error('error during dial of %
|
|
477
|
+
log.error('error during dial of %a', addr, err)
|
|
478
478
|
deferred.reject(err)
|
|
479
479
|
}
|
|
480
480
|
}, {
|
|
@@ -547,7 +547,7 @@ export class DefaultConnectionManager implements ConnectionManager, Startable {
|
|
|
547
547
|
})
|
|
548
548
|
|
|
549
549
|
if (denyConnection) {
|
|
550
|
-
log('connection from %
|
|
550
|
+
log('connection from %a refused - connection remote address was in deny list', maConn.remoteAddr)
|
|
551
551
|
return false
|
|
552
552
|
}
|
|
553
553
|
|
|
@@ -564,7 +564,7 @@ export class DefaultConnectionManager implements ConnectionManager, Startable {
|
|
|
564
564
|
|
|
565
565
|
// check pending connections
|
|
566
566
|
if (this.incomingPendingConnections === this.maxIncomingPendingConnections) {
|
|
567
|
-
log('connection from %
|
|
567
|
+
log('connection from %a refused - incomingPendingConnections exceeded by host', maConn.remoteAddr)
|
|
568
568
|
return false
|
|
569
569
|
}
|
|
570
570
|
|
|
@@ -574,7 +574,7 @@ export class DefaultConnectionManager implements ConnectionManager, Startable {
|
|
|
574
574
|
try {
|
|
575
575
|
await this.inboundConnectionRateLimiter.consume(host, 1)
|
|
576
576
|
} catch {
|
|
577
|
-
log('connection from %
|
|
577
|
+
log('connection from %a refused - inboundConnectionThreshold exceeded by host %s', maConn.remoteAddr, host)
|
|
578
578
|
return false
|
|
579
579
|
}
|
|
580
580
|
}
|
|
@@ -585,7 +585,7 @@ export class DefaultConnectionManager implements ConnectionManager, Startable {
|
|
|
585
585
|
return true
|
|
586
586
|
}
|
|
587
587
|
|
|
588
|
-
log('connection from %
|
|
588
|
+
log('connection from %a refused - maxConnections exceeded', maConn.remoteAddr)
|
|
589
589
|
return false
|
|
590
590
|
}
|
|
591
591
|
|
package/src/identify/identify.ts
CHANGED
|
@@ -322,11 +322,11 @@ export class DefaultIdentifyService implements Startable {
|
|
|
322
322
|
const cleanObservedAddr = getCleanMultiaddr(observedAddr)
|
|
323
323
|
|
|
324
324
|
log('identify completed for peer %p and protocols %o', id, protocols)
|
|
325
|
-
log('our observed address is %
|
|
325
|
+
log('our observed address is %a', cleanObservedAddr)
|
|
326
326
|
|
|
327
327
|
if (cleanObservedAddr != null &&
|
|
328
328
|
this.addressManager.getObservedAddrs().length < (this.maxObservedAddresses ?? Infinity)) {
|
|
329
|
-
log('storing our observed address %
|
|
329
|
+
log('storing our observed address %a', cleanObservedAddr)
|
|
330
330
|
this.addressManager.addObservedAddr(cleanObservedAddr)
|
|
331
331
|
}
|
|
332
332
|
|
package/src/transport-manager.ts
CHANGED
|
@@ -190,7 +190,7 @@ export class DefaultTransportManager implements TransportManager, Startable {
|
|
|
190
190
|
|
|
191
191
|
// For each supported multiaddr, create a listener
|
|
192
192
|
for (const addr of supportedAddrs) {
|
|
193
|
-
log('creating listener for %s on %
|
|
193
|
+
log('creating listener for %s on %a', key, addr)
|
|
194
194
|
const listener = transport.createListener({
|
|
195
195
|
upgrader: this.components.upgrader
|
|
196
196
|
})
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = '0.45.9-
|
|
1
|
+
export const version = '0.45.9-2e561fe9'
|
|
2
2
|
export const name = 'libp2p'
|