11#!/usr/bin/env node
22'use strict' ;
33var 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 ;
55var http = require ( 'http' ) , https = require ( 'https' ) ;
66var 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' ) ;
5050var STATE_NONE = 0 , STATE_FOUND_LF = 1 , STATE_FOUND_LF_CR = 2 ;
5151
5252function createPortForwarder ( local_host , local_port , remote_host , remote_port , buf_proxy_basic_auth , is_remote_https , ignore_https_cert ) {
0 commit comments