pyre-cli 3.10.0 → 3.12.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/dist/index.js +10 -3
- package/package.json +1 -1
- package/src/index.ts +5 -1
- package/src/p2p/client.ts +8 -2
package/dist/index.js
CHANGED
|
@@ -2359,11 +2359,12 @@ var P2PClient = class {
|
|
|
2359
2359
|
console.log(chalk7.yellow("Warning: could not open audit log"));
|
|
2360
2360
|
}
|
|
2361
2361
|
}
|
|
2362
|
+
const host = sanitizeHost(this.options.host);
|
|
2362
2363
|
return new Promise((resolve, reject) => {
|
|
2363
2364
|
const useTLS = !!this.options.tls;
|
|
2364
2365
|
if (useTLS) {
|
|
2365
2366
|
const tlsOptions = {
|
|
2366
|
-
host
|
|
2367
|
+
host,
|
|
2367
2368
|
port: this.options.port,
|
|
2368
2369
|
rejectUnauthorized: !this.options.tlsInsecure
|
|
2369
2370
|
};
|
|
@@ -2378,7 +2379,7 @@ var P2PClient = class {
|
|
|
2378
2379
|
} else {
|
|
2379
2380
|
this.socket = new net2.Socket();
|
|
2380
2381
|
this.socket.setTimeout(1e4);
|
|
2381
|
-
this.socket.connect(this.options.port,
|
|
2382
|
+
this.socket.connect(this.options.port, host, () => {
|
|
2382
2383
|
this.running = true;
|
|
2383
2384
|
this.status("Connected");
|
|
2384
2385
|
resolve();
|
|
@@ -2550,6 +2551,9 @@ var P2PClient = class {
|
|
|
2550
2551
|
`);
|
|
2551
2552
|
}
|
|
2552
2553
|
};
|
|
2554
|
+
function sanitizeHost(host) {
|
|
2555
|
+
return host.trim().replace(/%$/, "");
|
|
2556
|
+
}
|
|
2553
2557
|
function deriveHMACKey2(password) {
|
|
2554
2558
|
return crypto3.createHash("sha256").update(password).digest("hex").slice(0, 32);
|
|
2555
2559
|
}
|
|
@@ -3215,6 +3219,9 @@ function isExportMode() {
|
|
|
3215
3219
|
function stripAnsi(s) {
|
|
3216
3220
|
return s.replace(/\x1b\[[0-9;]*m/g, "");
|
|
3217
3221
|
}
|
|
3222
|
+
function sanitizeHost2(host) {
|
|
3223
|
+
return host.trim().replace(/%$/, "");
|
|
3224
|
+
}
|
|
3218
3225
|
async function main() {
|
|
3219
3226
|
const cmd = program.args[0];
|
|
3220
3227
|
if (cmd === "live" || !isExportMode() && !opts.once && cmd !== "p2p") {
|
|
@@ -3338,7 +3345,7 @@ async function runP2PServer() {
|
|
|
3338
3345
|
});
|
|
3339
3346
|
}
|
|
3340
3347
|
async function runP2PConnect() {
|
|
3341
|
-
const host = opts.p2pHost || "127.0.0.1";
|
|
3348
|
+
const host = sanitizeHost2(opts.p2pHost || "127.0.0.1");
|
|
3342
3349
|
const port = parseInt(opts.p2pPort, 10) || 9876;
|
|
3343
3350
|
const password = opts.p2pPassword || "";
|
|
3344
3351
|
const useTLS = !!opts.p2pTls;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -65,6 +65,10 @@ function stripAnsi(s: string): string {
|
|
|
65
65
|
return s.replace(/\x1b\[[0-9;]*m/g, '');
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
function sanitizeHost(host: string): string {
|
|
69
|
+
return host.trim().replace(/%$/, '');
|
|
70
|
+
}
|
|
71
|
+
|
|
68
72
|
async function main() {
|
|
69
73
|
const cmd = program.args[0];
|
|
70
74
|
|
|
@@ -205,7 +209,7 @@ async function runP2PServer(): Promise<void> {
|
|
|
205
209
|
}
|
|
206
210
|
|
|
207
211
|
async function runP2PConnect(): Promise<void> {
|
|
208
|
-
const host = opts.p2pHost || '127.0.0.1';
|
|
212
|
+
const host = sanitizeHost(opts.p2pHost || '127.0.0.1');
|
|
209
213
|
const port = parseInt(opts.p2pPort, 10) || 9876;
|
|
210
214
|
const password = opts.p2pPassword || '';
|
|
211
215
|
const useTLS = !!opts.p2pTls;
|
package/src/p2p/client.ts
CHANGED
|
@@ -50,12 +50,14 @@ export class P2PClient {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
const host = sanitizeHost(this.options.host);
|
|
54
|
+
|
|
53
55
|
return new Promise((resolve, reject) => {
|
|
54
56
|
const useTLS = !!this.options.tls;
|
|
55
57
|
|
|
56
58
|
if (useTLS) {
|
|
57
59
|
const tlsOptions: tls.ConnectionOptions = {
|
|
58
|
-
host
|
|
60
|
+
host,
|
|
59
61
|
port: this.options.port,
|
|
60
62
|
rejectUnauthorized: !this.options.tlsInsecure,
|
|
61
63
|
};
|
|
@@ -70,7 +72,7 @@ export class P2PClient {
|
|
|
70
72
|
} else {
|
|
71
73
|
this.socket = new net.Socket();
|
|
72
74
|
this.socket.setTimeout(10000);
|
|
73
|
-
this.socket.connect(this.options.port,
|
|
75
|
+
this.socket.connect(this.options.port, host, () => {
|
|
74
76
|
this.running = true;
|
|
75
77
|
this.status('Connected');
|
|
76
78
|
resolve();
|
|
@@ -266,6 +268,10 @@ export class P2PClient {
|
|
|
266
268
|
}
|
|
267
269
|
}
|
|
268
270
|
|
|
271
|
+
function sanitizeHost(host: string): string {
|
|
272
|
+
return host.trim().replace(/%$/, '');
|
|
273
|
+
}
|
|
274
|
+
|
|
269
275
|
function deriveHMACKey(password: string): string {
|
|
270
276
|
return crypto.createHash('sha256').update(password).digest('hex').slice(0, 32);
|
|
271
277
|
}
|