mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
chore: use socks.Duplex constructor instead of extending (#31816)
This commit is contained in:
parent
bbe5df3f5f
commit
526e4118fa
@ -26,17 +26,6 @@ import type { SocksSocketClosedPayload, SocksSocketDataPayload, SocksSocketReque
|
|||||||
import { SocksProxy } from '../common/socksProxy';
|
import { SocksProxy } from '../common/socksProxy';
|
||||||
import type * as channels from '@protocol/channels';
|
import type * as channels from '@protocol/channels';
|
||||||
|
|
||||||
class SocksConnectionDuplex extends stream.Duplex {
|
|
||||||
constructor(private readonly writeCallback: (data: Buffer) => void) {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
override _read(): void { }
|
|
||||||
override _write(chunk: Buffer, encoding: BufferEncoding, callback: (error?: Error | null | undefined) => void): void {
|
|
||||||
this.writeCallback(chunk);
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class SocksProxyConnection {
|
class SocksProxyConnection {
|
||||||
private readonly socksProxy: ClientCertificatesProxy;
|
private readonly socksProxy: ClientCertificatesProxy;
|
||||||
private readonly uid: string;
|
private readonly uid: string;
|
||||||
@ -89,7 +78,13 @@ class SocksProxyConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _attachTLSListeners() {
|
private _attachTLSListeners() {
|
||||||
this.internal = new SocksConnectionDuplex(data => this.socksProxy._socksProxy.sendSocketData({ uid: this.uid, data }));
|
this.internal = new stream.Duplex({
|
||||||
|
read: () => {},
|
||||||
|
write: (data, encoding, callback) => {
|
||||||
|
this.socksProxy._socksProxy.sendSocketData({ uid: this.uid, data });
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
});
|
||||||
const internalTLS = new tls.TLSSocket(this.internal, {
|
const internalTLS = new tls.TLSSocket(this.internal, {
|
||||||
isServer: true,
|
isServer: true,
|
||||||
key: fs.readFileSync(path.join(__dirname, '../../bin/socks-certs/key.pem')),
|
key: fs.readFileSync(path.join(__dirname, '../../bin/socks-certs/key.pem')),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user