@nora-link/client 1.0.4 → 1.0.5
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/cli.js +23 -25
- package/package.json +1 -1
- package/src/cli.ts +23 -25
package/dist/cli.js
CHANGED
|
@@ -11,8 +11,8 @@ commander_1.program
|
|
|
11
11
|
.usage('[OPTIONS]...')
|
|
12
12
|
.option('-d, --debug', 'output extra debugging', false)
|
|
13
13
|
.option('-n, --non-secure', 'don\'t use secure connection', false)
|
|
14
|
-
.option('-l, --log', `min log level to display. Options: ${logger_1.LOG_LEVEL.join(',')}`, (value, previous) => {
|
|
15
|
-
const v = value
|
|
14
|
+
.option('-l, --log <log-level>', `min log level to display. Options: ${logger_1.LOG_LEVEL.join(',')}`, (value, previous) => {
|
|
15
|
+
const v = value?.toLowerCase();
|
|
16
16
|
if (logger_1.LOG_LEVEL.includes(v)) {
|
|
17
17
|
return v;
|
|
18
18
|
}
|
|
@@ -25,29 +25,27 @@ commander_1.program
|
|
|
25
25
|
.addHelpText('afterAll', 'To tunnel an ip to the subdomain `test`, you can use `-f test|192.168.1.130`')
|
|
26
26
|
.parse();
|
|
27
27
|
const options = commander_1.program.opts();
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
-
}
|
|
28
|
+
const forward = Array.isArray(options.forward) ? options.forward : [options.forward];
|
|
29
|
+
const tunnels = forward
|
|
30
|
+
.filter((v) => typeof v === 'string')
|
|
31
|
+
.map(v => {
|
|
32
|
+
const [segment, labelOrUrl, urlPart] = v.split('|');
|
|
33
|
+
let toUrl;
|
|
34
|
+
const label = urlPart ? labelOrUrl : segment;
|
|
35
|
+
const url = urlPart ?? labelOrUrl;
|
|
36
|
+
if (/^https?:\/\//.test(url)) {
|
|
37
|
+
toUrl = url;
|
|
38
|
+
}
|
|
39
|
+
else if (url.startsWith(':')) {
|
|
40
|
+
//only port specified
|
|
41
|
+
const port = +url.split(':')[1];
|
|
42
|
+
toUrl = `http://127.0.0.1:${port}`;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
toUrl = `http://${url}`;
|
|
46
|
+
}
|
|
47
|
+
return { remotePath: segment, localUrl: toUrl, label };
|
|
48
|
+
});
|
|
51
49
|
new client_1.Client({
|
|
52
50
|
agent: `${name}@${version}`,
|
|
53
51
|
hostname: options.host,
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -12,8 +12,8 @@ program
|
|
|
12
12
|
.usage('[OPTIONS]...')
|
|
13
13
|
.option('-d, --debug', 'output extra debugging', false)
|
|
14
14
|
.option('-n, --non-secure', 'don\'t use secure connection', false)
|
|
15
|
-
.option<LogLevel>('-l, --log', `min log level to display. Options: ${LOG_LEVEL.join(',')}`, (value, previous) => {
|
|
16
|
-
const v = value
|
|
15
|
+
.option<LogLevel>('-l, --log <log-level>', `min log level to display. Options: ${LOG_LEVEL.join(',')}`, (value, previous) => {
|
|
16
|
+
const v = value?.toLowerCase() as LogLevel;
|
|
17
17
|
if (LOG_LEVEL.includes(v)) {
|
|
18
18
|
return v;
|
|
19
19
|
}
|
|
@@ -28,30 +28,28 @@ program
|
|
|
28
28
|
|
|
29
29
|
const options = program.opts();
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
31
|
+
const forward = Array.isArray(options.forward) ? options.forward : [options.forward];
|
|
32
|
+
const tunnels: ClientConnectionOptions['tunnels'] = forward
|
|
33
|
+
.filter((v): v is string => typeof v === 'string')
|
|
34
|
+
.map(v => {
|
|
35
|
+
const [segment, labelOrUrl, urlPart] = v.split('|');
|
|
36
|
+
let toUrl: string;
|
|
37
|
+
|
|
38
|
+
const label = urlPart ? labelOrUrl : segment;
|
|
39
|
+
const url = urlPart ?? labelOrUrl;
|
|
40
|
+
|
|
41
|
+
if (/^https?:\/\//.test(url)) {
|
|
42
|
+
toUrl = url;
|
|
43
|
+
} else if (url.startsWith(':')) {
|
|
44
|
+
//only port specified
|
|
45
|
+
const port = +url.split(':')[1];
|
|
46
|
+
toUrl = `http://127.0.0.1:${port}`;
|
|
47
|
+
} else {
|
|
48
|
+
toUrl = `http://${url}`;
|
|
49
|
+
}
|
|
51
50
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
51
|
+
return { remotePath: segment, localUrl: toUrl, label };
|
|
52
|
+
});
|
|
55
53
|
|
|
56
54
|
new Client({
|
|
57
55
|
agent: `${name}@${version}`,
|