remoteingress/ts/connector.private.ts

27 lines
753 B
TypeScript
Raw Normal View History

2024-03-24 13:44:44 +00:00
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
});
}
}