tunli 0.0.25 → 0.0.26
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/README.md +2 -0
- package/package.json +6 -6
- package/src/lib/Flow/proxyUrl.js +5 -2
- package/src/lib/defs.js +4 -1
- package/src/utils/stringFunctions.js +25 -0
package/README.md
CHANGED
|
@@ -126,6 +126,8 @@ Tunli relies on the following packages:
|
|
|
126
126
|
|
|
127
127
|
For development purposes, you can start the application using nodemon to automatically restart it on file changes:
|
|
128
128
|
|
|
129
|
+
_$ TUNLI_API_SERVER_URL=http://127.0.0.1:10000/api TUNLI_DASHBOARD=off TUNLI_SERVER=http://127.0.0.1:10000 TUNLI_PROXY_URL='http://127.0.0.1:10000/proxy/{{ uuid }}' node client.js register -f
|
|
130
|
+
|
|
129
131
|
```bash
|
|
130
132
|
npm run dev
|
|
131
133
|
```
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tunli",
|
|
3
3
|
"description": "Node.js application for creating HTTP tunnels to make local software projects accessible over the internet.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.26",
|
|
5
5
|
"main": "bin/tunli",
|
|
6
6
|
"bin": {
|
|
7
7
|
"tunli": "bin/tunli"
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
},
|
|
25
25
|
"type": "module",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"axios": "^1.
|
|
27
|
+
"axios": "^1.11.0",
|
|
28
28
|
"blessed": "^0.1.81",
|
|
29
|
-
"chalk": "^5.
|
|
30
|
-
"commander": "^
|
|
31
|
-
"socket.io-client": "^4.
|
|
29
|
+
"chalk": "^5.5.0",
|
|
30
|
+
"commander": "^14.0.0",
|
|
31
|
+
"socket.io-client": "^4.8.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"nodemon": "^3.1.
|
|
34
|
+
"nodemon": "^3.1.10"
|
|
35
35
|
},
|
|
36
36
|
"repository": {
|
|
37
37
|
"type": "git",
|
package/src/lib/Flow/proxyUrl.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {securedHttpClient} from "#lib/HttpClient";
|
|
2
|
-
import {
|
|
2
|
+
import {TUNLI_PROXY_URL} from "#lib/defs";
|
|
3
|
+
import {replaceTemplatePlaceholders} from "#src/utils/stringFunctions";
|
|
3
4
|
|
|
4
5
|
export const requestNewProxyUrl = async (token) => {
|
|
5
6
|
|
|
@@ -10,7 +11,9 @@ export const requestNewProxyUrl = async (token) => {
|
|
|
10
11
|
process.exit(1)
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
return
|
|
14
|
+
return replaceTemplatePlaceholders(TUNLI_PROXY_URL, {
|
|
15
|
+
uuid: data
|
|
16
|
+
})
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
export const renewProxyUrlRegistration = async (proxyUrl, token) => {
|
package/src/lib/defs.js
CHANGED
|
@@ -2,9 +2,12 @@ import {resolve} from "path";
|
|
|
2
2
|
import {homedir} from "os";
|
|
3
3
|
|
|
4
4
|
export const SERVER_HOST = 'tunli.app'
|
|
5
|
+
|
|
6
|
+
export const TUNLI_PROXY_URL = process.env.TUNLI_PROXY_URL ?? 'https://{{ uuid }}.tunli.app'
|
|
7
|
+
|
|
5
8
|
export const CONFIG_DIR_NAME = '.tunli'
|
|
6
9
|
|
|
7
|
-
export const AUTH_SERVER_URL = 'https://api.tunli.app'
|
|
10
|
+
export const AUTH_SERVER_URL = process.env.TUNLI_API_SERVER_URL ?? 'https://api.tunli.app'
|
|
8
11
|
|
|
9
12
|
export const GLOBAL_CONFIG_DIR = resolve(homedir(), CONFIG_DIR_NAME);
|
|
10
13
|
export const CONFIG_FILENAME = 'default.json'
|
|
@@ -32,3 +32,28 @@ export const padEndIgnoreControlChars = (string, maxLength, fillString = ' ', au
|
|
|
32
32
|
const padding = ''.padEnd(maxLength - stringWithoutCC.length, fillString)
|
|
33
33
|
return `${string}${padding}`
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Replaces template placeholders in a string with corresponding values from a replacements object.
|
|
38
|
+
*
|
|
39
|
+
* @param {string} template - The string containing placeholders in the format {{ placeholder }}.
|
|
40
|
+
* @param {object} replacements - The object containing replacement values. Nested placeholders can be accessed using dot notation.
|
|
41
|
+
*/
|
|
42
|
+
export const replaceTemplatePlaceholders = (template, replacements) => {
|
|
43
|
+
|
|
44
|
+
return template.replace(/{{\s*([^{}|]+)\s*(\|[^{}]+)*\s*}}/ig, (match, placeholder) => {
|
|
45
|
+
|
|
46
|
+
placeholder = placeholder.trim()
|
|
47
|
+
const keys = placeholder.split('.')
|
|
48
|
+
|
|
49
|
+
let value = replacements
|
|
50
|
+
for (const part of keys) {
|
|
51
|
+
if (!value) {
|
|
52
|
+
break
|
|
53
|
+
}
|
|
54
|
+
value = value [part]
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return value ?? ''
|
|
58
|
+
})
|
|
59
|
+
}
|