Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
cdnbye-dash
Advanced tools
English | 简体中文
CDNBye dashjs-p2p-engine implements WebRTC datachannel to scale live/vod video streaming by peer-to-peer network using bittorrent-like protocol. The forming peer network can be layed over other CDNs or on top of the origin server. Powered by dash.js, it can play MPEG-dash on any platform with many popular HTML5 players such as video.js, JWPlayer and Flowplayer. BTW, you can view how much traffic has been saved here!
Put the quick-start.html in your web page, run it. Wait for a few seconds,then open the same page from another browser. Now you have a direct P2P connection between two browsers without plugin! The first web peer will serve as a seed, if no one else in the same channel.
WebRTC has already been incorporated into the HTML5 standard and it is broadly deployed in modern browsers. The compatibility of CDNBye depends on the browser support of WebRTC and dash.js. Please note that iOS Safari "Mobile" does not support the MediaSource API.
Compatibility | Chrome | Firefox | macOS Safari | Android Wechat/QQ | Opera | Edge | IE | iOS Safari |
---|---|---|---|---|---|---|---|---|
WebRTC Datachannel | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ |
dash.js | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ❌ |
CDNBye | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ❌ | ❌ |
Include the pre-built script of latest version:
<script src="https://cdn.jsdelivr.net/npm/cdnbye-dash@latest"></script>
<!doctype html>
<html>
<head>
<title>Dash with P2P</title>
<style>
video {
width: 640px;
height: 360px;
}
</style>
</head>
<body>
<div>
<video id="videoPlayer" controls></video>
</div>
<script src="yourPathToDash/dash.all.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cdnbye-dash@latest"></script>
<script>
(function(){
var url = "https://dash.akamaized.net/envivio/EnvivioDash3/manifest.mpd";
var player = dashjs.MediaPlayer().create();
new P2PEngine(player);
player.initialize(document.querySelector("#videoPlayer"), url, true);
})();
</script>
</body>
</html>
var engine = new P2PEngine(player, {p2pConfig: [opts]});
Create a new P2PEngine
instance, player
is an instance of dashjs#MediaPlayer
.
If opts
is specified, then the default options (shown below) will be overridden.
Field | Type | Default | Description |
---|---|---|---|
logLevel | string or boolean | 'none' | Print log level(warn, error, none,false=none, true=warn). |
live | boolean | false | tell engine whether in live or VOD mode, set to false will pre-buffer for smooth playing. |
wsSignalerAddr | string | 'wss://signal.cdnbye.com' | The address of signal server. |
announce | string | 'https://tracker.cdnbye.com/v1' | The address of tracker server. |
wsMaxRetries | number | 15 | The maximum number of reconnection attempts that will be made by websocket before giving up. |
wsReconnectInterval | number | 30 | The number of seconds to delay before attempting to reconnect by websocket. |
memoryCacheLimit | Object | {"pc": 1024 * 1024 * 512, "mobile": 1024 * 1024 * 256} | The max size of binary data that can be stored in the cache. |
p2pEnabled | boolean | true | Enable or disable p2p engine. |
dcDownloadTimeout | number | 25 | Max download timeout for WebRTC datachannel. |
webRTCConfig | Object | {} | A Configuration dictionary providing options to configure WebRTC connections. |
useHttpRange | boolean | false | Use HTTP ranges requests where it is possible. Allows to continue (and not start over) aborted P2P downloads over HTTP(True in live mode by default). |
getStats | function | - | Get the downloading statistics, including totalP2PDownloaded, totalP2PUploaded and totalHTTPDownloaded. |
getPeerId | function | - | Emitted when the peer Id of this client is obtained from server. |
getPeersInfo | function | - | Emitted when successfully connected with new peer. |
channelId | function | - | Pass a function to generate channel Id.(See advanced usage) |
validateSegment | function | - | Pass a function to check segment validity downloaded from peers. |
P2PEngine.version
(static method)Get the version of P2PEngine
.
P2PEngine.isSupported()
(static method)Returns true if WebRTC data channel is supported by the browser.
engine.enableP2P()
Resume P2P if it has been stopped.
engine.disableP2P()
Disable engine to stop p2p and free used resources.
engine.destroy()
Stop p2p and free used resources.
engine.on('peerId', function (peerId) {})
Emitted when the peer Id of this client is obtained from server.
engine.on('peers', function (peers) {})
Emitted when successfully connected with new peer.
engine.on('stats', function (stats) {})
Emitted when data is downloaded/uploaded.
stats.totalHTTPDownloaded: total data downloaded by HTTP(KB).
stats.totalP2PDownloaded: total data downloaded by P2P(KB).
stats.totalP2PUploaded: total data uploaded by P2P(KB).
p2pConfig: {
getStats: function (totalP2PDownloaded, totalP2PUploaded, totalHTTPDownloaded) {
// do something
}
}
p2pConfig: {
getPeerId: function (peerId) {
// do something
}
}
p2pConfig: {
getPeersInfo: function (peers) {
// do something
}
}
Some MPD urls play the same live/vod but have different paths on them. For example,
example.com/clientId1/file.mpd and example.com/clientId2/file.mpd. In this case, you can format a common channelId for them. It is strongly recommended to add a unique identifier to the channelid to prevent conflicts with other channels.
p2pConfig: {
channelId: function (mpdUrl) {
const formatedUrl = 'YOUR_UNIQUE_ID' + format(mpdUrl); // format a channelId by removing the different part
return formatedUrl;
}
}
p2pConfig: {
webRTCConfig: {
config: { // custom webrtc configuration (used by RTCPeerConnection constructor)
iceServers: [
{ urls: 'stun:stun.l.google.com:19302' },
{ urls: 'stun:global.stun.twilio.com:3478?transport=udp' }
]
}
}
}
If http range request is activated, we are able to get chunks of data from peer and then complete the segments by getting other chunks from the CDN, thus, reducing your CDN bandwidth. Besides, the code below is needed:
p2pConfig: {
useHttpRange: true,
}
Bind your domain in https://oms.cdnbye.com
, where you can view p2p-related information.
We have collected some frequently asked questions. Before reporting an issue, please search if the FAQ has the answer to your problem.
Email: service@cdnbye.com
FAQs
Let your viewers become your unlimitedly scalable CDN.
The npm package cdnbye-dash receives a total of 24 weekly downloads. As such, cdnbye-dash popularity was classified as not popular.
We found that cdnbye-dash demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.