Skip to content
This repository was archived by the owner on Dec 13, 2023. It is now read-only.

Commit b29438f

Browse files
authored
fix proxy authentication (#21)
1 parent 1514e0b commit b29438f

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

cbt_tunnels.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ function cbtSocket(api, params) {
121121
self.start = function(cb){
122122

123123
if(proxyAuthString !== ''){
124-
global.logger.info('Using basic authentication for proxy server mode.');
125-
sendLog('Using basic authentication for proxy server mode.');
124+
global.logger.debug('Using basic authentication for proxy server mode.');
125+
// sendLog('Using basic authentication for proxy server mode.');
126126
}
127127
var reconnecting = false;
128128
var reconnectAttempts = 0;
@@ -131,7 +131,7 @@ function cbtSocket(api, params) {
131131
conn.ping();
132132
},10000);
133133

134-
global.logger.info('Started connection attempt!');
134+
global.logger.debug('Started connection attempt!');
135135
conn.on('message',function(message){
136136
try{
137137
msg = JSON.parse(message);
@@ -440,8 +440,10 @@ function cbtSocket(api, params) {
440440

441441
if((socketExists(id)&&data.data)||(data._type==='bytesonly')){
442442
var client = connection_list[id].client;
443-
if( (data._type === 'bytesonly') && (proxyAuthString !== '') && (data.data.toString().includes('Host')) ){
444-
data = self.addProxyAuth(data);
443+
var receivedDataString = Buffer.from(data.data).toString();
444+
445+
if( (data._type === 'bytesonly') && (proxyAuthString !== '') && (receivedDataString.includes('Host')) ){
446+
data = self.addProxyAuth(data, receivedDataString);
445447
}
446448
if(connection_list[id].manipulateHeaders){
447449
data = self.manipulateHeaders(data);
@@ -500,12 +502,7 @@ function cbtSocket(api, params) {
500502
});
501503
}
502504

503-
self.addProxyAuth = function(data){
504-
var dataArr = [];
505-
data.data.map((char)=>{
506-
dataArr.push(String.fromCharCode(char));
507-
})
508-
dataStr = dataArr.join('');
505+
self.addProxyAuth = function(data, dataStr){
509506
dataArr = dataStr.split('\r\n');
510507
dataArr = _.filter(dataArr, function(col){
511508
if(!col==''){

tunnel_start.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,14 @@ module.exports = {
194194
.omit(_.isUndefined)
195195
.omit(_.isNull)
196196
.mapValues((property)=>{
197-
return property === 'true' ? true :
197+
return property === 'true' ? true :
198198
property === 'false' ? false :
199-
property
199+
property
200200
}).value();
201201

202202
var logLevel = cmdArgs.verbose ? 'ALL' :
203-
cmdArgs.quiet ? 'OFF' :
204-
'INFO';
203+
cmdArgs.quiet ? 'OFF' :
204+
'INFO';
205205

206206
if(cmdArgs.log&&cmdArgs.quiet){
207207
log4js.configure({
@@ -291,6 +291,8 @@ module.exports = {
291291
port: cmdArgs.port,
292292
proxyIp: cmdArgs.proxyIp,
293293
proxyPort: cmdArgs.proxyPort,
294+
proxyUser: cmdArgs.proxyUser,
295+
proxyPass: cmdArgs.proxyPass,
294296
quiet: cmdArgs.quiet,
295297
tType: cmdArgs.tType,
296298
tunnelName: cmdArgs.tunnelname,

0 commit comments

Comments
 (0)