Unverified 提交 25039048 authored 作者: Jesús Leganés-Combarro's avatar Jesús Leganés-Combarro 提交者: GitHub

Clean-ups (#1003)

上级 3bdad193
......@@ -20,15 +20,15 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.ci.node }}
- name: Configure cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.npm
......
......@@ -19,10 +19,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Configure cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
......
......@@ -47,10 +47,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
......@@ -62,7 +62,7 @@ jobs:
if: runner.os != 'Windows'
- name: Configure cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.npm
......
......@@ -36,3 +36,6 @@
/.vscode
# JetBrains IDE stuff.
/.idea
# Packaged module.
*.tgz
......@@ -2,133 +2,108 @@
This document is intended for mediasoup developers.
## NPM scripts
The `package.json` file in the main folder includes the following scripts:
### `npm run typescript:build`
Compiles mediasoup TypeScript code (`lib` folder) JavaScript and places it into the `lib` directory.
### `npm run typescript:watch`
Compiles mediasoup TypeScript code (`lib` folder) JavaScript, places it into the `lib` directory an watches for changes in the TypeScript files.
### `npm run worker:build`
Builds the `mediasoup-worker` binary. It invokes `make`below.
### `npm run lint`
Runs both `npm run lint:node` and `npm run lint:worker`.
### `npm run lint:node`
Validates mediasoup JavaScript files using [ESLint](https://eslint.org).
### `npm run lint:worker`
Validates mediasoup-worker C++ files using [clang-format](https://clang.llvm.org/docs/ClangFormat.html). It invokes `make lint` below.
### `npm run format:worker`
Rewrites mediasoup-worker C++ files using [clang-format](https://clang.llvm.org/docs/ClangFormat.html). It invokes `make format` below.
### `npm run test`
Runs both `npm run test:node` and `npm run test:worker`.
### `npm run test:node`
Runs [Jest](https://jestjs.io) test units located at `test/` folder.
### `npm run test:worker`
Runs [Catch2](https://github.com/catchorg/Catch2) test units located at `worker/test/` folder. It invokes `make test` below.
### `npm run coverage:node`
Same as `npm run test:node` but it also opens a browser window with JavaScript coverage results.
### `npm run install-deps:node`
Installs NPM dependencies and updates `package-lock.json`.
### `npm run install-clang-tools`
Installs clang tools needed for local development.
## Rust
The only special feature in Rust case is special environment variable `KEEP_BUILD_ARTIFACTS`, that when set to `1` will allow incremental recompilation of changed C++ sources during hacking on mediasoup.
It is not necessary for normal usage of mediasoup as a dependency.
## Makefile
The `worker` folder contains a `Makefile` for the mediasoup-worker C++ subproject. It includes the following tasks:
### `make` or `make mediasoup-worker`
Alias of ``make mediasoup-worker` below.
### `make meson-ninja`
Installs `meson` and `ninja`.
### `make clean`
Cleans built objects and binaries.
### `make clean-build`
Cleans built objects and other artifacts, but keeps `mediasoup-worker` binary in place.
### `make clean-pip`
Cleans `meson` and `ninja` installed in local prefix with pip.
### `make clean-subprojects`
Cleans subprojects downloaded with Meson.
### `make clean-all`
Cleans built objects and binaries, `meson` and `ninja` installed in local prefix with pip and all subprojects downloaded with Meson.
### `make update-wrap-file`
Update the wrap file of a subproject with Meson. Usage example:
```bash
$ cd worker
$ make update-wrap-file SUBPROJECT=openssl
cd worker
make update-wrap-file SUBPROJECT=openssl
```
### `make mediasoup-worker`
Builds the `mediasoup-worker` binary at `worker/out/Release/`.
......@@ -139,49 +114,42 @@ If the "MEDIASOUP_MAX_CORES" environment variable is set, the build process will
Other build types are possible too, but they are not presets and will require "MESON_ARGS" use to customize build configuration.
Check the meaning of useful macros in the `worker/include/Logger.hpp` header file if you want to enable tracing or other debug information.
Binary is built at `worker/out/MEDIASOUP_BUILDTYPE/build`.
Binary is built at `worker/out/MEDIASOUP_BUILDTYPE/build`.
In order to instruct the mediasoup Node.js module to use the `Debug` mediasoup-worker binary, an environment variable must be set before running the Node.js application:
```bash
$ MEDIASOUP_BUILDTYPE=Debug node myapp.js
MEDIASOUP_BUILDTYPE=Debug node myapp.js
```
If the "MEDIASOUP_WORKER_BIN" environment variable is set, mediasoup will use the it as mediasoup-worker binary and **won't** compile the binary:
```bash
$ MEDIASOUP_WORKER_BIN="/home/xxx/src/foo/mediasoup-worker" node myapp.js
MEDIASOUP_WORKER_BIN="/home/xxx/src/foo/mediasoup-worker" node myapp.js
```
### `make libmediasoup-worker`
Builds the `libmediasoup-worker` static library at `worker/out/Release/`.
`MEDIASOUP_MAX_CORES` and `MEDIASOUP_BUILDTYPE` environment variables from above still apply for static library build.
### `make xcode`
Builds a Xcode project for the mediasoup-worker subproject.
### `make lint`
Validates mediasoup-worker C++ files using [clang-format](https://clang.llvm.org/docs/ClangFormat.html) and rules in `worker/.clang-format`.
### `make format`
Rewrites mediasoup-worker C++ files using [clang-format](https://clang.llvm.org/docs/ClangFormat.html).
### `make test`
Builds and runs the `mediasoup-worker-test` binary at `worker/out/Release/` (or at `worker/out/Debug/` if the "MEDIASOUP_BUILDTYPE" environment variable is set to "Debug"), which uses [Catch2](https://github.com/catchorg/Catch2) to run test units located at `worker/test/` folder.
### `make tidy`
Runs [clang-tidy](http://clang.llvm.org/extra/clang-tidy/) and performs C++ code checks following `worker/.clang-tidy` rules.
......@@ -190,8 +158,7 @@ Runs [clang-tidy](http://clang.llvm.org/extra/clang-tidy/) and performs C++ code
* `make clean` and `make` must have been called first.
* [PyYAML](https://pyyaml.org/) is required.
- In OSX install it with `brew install libyaml` and `sudo easy_install-X.Y pyyaml`.
* In OSX install it with `brew install libyaml` and `sudo easy_install-X.Y pyyaml`.
### `make fuzzer`
......@@ -205,12 +172,10 @@ Builds the `mediasoup-worker-fuzzer` binary (which uses [libFuzzer](http://llvm.
Read the [Fuzzer](Fuzzer.md) documentation for detailed information.
### `make fuzzer-run-all`
Runs all fuzzer cases.
### `make docker`
Builds a Linux image with fuzzer capable clang++.
......@@ -218,11 +183,10 @@ Builds a Linux image with fuzzer capable clang++.
**NOTE:** Before running this command, a specific version of Linux clang must be downloaded. To get it, run:
```bash
$ cd worker
$ ./scripts/get-dep.sh clang-fuzzer
cd worker
./scripts/get-dep.sh clang-fuzzer
```
### `make docker-run`
Runs a container of the Docker image created with `make docker`. It automatically executes a `bash` session in the `/mediasoup` directory, which is a Docker volume that points to the real `mediasoup` directory.
......@@ -4,7 +4,6 @@ Once we have built the `mediasoup-worker-fuzzer` target in a Linux environment w
**NOTE:** From now on, we assume we are in the mediasoup `worker` directory.
## Related documentation
* [libFuzzer documentation](http://llvm.org/docs/LibFuzzer.html)
......@@ -12,14 +11,12 @@ Once we have built the `mediasoup-worker-fuzzer` target in a Linux environment w
* [webrtcH4cKS ~ Lets get better at fuzzing in 2019](https://webrtchacks.com/lets-get-better-at-fuzzing-in-2019-heres-how/)
* [OSS-Fuzz](https://github.com/google/oss-fuzz) - Continuous fuzzing of open source software ("fuzz for me")
## Corpus files
The `deps/webrtc-fuzzer-corpora/corpora` directory has corpus directories taken from the [webrtc-fuzzer-corpora](https://github.com/RTC-Cartel/webrtc-fuzzer-corpora) project. They should be use to feed fuzzer with appropriate input.
However, given how `libFuzzer` [works](http://llvm.org/docs/LibFuzzer.html#options), the first directory given as command line parameter is not just used for reading corpus files, but also to store newly generated ones. So, it's recommended to pass `fuzzer/new-corpus` as first directory. Such a directory is gitignored.
## Crash reports
When the fuzzer detects an issue it generates a crash report file which contains the bytes given as input. Those files can be individually used later (instead of passing corpus directories) to the fuzzer to verify that the issue has been fixed.
......@@ -50,41 +47,40 @@ The mediasoup-worker fuzzer reads some custom environment variables to decide wh
The log level can also be set by setting the `MS_FUZZ_LOG_LEVEL` environment variable to "debug", "warn" or "error" (it is "none" if unset).
## Usage examples
* Detect memory leaks and just fuzz STUN:
```bash
$ MS_FUZZ_STUN=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/stun-corpus
MS_FUZZ_STUN=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/stun-corpus
```
* Detect memory leaks and just fuzz RTP:
```bash
$ MS_FUZZ_RTP=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/rtp-corpus
MS_FUZZ_RTP=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/rtp-corpus
```
* Detect memory leaks and just fuzz RTCP:
```bash
$ MS_FUZZ_RTCP=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/rtcp-corpus
MS_FUZZ_RTCP=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/rtcp-corpus
```
* Detect memory leaks and just fuzz mediasoup-worker C++ utils:
```bash
$ MS_FUZZ_UTILS=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=2000 fuzzer/new-corpus
MS_FUZZ_UTILS=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=2000 fuzzer/new-corpus
```
* Detect memory leaks and fuzz everything with log level "warn":
```bash
$ MS_FUZZ_LOG_LEVEL=warn LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/stun-corpus deps/webrtc-fuzzer-corpora/corpora/rtp-corpus deps/webrtc-fuzzer-corpora/corpora/rtcp-corpus
MS_FUZZ_LOG_LEVEL=warn LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/stun-corpus deps/webrtc-fuzzer-corpora/corpora/rtp-corpus deps/webrtc-fuzzer-corpora/corpora/rtcp-corpus
```
* Verify that a specific crash is fixed:
```bash
$ LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer fuzzer/reports/crash-f39771f7a03c0e7e539d4e52f48f7adad8976404
LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer fuzzer/reports/crash-f39771f7a03c0e7e539d4e52f48f7adad8976404
```
......@@ -175,15 +175,15 @@ export type WorkerResourceUsage =
/* eslint-enable camelcase */
};
export type WorkerEvents =
{
export type WorkerEvents =
{
died: [Error];
// Private events.
'@success': [];
'@failure': [Error];
};
export type WorkerObserverEvents =
export type WorkerObserverEvents =
{
close: [];
newwebrtcserver: [WebRtcServer];
......@@ -655,7 +655,7 @@ export class Worker extends EnhancedEventEmitter<WorkerEvents>
const data = { rtpCapabilities };
const router = new Router(
{
internal :
internal :
{
routerId : reqData.routerId
},
......
......@@ -20,23 +20,23 @@
"main": "node/lib/index.js",
"types": "node/lib/index.d.ts",
"files": [
"npm-scripts.js",
"node/lib",
"worker/Makefile",
"worker/meson.build",
"worker/meson_options.txt",
"worker/src",
"worker/include",
"worker/test/src",
"worker/test/include",
"worker/fuzzer/src",
"worker/fuzzer/include",
"worker/subprojects/*.wrap",
"worker/deps/libwebrtc",
"worker/fuzzer/include",
"worker/fuzzer/src",
"worker/include",
"worker/scripts/*.js",
"worker/scripts/*.json",
"worker/scripts/*.py",
"worker/scripts/*.sh",
"worker/scripts/*.js",
"worker/scripts/*.json"
"worker/src",
"worker/subprojects/*.wrap",
"worker/test/include",
"worker/test/src",
"worker/Makefile",
"worker/meson.build",
"worker/meson_options.txt",
"npm-scripts.js"
],
"keywords": [
"webrtc",
......
......@@ -18,7 +18,7 @@ LCOV = ./deps/lcov/bin/lcov
DOCKER ?= docker
PIP_DIR = $(MEDIASOUP_OUT_DIR)/pip
INSTALL_DIR ?= $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)
BUILD_DIR ?= $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE)/build
BUILD_DIR ?= $(INSTALL_DIR)/build
MESON ?= $(PIP_DIR)/bin/meson
MESON_VERSION ?= 0.61.5
# `MESON_ARGS` can be used to provide extra configuration parameters to Meson,
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论