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 = [
|
||||
[ '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' ]
|
||||
]
|
||||
|
||||
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 torrent
|
||||
console.debug '%c' + torrent.name + ' (' + torrent.infoHash + '): %c' + string, 'color: #33C3F0', 'color: #333'
|
||||
if torrent? && torrent.name
|
||||
console.debug '%cβTorrent:torrent:' + torrent.name + ' (' + torrent.infoHash + ') %c' + string, 'color: #33C3F0', 'color: ' + color
|
||||
return
|
||||
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'], ['$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):/
|
||||
$locationProvider.html5Mode(
|
||||
enabled: true
|
||||
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.seedIt = true
|
||||
$scope.client.validTorrents = []
|
||||
|
@ -74,20 +98,26 @@ app.controller 'bTorrentCtrl', ['$scope','$http','$log','$location', 'uiGridCons
|
|||
|
||||
$scope.seedFile = (file) ->
|
||||
if file?
|
||||
dbg 'Seeding ' + file.name
|
||||
dbg 'Seeding file ' + file.name
|
||||
$scope.client.processing = true
|
||||
$scope.client.seed file, opts, $scope.onSeed
|
||||
return
|
||||
|
||||
$scope.openTorrentFile = (file) ->
|
||||
if file?
|
||||
dbg 'Adding ' + file.name
|
||||
dbg 'Adding torrent file ' + file.name
|
||||
$scope.client.processing = true
|
||||
$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 = ->
|
||||
if $scope.torrentInput != ''
|
||||
dbg 'Adding ' + $scope.torrentInput
|
||||
dbg 'Adding magnet/hash ' + $scope.torrentInput
|
||||
$scope.client.processing = true
|
||||
$scope.client.add $scope.torrentInput, opts, $scope.onTorrent
|
||||
$scope.torrentInput = ''
|
||||
|
|
|
@ -1,28 +1,67 @@
|
|||
// Generated by CoffeeScript 1.10.0
|
||||
(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 = {
|
||||
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 (torrent) {
|
||||
console.debug('%c' + torrent.name + ' (' + torrent.infoHash + '): %c' + string, 'color: #33C3F0', 'color: #333');
|
||||
if ((torrent != null) && torrent.name) {
|
||||
console.debug('%cβTorrent:torrent:' + torrent.name + ' (' + torrent.infoHash + ') %c' + string, 'color: #33C3F0', 'color: ' + color);
|
||||
return;
|
||||
} else {
|
||||
console.debug('%cClient: %c' + string, 'color: #33C3F0', 'color: #333');
|
||||
console.debug('%cβTorrent:client %c' + string, 'color: #33C3F0', 'color: ' + color);
|
||||
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.aHrefSanitizationWhitelist(/^\s*(https?|magnet|blob|javascript):/);
|
||||
return $locationProvider.html5Mode({
|
||||
|
@ -33,7 +72,7 @@
|
|||
]);
|
||||
|
||||
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;
|
||||
$scope.client = client;
|
||||
$scope.seedIt = true;
|
||||
|
@ -116,21 +155,26 @@
|
|||
};
|
||||
$scope.seedFile = function(file) {
|
||||
if (file != null) {
|
||||
dbg('Seeding ' + file.name);
|
||||
dbg('Seeding file ' + file.name);
|
||||
$scope.client.processing = true;
|
||||
$scope.client.seed(file, opts, $scope.onSeed);
|
||||
}
|
||||
};
|
||||
$scope.openTorrentFile = function(file) {
|
||||
if (file != null) {
|
||||
dbg('Adding ' + file.name);
|
||||
dbg('Adding torrent file ' + file.name);
|
||||
$scope.client.processing = true;
|
||||
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() {
|
||||
if ($scope.torrentInput !== '') {
|
||||
dbg('Adding ' + $scope.torrentInput);
|
||||
dbg('Adding magnet/hash ' + $scope.torrentInput);
|
||||
$scope.client.processing = true;
|
||||
$scope.client.add($scope.torrentInput, opts, $scope.onTorrent);
|
||||
$scope.torrentInput = '';
|
||||
|
|
|
@ -8,16 +8,16 @@
|
|||
<meta name="keywords" content="βTorrent, btorrent, client, webtorrent, browser, torrent, stream, bittorrent">
|
||||
<meta name="author" content="Diego Rodríguez Baquero - DiegoRBaquero">
|
||||
<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>
|
||||
<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/angular.ui-grid/3.0.7/ui-grid.min.css">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body ng-controller="bTorrentCtrl" ng-cloak="">
|
||||
<header>
|
||||
<h1>βTorrent<span class="version"> v0.6.3</span></h1>
|
||||
<h1>βTorrent<span class="version"> v0.7.0</span></h1>
|
||||
</header>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
|
@ -25,7 +25,7 @@
|
|||
<input type="text" placeholder="magnet link or hash" ng-model="torrentInput" class="u-full-width">
|
||||
</div>
|
||||
<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 class="three columns">
|
||||
<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='author', content='Diego Rodríguez Baquero - DiegoRBaquero')
|
||||
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')
|
||||
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/angular.ui-grid/3.0.7/ui-grid.min.css')
|
||||
link(rel='stylesheet', href='style.css')
|
||||
|
@ -18,14 +18,14 @@ html(ng-app='bTorrent', lang='en')
|
|||
header
|
||||
h1
|
||||
| βTorrent
|
||||
span.version v0.6.3
|
||||
span.version v0.7.0
|
||||
|
||||
.container
|
||||
.row
|
||||
.four.columns
|
||||
input.u-full-width(type='text', placeholder='magnet link or hash', ng-model='torrentInput')
|
||||
.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
|
||||
| Download
|
||||
.three.columns
|
||||
|
|
Loading…
Reference in a new issue