Added notification on error, fixed input, STUN/TURN servers
This commit is contained in:
parent
87f3d09cf2
commit
b6cc2d7919
4 changed files with 111 additions and 37 deletions
62
app.coffee
62
app.coffee
|
@ -1,35 +1,59 @@
|
||||||
trackers = [
|
trackers = [
|
||||||
[ 'udp://tracker.openbittorrent.com:80' ],
|
|
||||||
[ 'udp://tracker.internetwarriors.net:1337' ],
|
|
||||||
[ 'udp://tracker.leechers-paradise.org:6969' ],
|
|
||||||
[ 'udp://tracker.coppersurfer.tk:6969' ],
|
|
||||||
[ 'udp://exodus.desync.com:6969' ],
|
|
||||||
[ 'wss://tracker.webtorrent.io' ],
|
[ 'wss://tracker.webtorrent.io' ],
|
||||||
[ 'wss://tracker.btorrent.xyz' ]
|
[ 'wss://tracker.btorrent.xyz' ]
|
||||||
]
|
]
|
||||||
|
|
||||||
opts = {announce: trackers}
|
opts = {
|
||||||
|
announce: trackers
|
||||||
|
announceList: trackers
|
||||||
|
rtcConfig: {
|
||||||
|
"iceServers":[
|
||||||
|
{"url":"stun:23.21.150.121","urls":"stun:23.21.150.121"},
|
||||||
|
{"url":"stun:stun.l.google.com:19302","urls":"stun:stun.l.google.com:19302"},
|
||||||
|
{"url":"stun:stun1.l.google.com:19302","urls":"stun:stun1.l.google.com:19302"},
|
||||||
|
{"url":"stun:stun2.l.google.com:19302","urls":"stun:stun2.l.google.com:19302"},
|
||||||
|
{"url":"stun:stun3.l.google.com:19302","urls":"stun:stun3.l.google.com:19302"},
|
||||||
|
{"url":"stun:stun4.l.google.com:19302","urls":"stun:stun4.l.google.com:19302"},
|
||||||
|
{
|
||||||
|
"url":"turn:global.turn.twilio.com:3478?transport=udp",
|
||||||
|
"urls":"turn:global.turn.twilio.com:3478?transport=udp",
|
||||||
|
"username":"857315a4616be37252127d4ff924c3a3536dd3fa729b56206dfa0e6808a80478",
|
||||||
|
"credential":"EEEr7bxx8umMHC4sOoWDC/4MxU/4JCfL+W7KeSJEsBQ="
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"url": "turn:numb.viagenie.ca",
|
||||||
|
"urls": "turn:numb.viagenie.ca",
|
||||||
|
"credential": "webrtcdemo",
|
||||||
|
"username": "louis%40mozilla.com"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
client = new WebTorrent
|
client = new WebTorrent opts
|
||||||
|
|
||||||
dbg = (string, torrent) ->
|
dbg = (string, torrent, color) ->
|
||||||
|
color = if color? then color else '#333333'
|
||||||
if window.localStorage.getItem('debug')?
|
if window.localStorage.getItem('debug')?
|
||||||
if torrent
|
if torrent? && torrent.name
|
||||||
console.debug '%c' + torrent.name + ' (' + torrent.infoHash + '): %c' + string, 'color: #33C3F0', 'color: #333'
|
console.debug '%cβTorrent:torrent:' + torrent.name + ' (' + torrent.infoHash + ') %c' + string, 'color: #33C3F0', 'color: ' + color
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
console.debug '%cClient: %c' + string, 'color: #33C3F0', 'color: #333'
|
console.debug '%cβTorrent:client %c' + string, 'color: #33C3F0', 'color: ' + color
|
||||||
return
|
return
|
||||||
return
|
return
|
||||||
|
|
||||||
app = angular.module 'bTorrent', ['ui.grid', 'ui.grid.resizeColumns', 'ui.grid.selection', 'ngFileUpload'], ['$compileProvider','$locationProvider', ($compileProvider, $locationProvider) ->
|
er = (err, torrent) ->
|
||||||
|
dbg err, torrent, '#FF0000'
|
||||||
|
|
||||||
|
app = angular.module 'bTorrent', ['ui.grid', 'ui.grid.resizeColumns', 'ui.grid.selection', 'ngFileUpload', 'ngNotify'], ['$compileProvider','$locationProvider', ($compileProvider, $locationProvider) ->
|
||||||
$compileProvider.aHrefSanitizationWhitelist /^\s*(https?|magnet|blob|javascript):/
|
$compileProvider.aHrefSanitizationWhitelist /^\s*(https?|magnet|blob|javascript):/
|
||||||
$locationProvider.html5Mode(
|
$locationProvider.html5Mode(
|
||||||
enabled: true
|
enabled: true
|
||||||
requireBase: false).hashPrefix '#'
|
requireBase: false).hashPrefix '#'
|
||||||
]
|
]
|
||||||
|
|
||||||
app.controller 'bTorrentCtrl', ['$scope','$http','$log','$location', 'uiGridConstants', ($scope, $http, $log, $location, uiGridConstants) ->
|
app.controller 'bTorrentCtrl', ['$scope','$http','$log','$location', 'ngNotify', ($scope, $http, $log, $location, ngNotify) ->
|
||||||
$scope.client = client
|
$scope.client = client
|
||||||
$scope.seedIt = true
|
$scope.seedIt = true
|
||||||
$scope.client.validTorrents = []
|
$scope.client.validTorrents = []
|
||||||
|
@ -74,20 +98,26 @@ app.controller 'bTorrentCtrl', ['$scope','$http','$log','$location', 'uiGridCons
|
||||||
|
|
||||||
$scope.seedFile = (file) ->
|
$scope.seedFile = (file) ->
|
||||||
if file?
|
if file?
|
||||||
dbg 'Seeding ' + file.name
|
dbg 'Seeding file ' + file.name
|
||||||
$scope.client.processing = true
|
$scope.client.processing = true
|
||||||
$scope.client.seed file, opts, $scope.onSeed
|
$scope.client.seed file, opts, $scope.onSeed
|
||||||
return
|
return
|
||||||
|
|
||||||
$scope.openTorrentFile = (file) ->
|
$scope.openTorrentFile = (file) ->
|
||||||
if file?
|
if file?
|
||||||
dbg 'Adding ' + file.name
|
dbg 'Adding torrent file ' + file.name
|
||||||
$scope.client.processing = true
|
$scope.client.processing = true
|
||||||
$scope.client.add file, opts, $scope.onTorrent
|
$scope.client.add file, opts, $scope.onTorrent
|
||||||
|
|
||||||
|
$scope.client.on('error', (err, torrent) ->
|
||||||
|
$scope.client.processing = false
|
||||||
|
ngNotify.set(err, 'error');
|
||||||
|
er err, torrent
|
||||||
|
)
|
||||||
|
|
||||||
$scope.addMagnet = ->
|
$scope.addMagnet = ->
|
||||||
if $scope.torrentInput != ''
|
if $scope.torrentInput != ''
|
||||||
dbg 'Adding ' + $scope.torrentInput
|
dbg 'Adding magnet/hash ' + $scope.torrentInput
|
||||||
$scope.client.processing = true
|
$scope.client.processing = true
|
||||||
$scope.client.add $scope.torrentInput, opts, $scope.onTorrent
|
$scope.client.add $scope.torrentInput, opts, $scope.onTorrent
|
||||||
$scope.torrentInput = ''
|
$scope.torrentInput = ''
|
||||||
|
|
|
@ -1,28 +1,67 @@
|
||||||
// Generated by CoffeeScript 1.10.0
|
// Generated by CoffeeScript 1.10.0
|
||||||
(function() {
|
(function() {
|
||||||
var app, client, dbg, opts, trackers;
|
var app, client, dbg, er, opts, trackers;
|
||||||
|
|
||||||
trackers = [['udp://tracker.openbittorrent.com:80'], ['udp://tracker.internetwarriors.net:1337'], ['udp://tracker.leechers-paradise.org:6969'], ['udp://tracker.coppersurfer.tk:6969'], ['udp://exodus.desync.com:6969'], ['wss://tracker.webtorrent.io'], ['wss://tracker.btorrent.xyz']];
|
trackers = [['wss://tracker.webtorrent.io'], ['wss://tracker.btorrent.xyz']];
|
||||||
|
|
||||||
opts = {
|
opts = {
|
||||||
announce: trackers
|
announce: trackers,
|
||||||
|
announceList: trackers,
|
||||||
|
rtcConfig: {
|
||||||
|
"iceServers": [
|
||||||
|
{
|
||||||
|
"url": "stun:23.21.150.121",
|
||||||
|
"urls": "stun:23.21.150.121"
|
||||||
|
}, {
|
||||||
|
"url": "stun:stun.l.google.com:19302",
|
||||||
|
"urls": "stun:stun.l.google.com:19302"
|
||||||
|
}, {
|
||||||
|
"url": "stun:stun1.l.google.com:19302",
|
||||||
|
"urls": "stun:stun1.l.google.com:19302"
|
||||||
|
}, {
|
||||||
|
"url": "stun:stun2.l.google.com:19302",
|
||||||
|
"urls": "stun:stun2.l.google.com:19302"
|
||||||
|
}, {
|
||||||
|
"url": "stun:stun3.l.google.com:19302",
|
||||||
|
"urls": "stun:stun3.l.google.com:19302"
|
||||||
|
}, {
|
||||||
|
"url": "stun:stun4.l.google.com:19302",
|
||||||
|
"urls": "stun:stun4.l.google.com:19302"
|
||||||
|
}, {
|
||||||
|
"url": "turn:global.turn.twilio.com:3478?transport=udp",
|
||||||
|
"urls": "turn:global.turn.twilio.com:3478?transport=udp",
|
||||||
|
"username": "857315a4616be37252127d4ff924c3a3536dd3fa729b56206dfa0e6808a80478",
|
||||||
|
"credential": "EEEr7bxx8umMHC4sOoWDC/4MxU/4JCfL+W7KeSJEsBQ="
|
||||||
|
}, {
|
||||||
|
"url": "turn:numb.viagenie.ca",
|
||||||
|
"urls": "turn:numb.viagenie.ca",
|
||||||
|
"credential": "webrtcdemo",
|
||||||
|
"username": "louis%40mozilla.com"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
client = new WebTorrent;
|
client = new WebTorrent(opts);
|
||||||
|
|
||||||
dbg = function(string, torrent) {
|
dbg = function(string, torrent, color) {
|
||||||
|
color = color != null ? color : '#333333';
|
||||||
if (window.localStorage.getItem('debug') != null) {
|
if (window.localStorage.getItem('debug') != null) {
|
||||||
if (torrent) {
|
if ((torrent != null) && torrent.name) {
|
||||||
console.debug('%c' + torrent.name + ' (' + torrent.infoHash + '): %c' + string, 'color: #33C3F0', 'color: #333');
|
console.debug('%cβTorrent:torrent:' + torrent.name + ' (' + torrent.infoHash + ') %c' + string, 'color: #33C3F0', 'color: ' + color);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
console.debug('%cClient: %c' + string, 'color: #33C3F0', 'color: #333');
|
console.debug('%cβTorrent:client %c' + string, 'color: #33C3F0', 'color: ' + color);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
app = angular.module('bTorrent', ['ui.grid', 'ui.grid.resizeColumns', 'ui.grid.selection', 'ngFileUpload'], [
|
er = function(err, torrent) {
|
||||||
|
return dbg(err, torrent, '#FF0000');
|
||||||
|
};
|
||||||
|
|
||||||
|
app = angular.module('bTorrent', ['ui.grid', 'ui.grid.resizeColumns', 'ui.grid.selection', 'ngFileUpload', 'ngNotify'], [
|
||||||
'$compileProvider', '$locationProvider', function($compileProvider, $locationProvider) {
|
'$compileProvider', '$locationProvider', function($compileProvider, $locationProvider) {
|
||||||
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|magnet|blob|javascript):/);
|
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|magnet|blob|javascript):/);
|
||||||
return $locationProvider.html5Mode({
|
return $locationProvider.html5Mode({
|
||||||
|
@ -33,7 +72,7 @@
|
||||||
]);
|
]);
|
||||||
|
|
||||||
app.controller('bTorrentCtrl', [
|
app.controller('bTorrentCtrl', [
|
||||||
'$scope', '$http', '$log', '$location', 'uiGridConstants', function($scope, $http, $log, $location, uiGridConstants) {
|
'$scope', '$http', '$log', '$location', 'ngNotify', function($scope, $http, $log, $location, ngNotify) {
|
||||||
var updateAll;
|
var updateAll;
|
||||||
$scope.client = client;
|
$scope.client = client;
|
||||||
$scope.seedIt = true;
|
$scope.seedIt = true;
|
||||||
|
@ -116,21 +155,26 @@
|
||||||
};
|
};
|
||||||
$scope.seedFile = function(file) {
|
$scope.seedFile = function(file) {
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
dbg('Seeding ' + file.name);
|
dbg('Seeding file ' + file.name);
|
||||||
$scope.client.processing = true;
|
$scope.client.processing = true;
|
||||||
$scope.client.seed(file, opts, $scope.onSeed);
|
$scope.client.seed(file, opts, $scope.onSeed);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
$scope.openTorrentFile = function(file) {
|
$scope.openTorrentFile = function(file) {
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
dbg('Adding ' + file.name);
|
dbg('Adding torrent file ' + file.name);
|
||||||
$scope.client.processing = true;
|
$scope.client.processing = true;
|
||||||
return $scope.client.add(file, opts, $scope.onTorrent);
|
return $scope.client.add(file, opts, $scope.onTorrent);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
$scope.client.on('error', function(err, torrent) {
|
||||||
|
$scope.client.processing = false;
|
||||||
|
ngNotify.set(err, 'error');
|
||||||
|
return er(err, torrent);
|
||||||
|
});
|
||||||
$scope.addMagnet = function() {
|
$scope.addMagnet = function() {
|
||||||
if ($scope.torrentInput !== '') {
|
if ($scope.torrentInput !== '') {
|
||||||
dbg('Adding ' + $scope.torrentInput);
|
dbg('Adding magnet/hash ' + $scope.torrentInput);
|
||||||
$scope.client.processing = true;
|
$scope.client.processing = true;
|
||||||
$scope.client.add($scope.torrentInput, opts, $scope.onTorrent);
|
$scope.client.add($scope.torrentInput, opts, $scope.onTorrent);
|
||||||
$scope.torrentInput = '';
|
$scope.torrentInput = '';
|
||||||
|
|
|
@ -8,16 +8,16 @@
|
||||||
<meta name="keywords" content="βTorrent, btorrent, client, webtorrent, browser, torrent, stream, bittorrent">
|
<meta name="keywords" content="βTorrent, btorrent, client, webtorrent, browser, torrent, stream, bittorrent">
|
||||||
<meta name="author" content="Diego Rodríguez Baquero - DiegoRBaquero">
|
<meta name="author" content="Diego Rodríguez Baquero - DiegoRBaquero">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<script src="https://cdn.jsdelivr.net/g/webtorrent@0.63.3,momentjs@2.10,angularjs@1.4,angular.ui-grid@3.0"></script>
|
<script src="https://cdn.jsdelivr.net/g/webtorrent@0.63.3,momentjs@2.10,angularjs@1.4,angular.ui-grid@3.0,angular.ng-notify@0.7"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/danialfarid-angular-file-upload/10.1.8/ng-file-upload.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/danialfarid-angular-file-upload/10.1.8/ng-file-upload.min.js"></script>
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/g/normalize@3.0,skeleton@2.0">
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/g/normalize@3.0,skeleton@2.0,angular.ng-notify@0.7(ng-notify.min.css)">
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/fontawesome/4.5/css/font-awesome.min.css">
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/fontawesome/4.5/css/font-awesome.min.css">
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/angular.ui-grid/3.0.7/ui-grid.min.css">
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/angular.ui-grid/3.0.7/ui-grid.min.css">
|
||||||
<link rel="stylesheet" href="style.css">
|
<link rel="stylesheet" href="style.css">
|
||||||
</head>
|
</head>
|
||||||
<body ng-controller="bTorrentCtrl" ng-cloak="">
|
<body ng-controller="bTorrentCtrl" ng-cloak="">
|
||||||
<header>
|
<header>
|
||||||
<h1>βTorrent<span class="version"> v0.6.3</span></h1>
|
<h1>βTorrent<span class="version"> v0.7.0</span></h1>
|
||||||
</header>
|
</header>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
<input type="text" placeholder="magnet link or hash" ng-model="torrentInput" class="u-full-width">
|
<input type="text" placeholder="magnet link or hash" ng-model="torrentInput" class="u-full-width">
|
||||||
</div>
|
</div>
|
||||||
<div class="two columns download-button">
|
<div class="two columns download-button">
|
||||||
<button ng-click="addMagnet()" class="button-primary"><i class="fa fa-download"></i> Download</button>
|
<button ng-click="addMagnet()" ng-disabled="!torrentInput.length" ng-class="{'button-primary': torrentInput.length}"><i class="fa fa-download"></i> Download</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="three columns">
|
<div class="three columns">
|
||||||
<button type="file" ngf-select="openTorrentFile($file)" class="button-primary"><i class="fa fa-folder-open"></i> Open torrent file</button>
|
<button type="file" ngf-select="openTorrentFile($file)" class="button-primary"><i class="fa fa-folder-open"></i> Open torrent file</button>
|
||||||
|
|
|
@ -8,9 +8,9 @@ html(ng-app='bTorrent', lang='en')
|
||||||
meta(name='keywords', content='βTorrent, btorrent, client, webtorrent, browser, torrent, stream, bittorrent')
|
meta(name='keywords', content='βTorrent, btorrent, client, webtorrent, browser, torrent, stream, bittorrent')
|
||||||
meta(name='author', content='Diego Rodríguez Baquero - DiegoRBaquero')
|
meta(name='author', content='Diego Rodríguez Baquero - DiegoRBaquero')
|
||||||
meta(name='viewport', content='width=device-width, initial-scale=1')
|
meta(name='viewport', content='width=device-width, initial-scale=1')
|
||||||
script(src='https://cdn.jsdelivr.net/g/webtorrent@0.63.3,momentjs@2.10,angularjs@1.4,angular.ui-grid@3.0')
|
script(src='https://cdn.jsdelivr.net/g/webtorrent@0.63.3,momentjs@2.10,angularjs@1.4,angular.ui-grid@3.0,angular.ng-notify@0.7')
|
||||||
script(src='https://cdnjs.cloudflare.com/ajax/libs/danialfarid-angular-file-upload/10.1.8/ng-file-upload.min.js')
|
script(src='https://cdnjs.cloudflare.com/ajax/libs/danialfarid-angular-file-upload/10.1.8/ng-file-upload.min.js')
|
||||||
link(rel='stylesheet', href='https://cdn.jsdelivr.net/g/normalize@3.0,skeleton@2.0')
|
link(rel='stylesheet', href='https://cdn.jsdelivr.net/g/normalize@3.0,skeleton@2.0,angular.ng-notify@0.7(ng-notify.min.css)')
|
||||||
link(rel='stylesheet', href='https://cdn.jsdelivr.net/fontawesome/4.5/css/font-awesome.min.css')
|
link(rel='stylesheet', href='https://cdn.jsdelivr.net/fontawesome/4.5/css/font-awesome.min.css')
|
||||||
link(rel='stylesheet', href='https://cdn.jsdelivr.net/angular.ui-grid/3.0.7/ui-grid.min.css')
|
link(rel='stylesheet', href='https://cdn.jsdelivr.net/angular.ui-grid/3.0.7/ui-grid.min.css')
|
||||||
link(rel='stylesheet', href='style.css')
|
link(rel='stylesheet', href='style.css')
|
||||||
|
@ -18,14 +18,14 @@ html(ng-app='bTorrent', lang='en')
|
||||||
header
|
header
|
||||||
h1
|
h1
|
||||||
| βTorrent
|
| βTorrent
|
||||||
span.version v0.6.3
|
span.version v0.7.0
|
||||||
|
|
||||||
.container
|
.container
|
||||||
.row
|
.row
|
||||||
.four.columns
|
.four.columns
|
||||||
input.u-full-width(type='text', placeholder='magnet link or hash', ng-model='torrentInput')
|
input.u-full-width(type='text', placeholder='magnet link or hash', ng-model='torrentInput')
|
||||||
.two.columns.download-button
|
.two.columns.download-button
|
||||||
button.button-primary(ng-click='addMagnet()')
|
button(ng-click='addMagnet()', ng-disabled='!torrentInput.length', ng-class="{'button-primary': torrentInput.length}")
|
||||||
i.fa.fa-download
|
i.fa.fa-download
|
||||||
| Download
|
| Download
|
||||||
.three.columns
|
.three.columns
|
||||||
|
|
Loading…
Reference in a new issue