proxy-chain
Advanced tools
Comparing version 2.0.2-beta.5 to 2.0.2-beta.6
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import net from 'net'; | ||
@@ -20,3 +22,3 @@ import http from 'http'; | ||
*/ | ||
export declare const closeAnonymizedProxy: (anonymizedProxyUrl: string, closeConnections: boolean, callback?: ((error: Error | null, result?: boolean | undefined) => void) | undefined) => Promise<boolean>; | ||
export declare const closeAnonymizedProxy: (anonymizedProxyUrl: string, closeConnections: boolean, callback?: ((error: Error | null, result?: boolean) => void) | undefined) => Promise<boolean>; | ||
declare type Callback = ({ response, socket, head, }: { | ||
@@ -23,0 +25,0 @@ response: http.IncomingMessage; |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import dns from 'dns'; | ||
@@ -3,0 +6,0 @@ import { URL } from 'url'; |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import dns from 'dns'; | ||
@@ -3,0 +5,0 @@ import { Buffer } from 'buffer'; |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import dns from 'dns'; | ||
@@ -3,0 +4,0 @@ import http from 'http'; |
@@ -73,4 +73,5 @@ "use strict"; | ||
} | ||
catch (error) { | ||
reject(error); | ||
catch { | ||
// Client error, pipeline already destroys the streams, ignore. | ||
resolve(); | ||
} | ||
@@ -81,12 +82,24 @@ }); | ||
}); | ||
try { | ||
// `pipeline` automatically handles all the events and data | ||
await pipeline(request, client); | ||
} | ||
catch (error) { | ||
error.proxy = proxy; | ||
reject(error); | ||
} | ||
// Can't use pipeline here as it automatically destroys the streams | ||
request.pipe(client); | ||
client.on('error', (error) => { | ||
var _a; | ||
if (response.headersSent) { | ||
return; | ||
} | ||
const statuses = { | ||
ENOTFOUND: proxy ? 502 : 404, | ||
ECONNREFUSED: 502, | ||
ECONNRESET: 502, | ||
EPIPE: 502, | ||
ETIMEDOUT: 504, | ||
'': 500, | ||
}; | ||
response.statusCode = statuses[(_a = error.code) !== null && _a !== void 0 ? _a : '']; | ||
response.setHeader('content-type', 'text/plain; charset=utf-8'); | ||
response.end(http_1.default.STATUS_CODES[response.statusCode]); | ||
resolve(); | ||
}); | ||
}); | ||
exports.forward = forward; | ||
//# sourceMappingURL=forward.js.map |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import dns from 'dns'; | ||
@@ -3,0 +8,0 @@ import http from 'http'; |
@@ -200,8 +200,2 @@ "use strict"; | ||
} | ||
if (error.code === 'ENOTFOUND') { | ||
if (error.proxy) { | ||
return new request_error_1.RequestError('Failed to connect to upstream proxy', 502); | ||
} | ||
return new request_error_1.RequestError('Target website does not exist', 404); | ||
} | ||
return error; | ||
@@ -208,0 +202,0 @@ } |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import type net from 'net'; | ||
@@ -3,0 +4,0 @@ import type tls from 'tls'; |
{ | ||
"name": "proxy-chain", | ||
"version": "2.0.2-beta.5", | ||
"version": "2.0.2-beta.6", | ||
"description": "Node.js implementation of a proxy server (think Squid) with support for SSL, authentication, upstream proxy chaining, and protocol tunneling.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
164890
1681