Skip to content

Commit

Permalink
fix: update websockets (#193)
Browse files Browse the repository at this point in the history
Fixes WebSockets cert setup
  • Loading branch information
achingbrain authored Dec 9, 2024
1 parent 03ae0c9 commit efe80e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 deletions 4.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable no-console */

import fs from 'fs'
import https from 'https'
import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux'
import { tcp } from '@libp2p/tcp'
Expand All @@ -11,11 +10,6 @@ import { createLibp2p } from 'libp2p'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'

const httpServer = https.createServer({
cert: fs.readFileSync('./test_certs/cert.pem'),
key: fs.readFileSync('./test_certs/key.pem')
})

const createNode = async (addresses = []) => {
if (!Array.isArray(addresses)) {
addresses = [addresses]
Expand All @@ -28,7 +22,10 @@ const createNode = async (addresses = []) => {
transports: [
tcp(),
webSockets({
server: httpServer,
https: {
cert: fs.readFileSync('./test_certs/cert.pem'),
key: fs.readFileSync('./test_certs/key.pem')
},
websocket: {
rejectUnauthorized: false
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@chainsafe/libp2p-noise": "^16.0.0",
"@chainsafe/libp2p-yamux": "^7.0.0",
"@libp2p/tcp": "^10.0.0",
"@libp2p/websockets": "^9.0.0",
"@libp2p/websockets": "^9.1.0",
"it-pipe": "^3.0.1",
"it-to-buffer": "^4.0.2",
"libp2p": "^2.0.0",
Expand Down

0 comments on commit efe80e0

Please sign in to comment.