Skip to content

Commit b838e4b

Browse files
committed
Patch package
1 parent 4a423c9 commit b838e4b

File tree

4 files changed

+247
-10
lines changed

4 files changed

+247
-10
lines changed

package-lock.json

Lines changed: 204 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"test:stress": "npm run test:k6-common k6 run -e TEST_TYPE=stress \"./dist/test/performance/perf_test.js\"",
4646
"test:request:rate": "npm run test:k6-common && k6 run -e RATE=true \"./dist/test/performance/perf_test.js\"",
4747
"release": "release-it --non-interactive",
48-
"changelog": "auto-changelog -p"
48+
"changelog": "auto-changelog -p",
49+
"postinstall": "patch-package"
4950
},
5051
"dependencies": {
5152
"@chainsafe/libp2p-noise": "^17.0.0",
@@ -126,6 +127,8 @@
126127
"eslint-plugin-promise": "^6.1.1",
127128
"mocha": "^11.1.0",
128129
"nyc": "^17.1.0",
130+
"patch-package": "^8.0.1",
131+
"postinstall-postinstall": "^2.1.0",
129132
"prettier": "^3.7.4",
130133
"release-it": "^19.0.6",
131134
"sinon": "^19.0.2",
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
diff --git a/node_modules/@libp2p/http-utils/dist/src/index.js b/node_modules/@libp2p/http-utils/dist/src/index.js
2+
index f1f98d5..2ad6be6 100644
3+
--- a/node_modules/@libp2p/http-utils/dist/src/index.js
4+
+++ b/node_modules/@libp2p/http-utils/dist/src/index.js
5+
@@ -213,7 +213,7 @@ export function getHost(addresses, headers) {
6+
let protocol = 'http:';
7+
if (addresses instanceof URL) {
8+
host = addresses.hostname;
9+
- port = parseInt(addresses.port, 10);
10+
+ port = parseInt(addresses.port === '' ? (addresses.protocol === 'https:' ? '443' : '80') : addresses.port, 10);
11+
protocol = addresses.protocol;
12+
}
13+
if (!isValidHost(host)) {
14+
diff --git a/node_modules/@libp2p/http-utils/src/index.ts b/node_modules/@libp2p/http-utils/src/index.ts
15+
index 5a73139..a5e0dc5 100644
16+
--- a/node_modules/@libp2p/http-utils/src/index.ts
17+
+++ b/node_modules/@libp2p/http-utils/src/index.ts
18+
@@ -301,7 +301,7 @@ export function getHost (addresses: URL | Multiaddr[], headers: Headers): string
19+
20+
if (addresses instanceof URL) {
21+
host = addresses.hostname
22+
- port = parseInt(addresses.port, 10)
23+
+ port = parseInt(addresses.port === '' ? (addresses.protocol === 'https:' ? '443' : '80') : addresses.port, 10)
24+
protocol = addresses.protocol
25+
}
26+

src/components/P2P/index.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ export class OceanP2P extends EventEmitter {
117117
this._libp2p.addEventListener('peer:discovery', (details: any) => {
118118
this.handlePeerDiscovery(details)
119119
})
120-
this._libp2p.addEventListener('certificate:provision', (details: any) => {
121-
this.handleCertificateProvision(details)
120+
this._libp2p.addEventListener('certificate:provision', () => {
121+
this.handleCertificateProvision()
122122
})
123-
this._libp2p.addEventListener('certificate:renew', (details: any) => {
124-
this.handleCertificateProvision(details)
123+
this._libp2p.addEventListener('certificate:renew', () => {
124+
this.handleCertificateRenew()
125125
})
126126
this._options = Object.assign(
127127
{},
@@ -198,22 +198,26 @@ export class OceanP2P extends EventEmitter {
198198
}
199199
}
200200

201-
handleCertificateProvision(details: any) {
202-
console.log('A TLS certificate was provisioned')
203-
console.log('Details: ' + JSON.stringify(details))
201+
handleCertificateProvision() {
202+
console.log('----- A TLS certificate was provisioned -----')
204203
const interval = setInterval(() => {
205204
const mas = this._libp2p
206205
.getMultiaddrs()
207206
.filter((ma: any) => ma.toString().includes('/sni/'))
208207
.map((ma: any) => ma.toString())
209208
if (mas.length > 0) {
210-
console.log('addresses:')
209+
console.log('----- TLS addresses: -----')
211210
console.log(mas.join('\n'))
211+
console.log('----- End of TLS addresses -----')
212212
}
213213
clearInterval(interval)
214214
}, 1_000)
215215
}
216216

217+
handleCertificateRenew() {
218+
console.log('----- A TLS certificate was renewed -----')
219+
}
220+
217221
handlePeerJoined(details: any) {
218222
P2P_LOGGER.debug('New peer joined us:' + details)
219223
}
@@ -316,7 +320,7 @@ export class OceanP2P extends EventEmitter {
316320
listen: bindInterfaces,
317321
announceFilter: (multiaddrs: any[]) =>
318322
multiaddrs.filter((m) => this.shouldAnnounce(m)),
319-
appendAnnounce: config.p2pConfig.announceAddresses
323+
announce: config.p2pConfig.announceAddresses
320324
}
321325
} else {
322326
addresses = {

0 commit comments

Comments
 (0)