channel-worker 1.6.18 → 1.7.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.
Files changed (2) hide show
  1. package/lib/nst-manager.js +15 -33
  2. package/package.json +1 -1
@@ -117,33 +117,21 @@ class NstManager {
117
117
  async setProxy(profileId, proxyUrl) {
118
118
  if (!proxyUrl) return;
119
119
  console.log(`[nst] Setting proxy for ${profileId}: ${proxyUrl}`);
120
- // Parse proxy URL: protocol://user:pass@host:port
121
- const parsed = new URL(proxyUrl);
122
- const proxyConfig = {
123
- proxy: {
124
- type: parsed.protocol.replace(':', '').replace('socks5', 'socks5'), // http, https, socks5
125
- host: parsed.hostname,
126
- port: parsed.port,
127
- ...(parsed.username && { username: decodeURIComponent(parsed.username) }),
128
- ...(parsed.password && { password: decodeURIComponent(parsed.password) }),
129
- },
130
- };
131
- // Try PATCH first, fallback to PUT
132
- for (const method of ['PATCH', 'PUT']) {
133
- try {
134
- const res = await fetch(`${this.baseUrl}/profiles/${profileId}`, {
135
- method,
136
- headers: { 'Content-Type': 'application/json', 'x-api-key': this.apiKey },
137
- body: JSON.stringify(proxyConfig),
138
- });
139
- const text = await res.text();
140
- console.log(`[nst] setProxy ${method} ${res.status}: ${text.substring(0, 200)}`);
141
- if (res.ok) { console.log(`[nst] Proxy saved to profile (${method})`); return; }
142
- } catch (e) {
143
- console.warn(`[nst] setProxy ${method} error: ${e.message}`);
120
+ try {
121
+ const res = await fetch(`${this.baseUrl}/profiles/${profileId}/proxy`, {
122
+ method: 'PUT',
123
+ headers: { 'Content-Type': 'application/json', 'x-api-key': this.apiKey },
124
+ body: JSON.stringify({ url: proxyUrl }),
125
+ });
126
+ const text = await res.text();
127
+ if (res.ok) {
128
+ console.log(`[nst] Proxy saved to profile`);
129
+ } else {
130
+ console.warn(`[nst] setProxy failed ${res.status}: ${text.substring(0, 200)}`);
144
131
  }
132
+ } catch (e) {
133
+ console.warn(`[nst] setProxy error: ${e.message}`);
145
134
  }
146
- console.warn(`[nst] Failed to save proxy to profile — will still use at launch time`);
147
135
  }
148
136
 
149
137
  // Launch browser — skip if already running, set proxy if provided
@@ -165,14 +153,8 @@ class NstManager {
165
153
  console.log(`[nst] Running browsers: ${running.map(b => b.name || b.profileId).join(', ') || 'none'}`);
166
154
  const isRunning = running.some(b => b.profileId === profileId);
167
155
  if (isRunning) {
168
- console.log(`[nst] Profile ${profileId} already running — stopping first`);
169
- try {
170
- await this.stopProfile(profileId);
171
- console.log(`[nst] Stop command sent, waiting 3s...`);
172
- await new Promise(r => setTimeout(r, 3000));
173
- } catch (e) {
174
- console.warn(`[nst] Stop failed: ${e.message} — continuing anyway`);
175
- }
156
+ console.log(`[nst] Profile ${profileId} already running — skipping launch`);
157
+ return { profileId, alreadyRunning: true };
176
158
  }
177
159
 
178
160
  // Update profile language to en-US (Custom) before launch
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "channel-worker",
3
- "version": "1.6.18",
3
+ "version": "1.7.0",
4
4
  "description": "Channel Manager worker daemon — runs on remote machines to execute video pipeline jobs",
5
5
  "main": "lib/daemon.js",
6
6
  "bin": {