@cloud-cli/px 4.4.2 → 4.4.3
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/proxy-manager.d.ts +4 -1
- package/dist/proxy-manager.js +30 -20
- package/package.json +2 -2
package/dist/proxy-manager.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ export declare class ProxyManager {
|
|
|
9
9
|
getProxyListWithContainers(): Promise<Proxy[]>;
|
|
10
10
|
getProxyList(filters?: Partial<Proxy>): Promise<Proxy[]>;
|
|
11
11
|
getProxyListForDomain(options: WithOptionalProps<DomainName>): Promise<Proxy[]>;
|
|
12
|
-
reload(
|
|
12
|
+
reload(options?: {
|
|
13
|
+
servers?: Boolean;
|
|
14
|
+
}): Promise<void>;
|
|
15
|
+
private loadProxy;
|
|
13
16
|
getRunningContainers(): Promise<DockerContainer[]>;
|
|
14
17
|
}
|
package/dist/proxy-manager.js
CHANGED
|
@@ -125,29 +125,39 @@ export class ProxyManager {
|
|
|
125
125
|
const all = await this.getProxyListWithContainers();
|
|
126
126
|
return all.filter((p) => p.domain.includes(options.domain));
|
|
127
127
|
}
|
|
128
|
-
async reload() {
|
|
128
|
+
async reload(options = {}) {
|
|
129
129
|
const all = await this.getProxyListWithContainers();
|
|
130
|
-
|
|
130
|
+
if (options.servers) {
|
|
131
|
+
px.reset();
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
px.resetProxies();
|
|
135
|
+
}
|
|
131
136
|
for (const t of all) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
137
|
+
this.loadProxy(t);
|
|
138
|
+
}
|
|
139
|
+
if (options.servers) {
|
|
140
|
+
px.start();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
loadProxy(t) {
|
|
144
|
+
try {
|
|
145
|
+
const [domain, path = ''] = t.domain.split('/');
|
|
146
|
+
px.add(new ProxyEntry({
|
|
147
|
+
domain,
|
|
148
|
+
path,
|
|
149
|
+
target: t.target,
|
|
150
|
+
redirectToHttps: t.redirect,
|
|
151
|
+
redirectToUrl: t.redirectUrl,
|
|
152
|
+
cors: t.cors,
|
|
153
|
+
headers: t.headers,
|
|
154
|
+
authorization: t.authorization,
|
|
155
|
+
preserveHost: t.preserveHost,
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
console.log(`Error adding proxy for ${t.domain}:`, error);
|
|
149
160
|
}
|
|
150
|
-
px.start();
|
|
151
161
|
}
|
|
152
162
|
async getRunningContainers() {
|
|
153
163
|
const ps = await exec('docker', ['ps', '-aq']);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloud-cli/px",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.3",
|
|
4
4
|
"description": "Reverse Proxy",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@cloud-cli/proxy": "^1.2.
|
|
31
|
+
"@cloud-cli/proxy": "^1.2.10",
|
|
32
32
|
"@cloud-cli/exec": "^1.2.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|