Skip to content

fix: improve callback safety in WebSocket and DataChannel wrappers #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
# tags:
# - v*

permissions:
contents: write

env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true

Expand Down Expand Up @@ -65,6 +68,11 @@ jobs:
gxx: arm-linux-gnueabihf-g++

steps:
- name: Fail if branch is not master
if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/master'
run: |
echo "This workflow should not be triggered with workflow_dispatch on a branch other than master"
exit 1
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/build-mac-m1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
# tags:
# - v*

permissions:
contents: write

env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
Expand All @@ -18,6 +20,11 @@ jobs:
node-version: [18]

steps:
- name: Fail if branch is not master
if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/master'
run: |
echo "This workflow should not be triggered with workflow_dispatch on a branch other than master"
exit 1
- uses: actions/checkout@v4
- name: Install OpenSSL
run: |
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/build-mac-x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
# tags:
# - v*

permissions:
contents: write

env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true

Expand All @@ -17,6 +20,11 @@ jobs:
node-version: [18]

steps:
- name: Fail if branch is not master
if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/master'
run: |
echo "This workflow should not be triggered with workflow_dispatch on a branch other than master"
exit 1
- uses: actions/checkout@v4
- name: Install OpenSSL
run: HOMEBREW_NO_INSTALL_CLEANUP=1 brew reinstall openssl@3
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/build-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
# tags:
# - v*

permissions:
contents: write

env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true

Expand Down Expand Up @@ -45,6 +48,11 @@ jobs:
node_arch:
- x86
steps:
- name: Fail if branch is not master
if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/master'
run: |
echo "This workflow should not be triggered with workflow_dispatch on a branch other than master"
exit 1
- uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
with:
Expand Down
28 changes: 28 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,19 @@ export interface RtcConfig {
bindAddress?: string;
enableIceTcp?: boolean;
enableIceUdpMux?: boolean;
disableAutoNegotiation?: boolean;
disableFingerprintVerification?: boolean;
disableAutoGathering?: boolean;
forceMediaTransport?: boolean;
portRangeBegin?: number;
portRangeEnd?: number;
maxMessageSize?: number;
mtu?: number;
iceTransportPolicy?: TransportPolicy;
disableFingerprintVerification?: boolean;
certificatePemFile?: string;
keyPemFile?: string;
keyPemPass?: string;
}

export const enum RelayType {
Expand Down Expand Up @@ -69,6 +76,27 @@ export const enum DescriptionType {
}
```

**setLocalDescription: (sdp: string, init?: LocalDescriptionInit) => void**

Set Local Description and optionally the ICE ufrag/pwd to use. These should not
be set as they will be generated automatically as per the spec.
```
export interface LocalDescriptionInit {
iceUfrag?: string;
icePwd?: string;
}
```

**remoteFingerprint: () => CertificateFingerprint**

Returns the certificate fingerprint used by the remote peer
```
export interface CertificateFingerprint {
value: string;
algorithm: 'sha-1' | 'sha-224' | 'sha-256' | 'sha-384' | 'sha-512' | 'md5' | 'md2';
}
```

**addRemoteCandidate: (candidate: string, mid: string) => void**

Add remote candidate info
Expand Down
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ include(FetchContent)
# Fetch libdatachannel
FetchContent_Declare(
libdatachannel
GIT_REPOSITORY https://github.com/paullouisageneau/libdatachannel.git
GIT_TAG "v0.22.2"
GIT_REPOSITORY https://github.com/achingbrain/libdatachannel.git
GIT_TAG 6673ce95223179f49db4a7f7e23852363501983e # feat/libjuice-with-mux-callbacks
)

option(NO_MEDIA "Disable media transport support in libdatachannel" OFF)
Expand All @@ -50,6 +50,7 @@ add_library(${PROJECT_NAME} SHARED
src/cpp/media-audio-wrapper.cpp
src/cpp/media-video-wrapper.cpp
src/cpp/data-channel-wrapper.cpp
src/cpp/ice-udp-mux-listener-wrapper.cpp
src/cpp/peer-connection-wrapper.cpp
src/cpp/thread-safe-callback.cpp
src/cpp/web-socket-wrapper.cpp
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
> This is a fork of `node-datachannel` with the changes from [#256](https://github.com/murat-dogan/node-datachannel/pull/256) applied

# WebRTC For Node.js and Electron ( with WebSocket)

![Linux CI Build](https://github.com/murat-dogan/node-datachannel/workflows/Build%20-%20Linux/badge.svg) ![Windows CI Build](https://github.com/murat-dogan/node-datachannel/workflows/Build%20-%20Win/badge.svg) ![Mac x64 CI Build](https://github.com/murat-dogan/node-datachannel/workflows/Build%20-%20Mac%20x64/badge.svg) ![Mac M1 CI Build](https://github.com/murat-dogan/node-datachannel/workflows/Build%20-%20Mac%20M1/badge.svg)
Expand Down
Loading