channel-worker 1.1.7 → 1.1.9
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/bin/cli.js +0 -10
- package/lib/api-client.js +0 -4
- package/lib/command-poller.js +2 -4
- package/lib/daemon.js +0 -13
- package/lib/job-executor.js +3 -4
- package/lib/nst-manager.js +18 -4
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -58,7 +58,6 @@ if (cmd === 'pair') {
|
|
|
58
58
|
headers: { 'Content-Type': 'application/json' },
|
|
59
59
|
body: JSON.stringify({
|
|
60
60
|
code,
|
|
61
|
-
ip_address: getLocalIP(),
|
|
62
61
|
max_concurrent: maxConcurrent,
|
|
63
62
|
}),
|
|
64
63
|
});
|
|
@@ -163,12 +162,3 @@ Examples:
|
|
|
163
162
|
`);
|
|
164
163
|
}
|
|
165
164
|
|
|
166
|
-
function getLocalIP() {
|
|
167
|
-
const interfaces = os.networkInterfaces();
|
|
168
|
-
for (const name of Object.keys(interfaces)) {
|
|
169
|
-
for (const iface of interfaces[name]) {
|
|
170
|
-
if (iface.family === 'IPv4' && !iface.internal) return iface.address;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return '127.0.0.1';
|
|
174
|
-
}
|
package/lib/api-client.js
CHANGED
|
@@ -54,10 +54,6 @@ class ApiClient {
|
|
|
54
54
|
return this.request('GET', `/channels/${channelId}`);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
async getMasterChannel(masterId) {
|
|
58
|
-
return this.request('GET', `/masters/${masterId}`);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
57
|
// Settings
|
|
62
58
|
async getSetting(key) {
|
|
63
59
|
const data = await this.request('GET', `/settings/${key}`);
|
package/lib/command-poller.js
CHANGED
|
@@ -125,15 +125,13 @@ class CommandPoller {
|
|
|
125
125
|
extensionPath = uniqueExtPath;
|
|
126
126
|
console.log(`[commands] Extension dir: ${uniqueExtPath}`);
|
|
127
127
|
|
|
128
|
-
// Cleanup old dirs (keep
|
|
128
|
+
// Cleanup ALL old dirs (only keep current)
|
|
129
129
|
const parent = path.dirname(baseExtPath);
|
|
130
130
|
const baseName = path.basename(baseExtPath);
|
|
131
131
|
const oldDirs = fs.readdirSync(parent)
|
|
132
132
|
.filter(d => d.startsWith(baseName + '-') && d !== path.basename(uniqueExtPath))
|
|
133
133
|
.map(d => path.join(parent, d))
|
|
134
|
-
.filter(d => fs.statSync(d).isDirectory())
|
|
135
|
-
.sort()
|
|
136
|
-
.slice(0, -3);
|
|
134
|
+
.filter(d => { try { return fs.statSync(d).isDirectory(); } catch { return false; } });
|
|
137
135
|
for (const d of oldDirs) {
|
|
138
136
|
try { fs.rmSync(d, { recursive: true }); } catch {}
|
|
139
137
|
}
|
package/lib/daemon.js
CHANGED
|
@@ -2,7 +2,6 @@ const { ApiClient } = require('./api-client');
|
|
|
2
2
|
const { Heartbeat } = require('./heartbeat');
|
|
3
3
|
const { JobPoller } = require('./job-poller');
|
|
4
4
|
const { CommandPoller } = require('./command-poller');
|
|
5
|
-
const os = require('os');
|
|
6
5
|
|
|
7
6
|
class Daemon {
|
|
8
7
|
constructor(config) {
|
|
@@ -29,7 +28,6 @@ class Daemon {
|
|
|
29
28
|
await this.api.register({
|
|
30
29
|
worker_id: this.config.worker_id,
|
|
31
30
|
name: this.config.worker_id,
|
|
32
|
-
ip_address: this.getLocalIP(),
|
|
33
31
|
max_concurrent: this.config.max_concurrent,
|
|
34
32
|
});
|
|
35
33
|
console.log('[daemon] Registered with dashboard ✓');
|
|
@@ -75,17 +73,6 @@ class Daemon {
|
|
|
75
73
|
process.on('SIGTERM', shutdown);
|
|
76
74
|
}
|
|
77
75
|
|
|
78
|
-
getLocalIP() {
|
|
79
|
-
const interfaces = os.networkInterfaces();
|
|
80
|
-
for (const name of Object.keys(interfaces)) {
|
|
81
|
-
for (const iface of interfaces[name]) {
|
|
82
|
-
if (iface.family === 'IPv4' && !iface.internal) {
|
|
83
|
-
return iface.address;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return '127.0.0.1';
|
|
88
|
-
}
|
|
89
76
|
}
|
|
90
77
|
|
|
91
78
|
module.exports = { Daemon };
|
package/lib/job-executor.js
CHANGED
|
@@ -9,13 +9,12 @@ class JobExecutor {
|
|
|
9
9
|
console.log(`[executor] Starting job ${jobId} — ${job.flow_type} for channel ${job.channel_id}`);
|
|
10
10
|
|
|
11
11
|
try {
|
|
12
|
-
// 1. Get channel
|
|
12
|
+
// 1. Get channel info
|
|
13
13
|
await this.updateStatus(jobId, 'sourcing');
|
|
14
14
|
const channel = await this.api.getChannel(job.channel_id);
|
|
15
|
-
const
|
|
16
|
-
const brandKit = master.brand_kit || {};
|
|
15
|
+
const brandKit = channel.brand_kit || {};
|
|
17
16
|
|
|
18
|
-
console.log(`[executor] Channel: ${channel.name} |
|
|
17
|
+
console.log(`[executor] Channel: ${channel.name} | Profile: ${channel.nst_profile_id}`);
|
|
19
18
|
|
|
20
19
|
// 2. Launch Nstbrowser profile
|
|
21
20
|
if (channel.nst_profile_id) {
|
package/lib/nst-manager.js
CHANGED
|
@@ -88,6 +88,7 @@ class NstManager {
|
|
|
88
88
|
},
|
|
89
89
|
hardwareConcurrency: 8,
|
|
90
90
|
deviceMemory: 8,
|
|
91
|
+
language: 'en-US',
|
|
91
92
|
},
|
|
92
93
|
});
|
|
93
94
|
|
|
@@ -119,6 +120,15 @@ class NstManager {
|
|
|
119
120
|
return { profileId, alreadyRunning: true };
|
|
120
121
|
}
|
|
121
122
|
|
|
123
|
+
// Ensure profile language is en-US to prevent auto-translate
|
|
124
|
+
try {
|
|
125
|
+
await this.client.profiles().updateProfile(profileId, {
|
|
126
|
+
fingerprint: { language: 'en-US' },
|
|
127
|
+
});
|
|
128
|
+
} catch (err) {
|
|
129
|
+
console.warn(`[nst] Could not update profile language:`, err.message);
|
|
130
|
+
}
|
|
131
|
+
|
|
122
132
|
// Set proxy before launch
|
|
123
133
|
if (options.proxy) {
|
|
124
134
|
await this.setProxy(profileId, options.proxy);
|
|
@@ -129,11 +139,15 @@ class NstManager {
|
|
|
129
139
|
autoClose: false,
|
|
130
140
|
};
|
|
131
141
|
|
|
142
|
+
// Disable Chrome auto-translate
|
|
143
|
+
connectConfig.args = {
|
|
144
|
+
'--lang': 'en-US',
|
|
145
|
+
'--disable-features': 'Translate',
|
|
146
|
+
};
|
|
147
|
+
|
|
132
148
|
if (options.extensionPath) {
|
|
133
|
-
connectConfig.args =
|
|
134
|
-
|
|
135
|
-
'--disable-extensions-except': options.extensionPath,
|
|
136
|
-
};
|
|
149
|
+
connectConfig.args['--load-extension'] = options.extensionPath;
|
|
150
|
+
connectConfig.args['--disable-extensions-except'] = options.extensionPath;
|
|
137
151
|
console.log(`[nst] Loading extension: ${options.extensionPath}`);
|
|
138
152
|
}
|
|
139
153
|
|