@pmtuan0206/n8n-nodes-netproxy-cur 0.1.0 → 0.1.1
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.
|
@@ -56,29 +56,41 @@ function selectProxy(proxies, strategy, staticData) {
|
|
|
56
56
|
return proxies[0];
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
function createProxyAgent(proxy) {
|
|
59
|
+
function createProxyAgent(proxy, targetUrl) {
|
|
60
60
|
const proxyUrl = proxy.auth
|
|
61
61
|
? `${proxy.protocol}://${proxy.auth.username}:${proxy.auth.password}@${proxy.host}:${proxy.port}`
|
|
62
62
|
: `${proxy.protocol}://${proxy.host}:${proxy.port}`;
|
|
63
|
+
// Determine if target URL is HTTPS
|
|
64
|
+
const isHttpsTarget = targetUrl ? targetUrl.startsWith('https://') : true;
|
|
63
65
|
if (proxy.protocol === 'socks5') {
|
|
64
66
|
return new socks_proxy_agent_1.SocksProxyAgent(proxyUrl);
|
|
65
67
|
}
|
|
66
68
|
else if (proxy.protocol === 'https') {
|
|
69
|
+
// HTTPS proxy - use HttpsProxyAgent from hpagent
|
|
67
70
|
return new hpagent_1.HttpsProxyAgent({
|
|
68
71
|
proxy: proxyUrl,
|
|
69
72
|
});
|
|
70
73
|
}
|
|
71
74
|
else {
|
|
72
75
|
// HTTP proxy
|
|
73
|
-
|
|
74
|
-
proxy
|
|
75
|
-
|
|
76
|
+
if (isHttpsTarget) {
|
|
77
|
+
// For HTTPS target through HTTP proxy, use HttpsProxyAgent to tunnel HTTPS
|
|
78
|
+
return new hpagent_1.HttpsProxyAgent({
|
|
79
|
+
proxy: proxyUrl,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
// For HTTP target through HTTP proxy
|
|
84
|
+
return new hpagent_1.HttpProxyAgent({
|
|
85
|
+
proxy: proxyUrl,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
76
88
|
}
|
|
77
89
|
}
|
|
78
90
|
async function testConnection(proxies, rotationStrategy, staticData) {
|
|
79
91
|
const selectedProxy = selectProxy(proxies, rotationStrategy, staticData);
|
|
80
|
-
const agent = createProxyAgent(selectedProxy);
|
|
81
92
|
const testUrl = 'https://api.ipify.org?format=json';
|
|
93
|
+
const agent = createProxyAgent(selectedProxy, testUrl);
|
|
82
94
|
try {
|
|
83
95
|
const response = await axios_1.default.get(testUrl, {
|
|
84
96
|
httpsAgent: agent,
|
|
@@ -96,7 +108,7 @@ async function testConnection(proxies, rotationStrategy, staticData) {
|
|
|
96
108
|
if (rotationStrategy === 'failover' && proxies.length > 1) {
|
|
97
109
|
// Try next proxy
|
|
98
110
|
const nextProxy = selectProxy(proxies, 'roundRobin', staticData);
|
|
99
|
-
const nextAgent = createProxyAgent(nextProxy);
|
|
111
|
+
const nextAgent = createProxyAgent(nextProxy, testUrl);
|
|
100
112
|
try {
|
|
101
113
|
const response = await axios_1.default.get(testUrl, {
|
|
102
114
|
httpsAgent: nextAgent,
|
|
@@ -169,11 +181,18 @@ async function makeRequest(executeFunctions, itemIndex, proxies, rotationStrateg
|
|
|
169
181
|
config.data = formData;
|
|
170
182
|
}
|
|
171
183
|
}
|
|
172
|
-
// Select proxy and create agent
|
|
184
|
+
// Select proxy and create agent based on target URL protocol
|
|
173
185
|
let selectedProxy = selectProxy(proxies, rotationStrategy, staticData);
|
|
174
|
-
let agent = createProxyAgent(selectedProxy);
|
|
175
|
-
|
|
176
|
-
|
|
186
|
+
let agent = createProxyAgent(selectedProxy, url);
|
|
187
|
+
// Set agents based on URL protocol
|
|
188
|
+
if (url.startsWith('https://')) {
|
|
189
|
+
config.httpsAgent = agent;
|
|
190
|
+
config.httpAgent = agent; // Also set for potential redirects
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
config.httpAgent = agent;
|
|
194
|
+
config.httpsAgent = agent; // Also set for potential redirects
|
|
195
|
+
}
|
|
177
196
|
// Make request with failover logic
|
|
178
197
|
const maxRetries = rotationStrategy === 'failover' ? proxies.length : 1;
|
|
179
198
|
let lastError = null;
|
|
@@ -200,9 +219,15 @@ async function makeRequest(executeFunctions, itemIndex, proxies, rotationStrateg
|
|
|
200
219
|
if (rotationStrategy === 'failover' && attempt < maxRetries - 1) {
|
|
201
220
|
// Try next proxy
|
|
202
221
|
selectedProxy = selectProxy(proxies, 'roundRobin', staticData);
|
|
203
|
-
agent = createProxyAgent(selectedProxy);
|
|
204
|
-
|
|
205
|
-
|
|
222
|
+
agent = createProxyAgent(selectedProxy, url);
|
|
223
|
+
if (url.startsWith('https://')) {
|
|
224
|
+
config.httpsAgent = agent;
|
|
225
|
+
config.httpAgent = agent;
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
config.httpAgent = agent;
|
|
229
|
+
config.httpsAgent = agent;
|
|
230
|
+
}
|
|
206
231
|
continue;
|
|
207
232
|
}
|
|
208
233
|
else if (rotationStrategy === 'stopOnDead') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pmtuan0206/n8n-nodes-netproxy-cur",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Route HTTP requests through NetProxy.io residential proxies with auto-rotation and failover",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node",
|
|
@@ -56,4 +56,3 @@
|
|
|
56
56
|
"socks-proxy-agent": "^8.0.2"
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
|