chore: add more client-certificates debug logging
This commit is contained in:
parent
5a015b0d6e
commit
d90619564b
|
|
@ -92,9 +92,14 @@ class SocksProxyConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
async connect() {
|
async connect() {
|
||||||
|
debugLogger.log('client-certificates', `Connecting to ${this.host}:${this.port}`);
|
||||||
this.target = await createSocket(rewriteToLocalhostIfNeeded(this.host), this.port);
|
this.target = await createSocket(rewriteToLocalhostIfNeeded(this.host), this.port);
|
||||||
this.target.on('close', this._targetCloseEventListener);
|
this.target.on('close', this._targetCloseEventListener);
|
||||||
this.target.on('error', error => this.socksProxy._socksProxy.sendSocketError({ uid: this.uid, error: error.message }));
|
this.target.on('error', error => {
|
||||||
|
debugLogger.log('client-certificates', `error when connecting to target: ${error.message.replaceAll('\n', ' ')}`);
|
||||||
|
this.socksProxy._socksProxy.sendSocketError({ uid: this.uid, error: error.message });
|
||||||
|
});
|
||||||
|
debugLogger.log('client-certificates', `Connected to ${this.host}:${this.port}`);
|
||||||
this.socksProxy._socksProxy.socketConnected({
|
this.socksProxy._socksProxy.socketConnected({
|
||||||
uid: this.uid,
|
uid: this.uid,
|
||||||
host: this.target.localAddress!,
|
host: this.target.localAddress!,
|
||||||
|
|
@ -113,11 +118,14 @@ class SocksProxyConnection {
|
||||||
if (!this.firstPackageReceived) {
|
if (!this.firstPackageReceived) {
|
||||||
this.firstPackageReceived = true;
|
this.firstPackageReceived = true;
|
||||||
// 0x16 is SSLv3/TLS "handshake" content type: https://en.wikipedia.org/wiki/Transport_Layer_Security#TLS_record
|
// 0x16 is SSLv3/TLS "handshake" content type: https://en.wikipedia.org/wiki/Transport_Layer_Security#TLS_record
|
||||||
if (data[0] === 0x16)
|
if (data[0] === 0x16) {
|
||||||
|
debugLogger.log('client-certificates', `Proxy->Target ${this.host}:${this.port} chooses TLS`);
|
||||||
this._attachTLSListeners();
|
this._attachTLSListeners();
|
||||||
else
|
} else {
|
||||||
|
debugLogger.log('client-certificates', `Proxy->Target ${this.host}:${this.port} chooses HTTP`);
|
||||||
this.target.on('data', data => this.socksProxy._socksProxy.sendSocketData({ uid: this.uid, data }));
|
this.target.on('data', data => this.socksProxy._socksProxy.sendSocketData({ uid: this.uid, data }));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (this.internal)
|
if (this.internal)
|
||||||
this.internal.push(data);
|
this.internal.push(data);
|
||||||
else
|
else
|
||||||
|
|
@ -151,7 +159,7 @@ class SocksProxyConnection {
|
||||||
|
|
||||||
const handleError = (error: Error) => {
|
const handleError = (error: Error) => {
|
||||||
error = rewriteOpenSSLErrorIfNeeded(error);
|
error = rewriteOpenSSLErrorIfNeeded(error);
|
||||||
debugLogger.log('client-certificates', `error when connecting to target: ${error.message.replaceAll('\n', ' ')}`);
|
debugLogger.log('client-certificates', `Proxy->Target ${this.host}:${this.port} TLS error: ${error.message}`);
|
||||||
const responseBody = escapeHTML('Playwright client-certificate error: ' + error.message)
|
const responseBody = escapeHTML('Playwright client-certificate error: ' + error.message)
|
||||||
.replaceAll('\n', ' <br>');
|
.replaceAll('\n', ' <br>');
|
||||||
if (internalTLS?.alpnProtocol === 'h2') {
|
if (internalTLS?.alpnProtocol === 'h2') {
|
||||||
|
|
@ -209,6 +217,7 @@ class SocksProxyConnection {
|
||||||
targetTLS = tls.connect(tlsOptions);
|
targetTLS = tls.connect(tlsOptions);
|
||||||
|
|
||||||
targetTLS.on('secureConnect', () => {
|
targetTLS.on('secureConnect', () => {
|
||||||
|
debugLogger.log('client-certificates', `Proxy->Target ${this.host}:${this.port} secure connection established`);
|
||||||
internalTLS.pipe(targetTLS);
|
internalTLS.pipe(targetTLS);
|
||||||
targetTLS.pipe(internalTLS);
|
targetTLS.pipe(internalTLS);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue