27 lines
753 B
TypeScript
27 lines
753 B
TypeScript
|
import * as tls from 'tls';
|
||
|
|
||
|
export class ConnectorPrivate {
|
||
|
private targetHost: string;
|
||
|
private targetPort: number;
|
||
|
|
||
|
constructor(targetHost: string, targetPort: number) {
|
||
|
this.targetHost = targetHost;
|
||
|
this.targetPort = targetPort;
|
||
|
this.connectToPublicRemoteConnector();
|
||
|
}
|
||
|
|
||
|
private connectToPublicRemoteConnector(): void {
|
||
|
const options = {
|
||
|
// If your server requires client certificate authentication, you can specify key and cert here as well
|
||
|
};
|
||
|
|
||
|
const tunnel = tls.connect({ port: 4000, ...options }, () => {
|
||
|
console.log('Connected to PublicRemoteConnector on port 4000');
|
||
|
});
|
||
|
|
||
|
tunnel.on('data', (data: Buffer) => {
|
||
|
// Similar logic for forwarding data to and from the target
|
||
|
});
|
||
|
}
|
||
|
}
|