{"size": 976, "ext": "js", "max_stars_repo_path": "public/remoting/bridge.js", "max_stars_repo_name": "genecyber/RibbitFlow", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "public/remoting/bridge.js", "max_issues_repo_name": "genecyber/RibbitFlow", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "public/remoting/bridge.js", "max_forks_repo_name": "genecyber/RibbitFlow", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.7058823529, "max_line_length": 155, "alphanum_fraction": 0.6864754098}
#!/usr/bin/env node

try {
  require('wrtc')
} catch(e) {
  console.error('The "wrtc" package is not installed.')
  console.error('Please install its dependencies (see https://github.com/js-platform/node-webrtc#prerequisites), then install it with `npm install wrtc`.')
  //process.exit()
  return
}

var Networks = require('bitcore').Networks
var Bridge = require('../lib/bridge.js')
var argv = require('minimist')(process.argv.slice(2))

var bridge = new Bridge({
  network: argv.testnet ? Networks.testnet : Networks.livenet,
  localPeer: argv.local
})

bridge.on('connection', function (peer, id) {
  console.log('Incoming connection:', id)
  peer.on('disconnect', function () {
    console.log('Disconnected from peer:', id)
  })
  peer.on('error', function (err) {
    console.error('Peer error:', err)
  })
})

bridge.on('bridge', function (webPeer, tcpPeer) {
  console.log('Bridging WebRTC connection to tcp://' + tcpPeer.remoteAddress + ':' + tcpPeer.remotePort)
})
