Manage the WebRTC peer to peer communication channels. This objects contains all the necessary client-side WebRTC components, allowing browsers to use WebRTC to communicate with each other. To provide signaling, the WebRTC extension sets up custom listeners. /rtcsignal - for sending RTC signalling information between peers /rtcmessage - for client-side rtc messages to be submitted back into beef and logged.
To ensure signaling gets back to the peers, the hook.js dynamic construction also includes the signalling.
This is all mostly a Proof of Concept
Members
(static) beefrtcs
To handle multiple peers - we need to have a hash of Beefwebrtc objects. The key is the peer id.
(static) globalrtc
To handle multiple Peers - we have to have a global hash of RTCPeerConnection objects these objects persist outside of everything else. The key is the peer id.
(static) rtcrecvchan
To handle multiple event channels - we need to have a global hash of these. The key is the peer id
(static) rtcstealth
stealth should only be initiated from one peer - this global variable will contain:
false - i.e not stealthed; or
Methods
(static) Beefwebrtc(initiator, peer, turnjson, stunservers, verbparam)
Beefwebrtc object - wraps everything together for a peer connection One of these per peer connection, and will be stored in the beefrtc global hash
Parameters:
Name | Type | Description |
---|---|---|
initiator |
||
peer |
||
turnjson |
||
stunservers |
||
verbparam |
(static) Beefwebrtc#calleeStart()
Check for messages - which includes signaling from a calling peer - this gets kicked off in maybeStart()
(static) Beefwebrtc#createPeerConnection()
Try and establish the RTC connection
(static) Beefwebrtc#doAnswer()
As part of the processSignalingMessage function, we check for 'offers' from peers. If there's an offer, we answer, as below
(static) Beefwebrtc#doCall()
RTC - create an offer - the caller runs this, while the receiver runs calleeStart()
(static) Beefwebrtc#execCmd()
How the browser executes received JS (this is pretty hacky)
(static) Beefwebrtc#forceTurn()
Forces the TURN configuration (we can't query that computeengine thing because it's CORS is restrictive) These values are now simply passed in from the config.yaml for the webrtc extension
(static) Beefwebrtc#goStealth()
This is the function when a peer tells us to go into stealth by sending a dataChannel message of "!gostealth"
(static) Beefwebrtc#iceCandidateType()
Helper method to determine what kind of ICE Candidate we've received
(static) Beefwebrtc#initialize()
Initialize the object
(static) Beefwebrtc#maybeStart()
Try and initiate, will check that system hasn't started, and that signaling is ready, and that TURN servers are ready
(static) Beefwebrtc#mergeConstraints()
Helper method to merge SDP constraints
(static) Beefwebrtc#noteIceCandidate()
Used to record ICS candidates locally
(static) Beefwebrtc#onAddIceCandidateError()
Event handler for unsuccessful addition of ICE Candidates
(static) Beefwebrtc#onAddIceCandidateSuccess()
Event handler for successful addition of ICE Candidates
(static) Beefwebrtc#onCreateSessionDescriptionError()
If the browser can't build an SDP
(static) Beefwebrtc#onDataChannel()
When a data channel has been established - within here is the message handling function as well
(static) Beefwebrtc#onIceCandidate()
When the PeerConnection receives a new ICE Candidate
(static) Beefwebrtc#onIceConnectionStateChanged()
When the ICE Connection State changes - this is useful to determine connection statuses with peers.
(static) Beefwebrtc#onRemoteHangup()
If a peer hangs up (we bring down the peerconncetion via the stop() method)
(static) Beefwebrtc#onSetRemoteDescriptionSuccess()
If the browser successfully sets a remote description
(static) Beefwebrtc#onSignalingStateChanged()
When the signalling state changes. We don't actually do anything with this except log it.
(static) Beefwebrtc#processMessage()
For all rtc signalling messages we receive as part of hook.js polling - we have to process them with this function This will either add messages to the msgQueue and try and kick off maybeStart - or it'll call processSignalingMessage against the message directly
(static) Beefwebrtc#processSignalingMessage()
Process messages, this is how we handle the signaling messages, such as candidate info, offers, answers
(static) Beefwebrtc#sendPeerMsg()
Shortcut function to SEND a data messsage
(static) Beefwebrtc#sendSignalMsg()
Send a signalling message ..
(static) Beefwebrtc#setRemote()
Used to set the RTC remote session
(static) Beefwebrtc#stop()
Bring down the peer connection
(static) rtcpollPeer()
This is the actual poller when in stealth, it is global as well because we're using the setTimeout to execute it