Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

webrtc-stun

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webrtc-stun

Pure TypeScript STUN implementation.

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
increased by10%
Maintainers
1
Weekly downloads
 
Created
Source

webrtc-stun

100% TypeScript STUN implementation for WebRTC.

npm i webrtc-stun

Supported methods

  • RFC5389
    • BINDING
      • REQUEST
      • RESPONSE_SUCCESS / RESPONSE_ERROR

Not supported yet

Supported attributes

Not supported yet

Usage

import * as dgram from 'dgram';
import * as stun from '../src';
import * as pkg from '../package.json';

const socket = dgram.createSocket({ type: 'udp4' });
const tid = stun.generateTransactionId();

socket.on('message', msg => {
  const res = stun.createBlank();

  // if msg is valid STUN message
  if (res.loadBuffer(msg)) {
    // if msg is BINDING_RESPONSE_SUCCESS and valid content
    if (
      res.isBindingResponseSuccess({
        transactionId: tid,
        fingerprint: true,
      })
    ) {
      const attr = res.getXorMappedAddressAttribute();
      // if msg includes attr
      if (attr) {
        console.log('my rinfo', attr);
      }
    }
  }

  socket.close();
});

const req = stun
  .createBindingRequest(tid)
  .setSoftwareAttribute(`${pkg.name}@${pkg.version}`)
  .setFingerprintAttribute();

socket.send(req.toBuffer(), 19302, 'stun.l.google.com');

See also /examples directory.

Keywords

FAQs

Package last updated on 16 Jan 2019

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc