#4093 Peer and network settings accessible through the Web Client

This commit is contained in:
Mitchell Livingston 2011-03-10 01:37:58 +00:00
parent 15394498b0
commit a0afcac4b0
4 changed files with 157 additions and 11 deletions

View File

@ -229,6 +229,8 @@
<ul> <ul>
<li id="prefs_tab_general_tab" class="prefs_tab_enabled">General</li> <li id="prefs_tab_general_tab" class="prefs_tab_enabled">General</li>
<li id="prefs_tab_speed_tab" class="prefs_tab_disabled">Speed</li> <li id="prefs_tab_speed_tab" class="prefs_tab_disabled">Speed</li>
<li id="prefs_tab_peers_tab" class="prefs_tab_disabled">Peers</li>
<li id="prefs_tab_network_tab" class="prefs_tab_disabled">Network</li>
</ul> </ul>
<div id="prefs_tab_general" class="prefs_tab"> <div id="prefs_tab_general" class="prefs_tab">
<div class="preference download_location"> <div class="preference download_location">
@ -242,13 +244,6 @@
<label for="auto_start" class="item">Start transfers when added</label> <label for="auto_start" class="item">Start transfers when added</label>
</div> </div>
</div> </div>
<div class="preference port">
<label class="category">Network:</label>
<div class="formdiv">
<label for="port" class="item">Incoming TCP Port:</label>
<input type="text" id="port" name="port"/>
</div>
</div>
<div class="preference encryption"> <div class="preference encryption">
<label class="category">Encryption:</label> <label class="category">Encryption:</label>
<div class="formdiv checkbox"> <div class="formdiv checkbox">
@ -321,6 +316,75 @@
</div> </div>
<div style="clear: both; visibility: hidden;"></div> <div style="clear: both; visibility: hidden;"></div>
</div> </div>
<div id="prefs_tab_peers" class="prefs_tab" style="display: none;">
<div class="preference peers_conn">
<label class="category">Connections:</label>
<div class="formdiv">
<label for="conn_global" class="item">Global maximum connections:</label>
<input type="text" name="conn_global" id="conn_global"/>
<label class="suffix">peers</label>
</div>
<div class="formdiv">
<label for="conn_torrent" class="item">Maximum connections for new transfers:</label>
<input type="text" name="conn_torrent" id="conn_torrent"/>
<label class="suffix">peers</label>
</div>
<div class="formdiv checkbox">
<input type="checkbox" name="conn_pex" id="conn_pex"/>
<label for="conn_pex" class="item">Use peer exchange (PEX) for public torrents</label>
</div>
<div class="formdiv checkbox">
<input type="checkbox" name="conn_dht" id="conn_dht"/>
<label for="conn_dht" class="item">Use distributed hash table (DHT) for public torrents</label>
</div>
<div class="formdiv checkbox">
<input type="checkbox" name="conn_lpd" id="conn_lpd"/>
<label for="conn_lpd" class="item">Use local peer discovery for public torrents</label>
</div>
</div>
<div class="preference block_conn">
<label class="category">Blocklist:</label>
<div class="formdiv checkbox">
<input type="checkbox" name="block_enable" id="block_enable"/>
<label for="block_enable" class="item">Prevent peers in blocklist from connecting</label>
</div>
<div class="formdiv block_url">
<label for="block_url" class="item">URL:</label>
<input type="text" name="block_url" id="block_url"/>
</div>
<div class="formdiv">
<input type="button" name="block_update_button" id="block_update_button" value="Update"/>
<label class="suffix" id="block_size">IP rules in the list</label>
</div>
</div>
<div style="clear: both; visibility: hidden;"></div>
</div>
<div id="prefs_tab_network" class="prefs_tab" style="display: none;">
<div class="preference utp">
<label class="category">Peer communication:</label>
<div class="formdiv checkbox">
<input type="checkbox" name="network_utp" id="network_utp"/>
<label for="network_utp" class="item">Enable Micro Transport Protocol (µTP)</label>
</div>
</div>
<div class="preference port">
<label class="category">Peer listening port:</label>
<div class="formdiv">
<label for="port" class="item">Incoming TCP Port:</label>
<input type="text" id="port" name="port"/>
<label class="suffix" id="port_test"></label>
</div>
<div class="formdiv checkbox">
<input type="checkbox" name="port_rand" id="port_rand"/>
<label for="port_rand" class="item">Randomize port on launch</label>
</div>
<div class="formdiv checkbox">
<input type="checkbox" name="port_forward" id="port_forward"/>
<label for="port_forward" class="item">Automatically map port</label>
</div>
</div>
<div style="clear: both; visibility: hidden;"></div>
</div>
</div> </div>
<span id="transmission_version"></span> <span id="transmission_version"></span>
<a href="#save" id="prefs_save_button">Save</a> <a href="#save" id="prefs_save_button">Save</a>

View File

@ -1,5 +1,5 @@
/* /*
* Copyright © Dave Perrett and Malcolm Jarvis * Copyright © Dave Perrett, Malcolm Jarvis and Bruno Bierbaumer
* This code is licensed under the GPL version 2. * This code is licensed under the GPL version 2.
* For details, see http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * For details, see http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* *
@ -48,6 +48,7 @@ Transmission.prototype =
$('#filter_finished_link').parent().bind('click', function(e){ tr.showFinishedClicked(e); }); $('#filter_finished_link').parent().bind('click', function(e){ tr.showFinishedClicked(e); });
$('#prefs_save_button').bind('click', function(e) { tr.savePrefsClicked(e); return false;}); $('#prefs_save_button').bind('click', function(e) { tr.savePrefsClicked(e); return false;});
$('#prefs_cancel_button').bind('click', function(e){ tr.cancelPrefsClicked(e); return false; }); $('#prefs_cancel_button').bind('click', function(e){ tr.cancelPrefsClicked(e); return false; });
$('#block_update_button').bind('click', function(e){ tr.blocklistUpdateClicked(e); return false; });
$('#stats_close_button').bind('click', function(e){ tr.closeStatsClicked(e); return false; }); $('#stats_close_button').bind('click', function(e){ tr.closeStatsClicked(e); return false; });
$('.inspector_tab').bind('click', function(e){ tr.inspectorTabClicked(e, this); }); $('.inspector_tab').bind('click', function(e){ tr.inspectorTabClicked(e, this); });
$('.file_wanted_control').live('click', function(e){ tr.fileWantedClicked(e, this); }); $('.file_wanted_control').live('click', function(e){ tr.fileWantedClicked(e, this); });
@ -60,7 +61,10 @@ Transmission.prototype =
$('#turtle_button').bind('click', function(e){ tr.toggleTurtleClicked(e); return false; }); $('#turtle_button').bind('click', function(e){ tr.toggleTurtleClicked(e); return false; });
$('#prefs_tab_general_tab').click(function(e){ changeTab(this, 'prefs_tab_general') }); $('#prefs_tab_general_tab').click(function(e){ changeTab(this, 'prefs_tab_general') });
$('#prefs_tab_speed_tab').click(function(e){ changeTab(this, 'prefs_tab_speed') }); $('#prefs_tab_speed_tab').click(function(e){ changeTab(this, 'prefs_tab_speed') });
$('#prefs_tab_peers_tab').click(function(e){ changeTab(this, 'prefs_tab_peers') });
$('#prefs_tab_network_tab').click(function(e){ changeTab(this, 'prefs_tab_network');});
$('#torrent_upload_form').submit(function(){ $('#upload_confirm_button').click(); return false; }); $('#torrent_upload_form').submit(function(){ $('#upload_confirm_button').click(); return false; });
$('#torrent_upload_form').submit(function(){ $('#upload_confirm_button').click(); return false; });
if (iPhone) { if (iPhone) {
$('#inspector_close').bind('click', function(e){ tr.hideInspector(); }); $('#inspector_close').bind('click', function(e){ tr.hideInspector(); });
@ -149,6 +153,14 @@ Transmission.prototype =
tr.updateStats( o ); tr.updateStats( o );
}, async ); }, async );
}, },
checkPort: function( async ){
$('#port_test').text('checking ...')
var tr = this;
this.remote.checkPort( function(data){
var o = data.arguments;
tr.updatePortStatus( o );
}, async );
},
preloadImages: function() { preloadImages: function() {
if (iPhone) { if (iPhone) {
@ -189,7 +201,7 @@ Transmission.prototype =
*/ */
setupPrefConstraints: function() { setupPrefConstraints: function() {
// only allow integers for speed limit & port options // only allow integers for speed limit & port options
$('div.preference input[@type=text]:not(#download_location)').blur( function() { $('div.preference input[@type=text]:not(#download_location,#block_url)').blur( function() {
this.value = this.value.replace(/[^0-9]/gi, ''); this.value = this.value.replace(/[^0-9]/gi, '');
if (this.value == '') { if (this.value == '') {
if ($(this).is('#refresh_rate')) { if ($(this).is('#refresh_rate')) {
@ -636,6 +648,7 @@ Transmission.prototype =
savePrefsClicked: function(event) savePrefsClicked: function(event)
{ {
// handle the clutch prefs locally // handle the clutch prefs locally
var tr = this; var tr = this;
var rate = parseInt( $('#prefs_form #refresh_rate')[0].value ); var rate = parseInt( $('#prefs_form #refresh_rate')[0].value );
@ -669,10 +682,28 @@ Transmission.prototype =
o[RPC._TurtleTimeEnd] = parseInt( $('#prefs_form #turtle_end_time').val() ); o[RPC._TurtleTimeEnd] = parseInt( $('#prefs_form #turtle_end_time').val() );
o[RPC._TurtleTimeDay] = parseInt( $('#prefs_form #turtle_days').val() ); o[RPC._TurtleTimeDay] = parseInt( $('#prefs_form #turtle_days').val() );
o[RPC._PeerLimitGlobal] = parseInt( $('#prefs_form #conn_global').val() );
o[RPC._PeerLimitPerTorrent] = parseInt( $('#prefs_form #conn_torrent').val() );
o[RPC._PexEnabled] = $('#prefs_form #conn_pex')[0].checked;
o[RPC._DhtEnabled] = $('#prefs_form #conn_dht')[0].checked;
o[RPC._LpdEnabled] = $('#prefs_form #conn_lpd')[0].checked;
o[RPC._BlocklistEnabled] = $('#prefs_form #block_enable')[0].checked;
o[RPC._BlocklistURL] = $('#prefs_form #block_url').val();
o[RPC._UtpEnabled] = $('#prefs_form #network_utp')[0].checked;
o[RPC._PeerPortRandom] = $('#prefs_form #port_rand')[0].checked;
o[RPC._PortForwardingEnabled]= $('#prefs_form #port_forward')[0].checked;
tr.remote.savePrefs( o ); tr.remote.savePrefs( o );
tr.hidePrefsDialog( ); tr.hidePrefsDialog( );
}, },
blocklistUpdateClicked: function(event){
var tr = this;
tr.remote.updateBlocklist();
},
closeStatsClicked: function(event) { closeStatsClicked: function(event) {
this.hideStatsDialog( ); this.hideStatsDialog( );
@ -948,6 +979,7 @@ Transmission.prototype =
*--------------------------------------------*/ *--------------------------------------------*/
showPrefsDialog: function( ) { showPrefsDialog: function( ) {
this.checkPort(true);
$('body').addClass('prefs_showing'); $('body').addClass('prefs_showing');
$('#prefs_container').show(); $('#prefs_container').show();
this.hideiPhoneAddressbar(); this.hideiPhoneAddressbar();
@ -1008,6 +1040,19 @@ Transmission.prototype =
$('select#turtle_days').val( prefs[RPC._TurtleTimeDay] ); $('select#turtle_days').val( prefs[RPC._TurtleTimeDay] );
$('#transmission_version').text( prefs[RPC._DaemonVersion] ); $('#transmission_version').text( prefs[RPC._DaemonVersion] );
$('#conn_global').val( prefs[RPC._PeerLimitGlobal] );
$('#conn_torrent').val( prefs[RPC._PeerLimitPerTorrent] );
$('#conn_pex')[0].checked = prefs[RPC._PexEnabled];
$('#conn_dht')[0].checked = prefs[RPC._DhtEnabled];
$('#conn_lpd')[0].checked = prefs[RPC._LpdEnabled];
$('#block_enable')[0].checked = prefs[RPC._BlocklistEnabled];
$('#block_url').val( prefs[RPC._BlocklistURL]);
$('#block_size').text( prefs[RPC._BlocklistSize] + ' IP rules in the list' );
$('#network_utp')[0].checked = prefs[RPC._UtpEnabled];
$('#port_rand')[0].checked = prefs[RPC._PeerPortRandom];
$('#port_forward')[0].checked = prefs[RPC._PortForwardingEnabled];
if (!iPhone) if (!iPhone)
{ {
setInnerHTML( $('#limited_download_rate')[0], [ 'Limit (', Transmission.fmt.speed(dn_limit_k), ')' ].join('') ); setInnerHTML( $('#limited_download_rate')[0], [ 'Limit (', Transmission.fmt.speed(dn_limit_k), ')' ].join('') );
@ -1025,6 +1070,13 @@ Transmission.prototype =
this.updateTurtleButton(); this.updateTurtleButton();
}, },
updatePortStatus: function( status ){
if(status['port-is-open'])
$('#port_test').text('Port is open');
else
$('#port_test').text('Port is closed');
},
showStatsDialog: function( ) { showStatsDialog: function( ) {
this.loadDaemonStats(); this.loadDaemonStats();
$('body').addClass('stats_showing'); $('body').addClass('stats_showing');

View File

@ -1,5 +1,5 @@
/* /*
* Copyright © Dave Perrett and Malcolm Jarvis * Copyright © Dave Perrett, Malcolm Jarvis and Bruno Bierbaumer
* This code is licensed under the GPL version 2. * This code is licensed under the GPL version 2.
* For details, see http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * For details, see http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* *
@ -28,6 +28,17 @@ RPC._TurtleTimeEnabled = 'alt-speed-time-enabled';
RPC._TurtleTimeBegin = 'alt-speed-time-begin'; RPC._TurtleTimeBegin = 'alt-speed-time-begin';
RPC._TurtleTimeEnd = 'alt-speed-time-end'; RPC._TurtleTimeEnd = 'alt-speed-time-end';
RPC._TurtleTimeDay = 'alt-speed-time-day'; RPC._TurtleTimeDay = 'alt-speed-time-day';
RPC._PeerLimitGlobal = 'peer-limit-global';
RPC._PeerLimitPerTorrent = 'peer-limit-per-torrent';
RPC._PexEnabled = 'pex-enabled';
RPC._DhtEnabled = 'dht-enabled';
RPC._LpdEnabled = 'lpd-enabled';
RPC._BlocklistEnabled = 'blocklist-enabled';
RPC._BlocklistURL = 'blocklist-url';
RPC._BlocklistSize = 'blocklist-size';
RPC._UtpEnabled = 'utp-enabled';
RPC._PeerPortRandom = 'peer-port-random-on-start';
RPC._PortForwardingEnabled = 'port-forwarding-enabled';
RPC._StartAddedTorrent = 'start-added-torrents'; RPC._StartAddedTorrent = 'start-added-torrents';
function TransmissionRemote( controller ) function TransmissionRemote( controller )
@ -109,6 +120,12 @@ TransmissionRemote.prototype =
this.sendRequest( o, callback, async ); this.sendRequest( o, callback, async );
}, },
checkPort: function( callback, async ) {
var tr = this._controller;
var o = { method: 'port-test' };
this.sendRequest( o, callback, async );
},
loadDaemonStats: function( callback, async ) { loadDaemonStats: function( callback, async ) {
var tr = this._controller; var tr = this._controller;
var o = { method: 'session-stats' }; var o = { method: 'session-stats' };
@ -250,6 +267,15 @@ TransmissionRemote.prototype =
remote._controller.loadDaemonPrefs(); remote._controller.loadDaemonPrefs();
} ); } );
}, },
updateBlocklist: function() {
var remote = this;
var o = {
method: 'blocklist-update',
};
this.sendRequest( o, function() {
remote._controller.loadDaemonPrefs();
} );
},
filesSelectAll: function( torrent_ids, files, callback ) { filesSelectAll: function( torrent_ids, files, callback ) {
this.sendTorrentSetRequests( 'torrent-set', torrent_ids, { 'files-wanted': files }, callback ); this.sendTorrentSetRequests( 'torrent-set', torrent_ids, { 'files-wanted': files }, callback );
}, },

View File

@ -1220,6 +1220,10 @@ div#prefs_container div.preference input {
float: left; float: left;
} }
div#prefs_container div.block_url input {
width: 256px !important;
}
div#prefs_container div.download_location input { div#prefs_container div.download_location input {
width: 256px !important; width: 256px !important;
} }