remoteingress/ts/connector.public.ts
2024-03-24 14:44:44 +01:00

33 lines
854 B
TypeScript

import * as tls from 'tls';
import * as fs from 'fs';
export class ConnectorPublic {
private tunnel: tls.TLSSocket | null = null;
constructor() {
this.createTunnel();
this.listenOnPorts();
}
private createTunnel(): void {
const options = {
key: fs.readFileSync('path/to/key.pem'),
cert: fs.readFileSync('path/to/cert.pem')
};
const server = tls.createServer(options, (socket: tls.TLSSocket) => {
this.tunnel = socket;
console.log('Tunnel established with LocalConnector');
});
server.listen(4000, () => {
console.log('PublicRemoteConnector listening for tunnel on port 4000');
});
}
private listenOnPorts(): void {
// Implement similar logic for listening on ports 80 and 443
// Keep in mind you may need to adjust how you handle secure and non-secure traffic
}
}