socket-function 0.25.0 → 0.27.0
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/package.json
CHANGED
package/src/forwardPort.ts
CHANGED
|
@@ -72,7 +72,7 @@ function getLocalInterfaceAddress(): { internalIP: string; gatewayIP: string; }
|
|
|
72
72
|
let gatewayMatch: RegExpMatchArray | undefined;
|
|
73
73
|
try {
|
|
74
74
|
// Attempt to get the gateway using "ip route" command (more universal)
|
|
75
|
-
const routeOutput = require("child_process")("ip route show default").toString();
|
|
75
|
+
const routeOutput = require("child_process").execSync("ip route show default").toString();
|
|
76
76
|
gatewayMatch = routeOutput.match(/default via (\d+\.\d+\.\d+\.\d+)/);
|
|
77
77
|
} catch (err) {
|
|
78
78
|
console.error("Failed to execute 'ip route show default', trying fallback", err);
|
|
@@ -81,7 +81,7 @@ function getLocalInterfaceAddress(): { internalIP: string; gatewayIP: string; }
|
|
|
81
81
|
if (!gatewayMatch) {
|
|
82
82
|
try {
|
|
83
83
|
// Fallback to "netstat -rn" for older systems
|
|
84
|
-
const netstatOutput = require("child_process")("netstat -rn").toString();
|
|
84
|
+
const netstatOutput = require("child_process").execSync("netstat -rn").toString();
|
|
85
85
|
gatewayMatch = netstatOutput.match(/default\s+(\d+\.\d+\.\d+\.\d+)/);
|
|
86
86
|
} catch (err) {
|
|
87
87
|
console.error("Failed to execute 'netstat -rn', unable to find gateway", err);
|
|
@@ -91,7 +91,7 @@ function getLocalInterfaceAddress(): { internalIP: string; gatewayIP: string; }
|
|
|
91
91
|
if (gatewayMatch) {
|
|
92
92
|
try {
|
|
93
93
|
// Use "ip addr" to get internal IP (more universal)
|
|
94
|
-
const ipOutput = require("child_process")("ip addr").toString();
|
|
94
|
+
const ipOutput = require("child_process").execSync("ip addr").toString();
|
|
95
95
|
const ipMatch = ipOutput.match(/inet (?!127\.0\.0\.1)(\d+\.\d+\.\d+\.\d+)\//);
|
|
96
96
|
|
|
97
97
|
if (ipMatch) {
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import debugbreak from "debugbreak";
|
|
2
|
+
import { isNode } from "../misc";
|
|
2
3
|
// TODO: We could probably make this an optional / dev dependency, to allow
|
|
3
4
|
// for use on machines without the ability to compile?
|
|
4
|
-
import { now } from "rdtsc-now";
|
|
5
|
+
//import { now } from "rdtsc-now";
|
|
6
|
+
let now = () => Date.now();
|
|
7
|
+
if (isNode()) {
|
|
8
|
+
now = () => performance.now();
|
|
9
|
+
}
|
|
5
10
|
|
|
6
11
|
export type OwnTimeObj = {
|
|
7
12
|
name: string;
|