Namespace: webrtc

webrtc

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

Source:

Members

(static) beefrtcs

To handle multiple peers - we need to have a hash of Beefwebrtc objects. The key is the peer id.

Source:

(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.

Source:

(static) rtcrecvchan

To handle multiple event channels - we need to have a global hash of these. The key is the peer id

Source:

(static) rtcstealth

stealth should only be initiated from one peer - this global variable will contain: false - i.e not stealthed; or - i.e. the id of the browser which initiated stealth mode

Source:

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
Source:

(static) Beefwebrtc#calleeStart()

Check for messages - which includes signaling from a calling peer - this gets kicked off in maybeStart()

Source:

(static) Beefwebrtc#createPeerConnection()

Try and establish the RTC connection

Source:

(static) Beefwebrtc#doAnswer()

As part of the processSignalingMessage function, we check for 'offers' from peers. If there's an offer, we answer, as below

Source:

(static) Beefwebrtc#doCall()

RTC - create an offer - the caller runs this, while the receiver runs calleeStart()

Source:

(static) Beefwebrtc#execCmd()

How the browser executes received JS (this is pretty hacky)

Source:

(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

Source:

(static) Beefwebrtc#goStealth()

This is the function when a peer tells us to go into stealth by sending a dataChannel message of "!gostealth"

Source:

(static) Beefwebrtc#iceCandidateType()

Helper method to determine what kind of ICE Candidate we've received

Source:

(static) Beefwebrtc#initialize()

Initialize the object

Source:

(static) Beefwebrtc#maybeStart()

Try and initiate, will check that system hasn't started, and that signaling is ready, and that TURN servers are ready

Source:

(static) Beefwebrtc#mergeConstraints()

Helper method to merge SDP constraints

Source:

(static) Beefwebrtc#noteIceCandidate()

Used to record ICS candidates locally

Source:

(static) Beefwebrtc#onAddIceCandidateError()

Event handler for unsuccessful addition of ICE Candidates

Source:

(static) Beefwebrtc#onAddIceCandidateSuccess()

Event handler for successful addition of ICE Candidates

Source:

(static) Beefwebrtc#onCreateSessionDescriptionError()

If the browser can't build an SDP

Source:

(static) Beefwebrtc#onDataChannel()

When a data channel has been established - within here is the message handling function as well

Source:

(static) Beefwebrtc#onIceCandidate()

When the PeerConnection receives a new ICE Candidate

Source:

(static) Beefwebrtc#onIceConnectionStateChanged()

When the ICE Connection State changes - this is useful to determine connection statuses with peers.

Source:

(static) Beefwebrtc#onRemoteHangup()

If a peer hangs up (we bring down the peerconncetion via the stop() method)

Source:

(static) Beefwebrtc#onSetRemoteDescriptionSuccess()

If the browser successfully sets a remote description

Source:

(static) Beefwebrtc#onSignalingStateChanged()

When the signalling state changes. We don't actually do anything with this except log it.

Source:

(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

Source:

(static) Beefwebrtc#processSignalingMessage()

Process messages, this is how we handle the signaling messages, such as candidate info, offers, answers

Source:

(static) Beefwebrtc#sendPeerMsg()

Shortcut function to SEND a data messsage

Source:

(static) Beefwebrtc#sendSignalMsg()

Send a signalling message ..

Source:

(static) Beefwebrtc#setRemote()

Used to set the RTC remote session

Source:

(static) Beefwebrtc#stop()

Bring down the peer connection

Source:

(static) rtcpollPeer()

This is the actual poller when in stealth, it is global as well because we're using the setTimeout to execute it

Source: