only allow tcp connections locally (#1525)

This commit is contained in:
Jason Jacobs 2024-06-21 10:35:55 -07:00 • committed by GitHub
parent a5f3a4d75b
commit 066e6f932b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

View file

@ -9,6 +9,7 @@ export class TcpMessenger<
> implements IMessenger<ToProtocol, FromProtocol>
{
private port: number = 3000;
private host: string = "127.0.0.1";
private socket: net.Socket | null = null;
typeListeners = new Map<keyof ToProtocol, ((message: Message) => any)[]>();
@ -30,7 +31,7 @@ export class TcpMessenger<
});
});
server.listen(this.port, () => {
server.listen(this.port, this.host, () => {
console.log(`Server listening on port ${this.port}`);
});
}

View file

@ -182,7 +182,7 @@ class CoreMessenger(private val project: Project, esbuildPath: String, continueC
init {
if (useTcp) {
try {
val socket = Socket("localhost", 3000)
val socket = Socket("127.0.0.1", 3000)
val writer = PrintWriter(socket.getOutputStream(), true)
this.writer = writer
val reader = BufferedReader(InputStreamReader(socket.getInputStream()))