@libp2p/tcp
Advanced tools
Comparing version 3.0.5 to 3.0.6
@@ -24,2 +24,3 @@ import net from 'net'; | ||
const socket = await this._connect(ma, options); | ||
socket.setKeepAlive(true); | ||
// Avoid uncaught errors caused by unstable connections | ||
@@ -26,0 +27,0 @@ socket.on('error', err => { |
@@ -27,2 +27,3 @@ import net from 'net'; | ||
const server = Object.assign(net.createServer(socket => { | ||
socket.setKeepAlive(true); | ||
// Avoid uncaught errors caused by unstable connections | ||
@@ -29,0 +30,0 @@ socket.on('error', err => { |
@@ -24,3 +24,14 @@ import { abortableSource } from 'abortable-iterator'; | ||
} | ||
const remoteAddr = options.remoteAddr ?? toMultiaddr(socket.remoteAddress ?? '', socket.remotePort ?? ''); | ||
let remoteAddr; | ||
if (options.remoteAddr != null) { | ||
remoteAddr = options.remoteAddr; | ||
} | ||
else { | ||
if (socket.remoteAddress == null || socket.remotePort == null) { | ||
// this can be undefined if the socket is destroyed (for example, if the client disconnected) | ||
// https://nodejs.org/dist/latest-v16.x/docs/api/net.html#socketremoteaddress | ||
throw errCode(new Error('Could not determine remote address or port'), 'ERR_NO_REMOTE_ADDRESS'); | ||
} | ||
remoteAddr = toMultiaddr(socket.remoteAddress, socket.remotePort); | ||
} | ||
const { host, port } = remoteAddr.toOptions(); | ||
@@ -27,0 +38,0 @@ const { sink, source } = toIterable.duplex(socket); |
{ | ||
"name": "@libp2p/tcp", | ||
"version": "3.0.5", | ||
"version": "3.0.6", | ||
"description": "Node.js implementation of the TCP module that libp2p uses, which implements the interface-connection and interface-transport interfaces", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0 OR MIT", |
@@ -52,2 +52,3 @@ import net from 'net' | ||
const socket = await this._connect(ma, options) | ||
socket.setKeepAlive(true) | ||
@@ -54,0 +55,0 @@ // Avoid uncaught errors caused by unstable connections |
@@ -51,2 +51,4 @@ import net from 'net' | ||
const server: ServerWithMultiaddrConnections = Object.assign(net.createServer(socket => { | ||
socket.setKeepAlive(true) | ||
// Avoid uncaught errors caused by unstable connections | ||
@@ -53,0 +55,0 @@ socket.on('error', err => { |
@@ -41,3 +41,16 @@ import { abortableSource } from 'abortable-iterator' | ||
const remoteAddr = options.remoteAddr ?? toMultiaddr(socket.remoteAddress ?? '', socket.remotePort ?? '') | ||
let remoteAddr: Multiaddr | ||
if (options.remoteAddr != null) { | ||
remoteAddr = options.remoteAddr | ||
} else { | ||
if (socket.remoteAddress == null || socket.remotePort == null) { | ||
// this can be undefined if the socket is destroyed (for example, if the client disconnected) | ||
// https://nodejs.org/dist/latest-v16.x/docs/api/net.html#socketremoteaddress | ||
throw errCode(new Error('Could not determine remote address or port'), 'ERR_NO_REMOTE_ADDRESS') | ||
} | ||
remoteAddr = toMultiaddr(socket.remoteAddress, socket.remotePort) | ||
} | ||
const { host, port } = remoteAddr.toOptions() | ||
@@ -44,0 +57,0 @@ const { sink, source } = toIterable.duplex(socket) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64671
982