Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
jhiesey committed Jan 23, 2020
1 parent 39f5d38 commit 8b79838
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 28 deletions.
13 changes: 9 additions & 4 deletions client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ var debug = require('debug')('peercloud.io')
var mime = require('mime')
var Peer = require('simple-peer')
var thunky = require('thunky')
var toArrayBuffer = require('to-arraybuffer')
var WebTorrent = require('webtorrent')
var xhr = require('xhr')

var TRACKER_URL = 'wss://tracker.webtorrent.io'

global.WEBTORRENT_ANNOUNCE = [ TRACKER_URL ]
global.WEBTORRENT_ANNOUNCE = [ 'wss://tracker.openwebtorrent.com', 'wss://tracker.btorrent.xyz', 'wss://tracker.fastcast.nz' ]

if (!Peer.WEBRTC_SUPPORT || !navigator.serviceWorker) {
alert('This browser is unsupported. Please use a browser with WebRTC support and ServiceWorker support.')
Expand Down Expand Up @@ -53,7 +54,7 @@ function fetchFileFromTorrent(torrent, path, cb) {
if (file.path === torrent.name + '/' + path) {
file.getBuffer(function (err, buffer) {
if (err) return cb(err);
cb(null, buffer.toArrayBuffer());
cb(null, toArrayBuffer(buffer));
});
return;
}
Expand Down Expand Up @@ -141,7 +142,7 @@ navigator.serviceWorker.register('/service-worker.js').then(function (registrati
if (!err) {
msg.response = {
body: buffer,
mime: mime.lookup(data.path)
mime: mime.getType(data.path)
}
} else {
msg.err = err.message
Expand Down Expand Up @@ -197,7 +198,11 @@ var getClient = thunky(function (cb) {
}
debug('got rtc config: %o', rtcConfig)
}
var client = new WebTorrent({ rtcConfig: rtcConfig })
var client = new WebTorrent({
tracker: {
rtcConfig
}
})
client.on('warning', console.warn)
client.on('error', console.error)
cb(null, client)
Expand Down
2 changes: 1 addition & 1 deletion config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
exports.ports = {
http: 9200
http: 9100
}
33 changes: 17 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,25 @@
"url": "https://github.com/jhiesey/peercloud/issues"
},
"dependencies": {
"compression": "^1.0.9",
"debug": "^2.0.0",
"express": "^4.8.5",
"jade": "^1.5.0",
"mime": "^1.3.4",
"simple-peer": "^5.3.0",
"thunky": "^0.1.0",
"twilio": "^2.1.0",
"compression": "^1.7.4",
"debug": "^4.1.1",
"express": "^4.17.1",
"mime": "^2.4.4",
"pug": "^2.0.4",
"simple-peer": "^9.6.2",
"thunky": "^1.1.0",
"to-arraybuffer": "^1.0.1",
"twilio": "^3.39.3",
"webtorrent": "0.x",
"xhr": "^2.0.0"
"xhr": "^2.5.0"
},
"devDependencies": {
"browserify": "^10.0.0",
"nib": "^1.0.3",
"nodemon": "^1.2.1",
"standard": "^3.1.1",
"stylus": "^0.51.0",
"watchify": "^3.1.0"
"browserify": "^16.5.0",
"nib": "^1.1.2",
"nodemon": "^2.0.2",
"standard": "^14.3.1",
"stylus": "^0.54.7",
"watchify": "^3.11.0"
},
"homepage": "https://peercloud.io",
"keywords": [
Expand All @@ -51,7 +52,7 @@
"secret-upload": "rsync -a -O -v --delete secret/ hiesey.com:/home/jhiesey/www/peercloud.io/secret/",
"start": "node server",
"test": "standard",
"watch": "npm run watch-css & npm run watch-js & DEBUG=peercloud* nodemon server -e js,jade -d 1",
"watch": "npm run watch-css & npm run watch-js & DEBUG=peercloud* nodemon server -e js,pug -d 1",
"watch-css": "stylus -u nib css/main.styl -o static/ -w",
"watch-js": "watchify client -o static/bundle.js -dv"
}
Expand Down
13 changes: 6 additions & 7 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var compress = require('compression')
var debug = require('debug')('peercloud')
var express = require('express')
var http = require('http')
var jade = require('jade')
var pug = require('pug')
var path = require('path')
var url = require('url')
var twilio = require('twilio')
Expand All @@ -15,9 +15,8 @@ var httpServer = http.createServer(app)

// Templating
app.set('views', __dirname + '/views')
app.set('view engine', 'jade')
app.set('view engine', 'pug')
app.set('x-powered-by', false)
app.engine('jade', jade.renderFile)

app.use(compress())

Expand Down Expand Up @@ -56,18 +55,18 @@ app.get('/', function (req, res) {
res.render('index')
})

// Fetch new ice_servers from twilio token regularly
// Fetch new iceServers from twilio token regularly
var iceServers
var twilioClient = twilio(secret.twilio.accountSid, secret.twilio.authToken)

function updateIceServers () {
twilioClient.tokens.create({}, function (err, token) {
if (err) return error(err)
if (!token.ice_servers) {
return error(new Error('twilio response ' + token + ' missing ice_servers'))
if (!token.iceServers) {
return error(new Error('twilio response ' + token + ' missing iceServers'))
}

iceServers = token.ice_servers
iceServers = token.iceServers
.filter(function (server) {
var urls = server.urls || server.url
return urls && !/^stun:/.test(urls)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 8b79838

Please sign in to comment.