sandboxedjs 0.1.73 → 0.1.75

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.
@@ -1,6 +1,6 @@
1
- import { V as Vfs, C as Cred, a as VirtualTcpNetwork } from './contracts-CVgctitO.cjs';
2
- export { m as ROOT_CRED, v as makeCred } from './contracts-CVgctitO.cjs';
3
- export { M as MemoryVolume } from './memory-volume-DlMSAh-K.cjs';
1
+ import { V as Vfs, C as Cred, a as VirtualTcpNetwork } from './contracts-C2_dTgk3.cjs';
2
+ export { m as ROOT_CRED, v as makeCred } from './contracts-C2_dTgk3.cjs';
3
+ export { M as MemoryVolume } from './memory-volume-DqEWFo7t.cjs';
4
4
 
5
5
  /**
6
6
  * Open-file descriptions: the thing a descriptor points *at*.
@@ -1,6 +1,6 @@
1
- import { V as Vfs, C as Cred, a as VirtualTcpNetwork } from './contracts-CVgctitO.js';
2
- export { m as ROOT_CRED, v as makeCred } from './contracts-CVgctitO.js';
3
- export { M as MemoryVolume } from './memory-volume-CWuWScIs.js';
1
+ import { V as Vfs, C as Cred, a as VirtualTcpNetwork } from './contracts-C2_dTgk3.js';
2
+ export { m as ROOT_CRED, v as makeCred } from './contracts-C2_dTgk3.js';
3
+ export { M as MemoryVolume } from './memory-volume-CG56p660.js';
4
4
 
5
5
  /**
6
6
  * Open-file descriptions: the thing a descriptor points *at*.
@@ -1137,6 +1137,12 @@ var VirtualTcpSocket = class _VirtualTcpSocket {
1137
1137
  }
1138
1138
  connect(port, address = "127.0.0.1") {
1139
1139
  if (this.listenerValue || this.connectionValue) throw new PosixError(Errno.EISCONN);
1140
+ if (!isLoopback(address)) {
1141
+ throw new PosixError(
1142
+ Errno.ENETUNREACH,
1143
+ `cannot reach ${address}:${port}: outbound network access is not available through raw sockets in this container; only loopback is routed`
1144
+ );
1145
+ }
1140
1146
  this.connectionValue = this.network.connect(port, this.boundPort, this.boundAddress);
1141
1147
  this.boundPort = this.connectionValue.local.port;
1142
1148
  this.boundAddress = this.connectionValue.local.address;
@@ -1273,6 +1279,11 @@ var SocketDescription = class _SocketDescription {
1273
1279
  return peer;
1274
1280
  }
1275
1281
  };
1282
+ function isLoopback(address) {
1283
+ if (address === "" || address === "localhost" || address === "0.0.0.0") return true;
1284
+ if (address === "::1" || address === "::" || address === "[::1]") return true;
1285
+ return /^127\./.test(address);
1286
+ }
1276
1287
 
1277
1288
  // src/python/syscall-server.ts
1278
1289
  var MAX_TRANSFER = 8 * 1024 * 1024;
@@ -1981,6 +1992,7 @@ var ERRNO = {
1981
1992
  ECONNRESET: 104,
1982
1993
  ENOTCONN: 107,
1983
1994
  ETIMEDOUT: 110,
1995
+ ENETUNREACH: 101,
1984
1996
  ECONNREFUSED: 111,
1985
1997
  EHOSTUNREACH: 113,
1986
1998
  ENOTSUP: 95
@@ -2034,6 +2046,7 @@ var STRERROR = {
2034
2046
  ECONNRESET: "Connection reset by peer",
2035
2047
  ENOTCONN: "Transport endpoint is not connected",
2036
2048
  ETIMEDOUT: "Connection timed out",
2049
+ ENETUNREACH: "Network is unreachable",
2037
2050
  ECONNREFUSED: "Connection refused",
2038
2051
  EHOSTUNREACH: "No route to host",
2039
2052
  ENOTSUP: "Operation not supported"