[#2082] [WebUI] [Console] Validate interface entry for IP address
This commit is contained in:
parent
8d74c3f22a
commit
cb87509e4f
|
@ -35,6 +35,7 @@
|
|||
|
||||
from deluge.ui.console.modes.input_popup import TextInput,SelectInput,CheckedInput,IntSpinInput,FloatSpinInput,CheckedPlusInput
|
||||
import deluge.ui.console.modes.alltorrents
|
||||
from deluge.common import is_ip
|
||||
|
||||
try:
|
||||
import curses
|
||||
|
@ -106,12 +107,16 @@ class BasePane:
|
|||
# gross, have to special case in/out ports since they are tuples
|
||||
if ipt.name in ("listen_ports_to", "listen_ports_from", "out_ports_from", "out_ports_to",
|
||||
"i2p_port", "i2p_hostname", "proxy_type", "proxy_username", "proxy_hostnames",
|
||||
"proxy_password", "proxy_hostname", "proxy_port", "proxy_peer_connections"
|
||||
):
|
||||
"proxy_password", "proxy_hostname", "proxy_port", "proxy_peer_connections",
|
||||
"listen_interface"):
|
||||
if ipt.name == "listen_ports_to":
|
||||
conf_dict["listen_ports"] = (self.infrom.get_value(),self.into.get_value())
|
||||
elif ipt.name == "out_ports_to":
|
||||
conf_dict["outgoing_ports"] = (self.outfrom.get_value(),self.outto.get_value())
|
||||
elif ipt.name == "listen_interface":
|
||||
interface = ipt.get_value().strip()
|
||||
if is_ip(interface) or not interface:
|
||||
conf_dict["listen_interface"] = interface
|
||||
elif ipt.name == "i2p_port":
|
||||
conf_dict.setdefault("i2p_proxy", {})["port"] = ipt.get_value()
|
||||
elif ipt.name == "i2p_hostname":
|
||||
|
@ -131,6 +136,7 @@ class BasePane:
|
|||
elif ipt.name == "proxy_peer_connections":
|
||||
conf_dict.setdefault("proxy", {})["proxy_peer_connections"] = ipt.get_value()
|
||||
|
||||
|
||||
else:
|
||||
conf_dict[ipt.name] = ipt.get_value()
|
||||
if hasattr(ipt,"get_child"):
|
||||
|
|
|
@ -31,6 +31,15 @@
|
|||
*/
|
||||
Ext.namespace('Deluge.preferences');
|
||||
|
||||
// custom Vtype for vtype:'IPAddress'
|
||||
Ext.apply(Ext.form.field.VTypes, {
|
||||
IPAddress: function(v) {
|
||||
return /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(v);
|
||||
},
|
||||
IPAddressText: 'Must be a numeric IP address',
|
||||
IPAddressMask: /[\d\.]/i
|
||||
});
|
||||
|
||||
/**
|
||||
* @class Deluge.preferences.Network
|
||||
* @extends Ext.form.FormPanel
|
||||
|
@ -44,7 +53,7 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
|
|||
initComponent: function() {
|
||||
Deluge.preferences.Network.superclass.initComponent.call(this);
|
||||
var optMan = deluge.preferences.getOptionsManager();
|
||||
|
||||
console.log(Ext.form.VTypes);
|
||||
fieldset = this.add({
|
||||
xtype: 'fieldset',
|
||||
border: false,
|
||||
|
@ -58,7 +67,8 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
|
|||
name: 'listen_interface',
|
||||
fieldLabel: '',
|
||||
labelSeparator: '',
|
||||
width: 200
|
||||
width: 200,
|
||||
vtype: 'IPAddress',
|
||||
}));
|
||||
|
||||
var fieldset = this.add({
|
||||
|
|
Loading…
Reference in New Issue