correct npx directive

according to the [doc](https://docs.npmjs.com/cli/v8/commands/npx), npx needs package name rather than the binary name. so executing `npx y-websocket-server` would not download and run the server binary in `y-websocket`, it would download from [y-websocket-server](https://npmjs.com/package/y-websocket-server) instead, which could lead to remote arbitrage code execution.
This commit is contained in:
Ya Zhuang 2021-12-30 11:22:28 +08:00 committed by Ya Zhuang
parent 011a06fe8e
commit 6b61bae779
No known key found for this signature in database
GPG Key ID: B024B2767A35B0C7

View File

@ -24,7 +24,7 @@ This repository implements a basic server that you can adopt to your specific us
Start a y-websocket server: Start a y-websocket server:
```sh ```sh
HOST=localhost PORT=1234 npx y-websocket-server HOST=localhost PORT=1234 npx y-websocket
``` ```
### Client Code: ### Client Code:
@ -101,10 +101,10 @@ wsOpts = {
Start a y-websocket server: Start a y-websocket server:
```sh ```sh
HOST=localhost PORT=1234 npx y-websocket-server HOST=localhost PORT=1234 npx y-websocket
``` ```
Since npm symlinks the `y-websocket-server` executable from your local `./node_modules/.bin` folder, you can simply run npx. The `PORT` environment variable already defaults to 1234, and `HOST` defaults to `localhost`. Since npm symlinks the `y-websocket` executable from your local `./node_modules/.bin` folder, you can simply run npx. The `PORT` environment variable already defaults to 1234, and `HOST` defaults to `localhost`.
### Websocket Server with Persistence ### Websocket Server with Persistence