Socket
Socket
Sign inDemoInstall

@tradle/dht-relay

Package Overview
Dependencies
29
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @tradle/dht-relay

bittorrent dht node that also functions as a udp relay, for getting around symmetric NATs


Version published
Maintainers
1
Install size
608 kB
Created

Readme

Source

dht-relay

bittorrent dht node that also functions as a udp relay, for getting around symmetric NATs

this module is used by Tradle

Usage

Command line
./cmd.js 25778 # port to run on
API
var Relay = require('dht-relay')
var relayAddr = {
  // specify relay ip:port
  address: '127.0.0.1',
  port: 25778
}

// use Relay.createServerWithDHT
// to limit connecting to clients to nodes known to internal DHT
var server = Relay.createServer(relayAddr.port)
var clientA = Relay.createClient(relayAddr)
clientA.bind()
var clientB = Relay.createClient(relayAddr)
clientB.bind()

var togo = 0
;[clientA, clientB, server].forEach(function (n, i) {
  togo++
  n.once('listening', start)
})

clientB.on('message', function (msg, rinfo) {
  // rinfo should be same as relayAddr
  console.log(msg.toString())
})

function start () {
  if (--togo === 0) {
    // message goes through relay
    clientA.send(new Buffer('hey'), 0, 3, clientB.address().port, '127.0.0.1')
  }
}

Todo

encode fwd'd messages to make them more compact (e.g. right now 'FWD:' and ip:port are unencoded)

Keywords

FAQs

Last updated on 21 Nov 2015

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc