Skip to content

Commit eadfb37

Browse files
committed
Fix nodejs compatibility error + buffer deprecation
1 parent 29e21f5 commit eadfb37

File tree

3 files changed

+39
-5
lines changed

3 files changed

+39
-5
lines changed

package-lock.json

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,8 @@
1818
"bugs": {
1919
"url": "https://github.com/hbollon/proxy-login-automator/issues"
2020
},
21-
"homepage": "https://github.com/hbollon/proxy-login-automator#readme"
21+
"homepage": "https://github.com/hbollon/proxy-login-automator#readme",
22+
"dependencies": {
23+
"http-parser-js": "0.5.3"
24+
}
2225
}

proxy-login-automator.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22
'use strict';
33
var net = require('net'), tls = require('tls');
4-
var HTTPParser = process.binding('http_parser').HTTPParser;
4+
var HTTPParser = process.binding('http_parser').HTTPParser = require('http-parser-js').HTTPParser;
55
var http = require('http'), https = require('https');
66
var url = require('url');
77

@@ -36,7 +36,7 @@ function main() {
3636
return console.error('when use as a PAC server, the local_host parameter must be a definite address');
3737
}
3838
console.log('Using parameters: ' + JSON.stringify(cfg, null, ' '));
39-
cfg.buf_proxy_basic_auth = new Buffer('Proxy-Authorization: Basic ' + new Buffer(cfg.usr + ':' + cfg.pwd).toString('base64'));
39+
cfg.buf_proxy_basic_auth = Buffer.from('Proxy-Authorization: Basic ' + Buffer.from(cfg.usr + ':' + cfg.pwd).toString('base64'));
4040

4141
if (cfg.as_pac_server) {
4242
createPacServer(cfg.local_host, cfg.local_port, cfg.remote_host, cfg.remote_port, cfg.buf_proxy_basic_auth, cfg.is_remote_https, cfg.ignore_https_cert, cfg.are_remotes_in_pac_https);
@@ -45,8 +45,8 @@ function main() {
4545
}
4646
}
4747

48-
var CR = 0xd, LF = 0xa, BUF_CR = new Buffer([0xd]), BUF_CR_LF_CR_LF = new Buffer([0xd, 0xa, 0xd, 0xa]),
49-
BUF_LF_LF = new Buffer([0xa, 0xa]), BUF_PROXY_CONNECTION_CLOSE = new Buffer('Proxy-Connection: close');
48+
var CR = 0xd, LF = 0xa, BUF_CR = Buffer.from([0xd]), BUF_CR_LF_CR_LF = Buffer.from([0xd, 0xa, 0xd, 0xa]),
49+
BUF_LF_LF = Buffer.from([0xa, 0xa]), BUF_PROXY_CONNECTION_CLOSE = Buffer.from('Proxy-Connection: close');
5050
var STATE_NONE = 0, STATE_FOUND_LF = 1, STATE_FOUND_LF_CR = 2;
5151

5252
function createPortForwarder(local_host, local_port, remote_host, remote_port, buf_proxy_basic_auth, is_remote_https, ignore_https_cert) {

0 commit comments

Comments
 (0)