9 var callInitAction
, callUpnpGetStatus
, callUpnpDeleteRule
, handleDelRule
;
11 callInitAction
= rpc
.declare({
13 method
: 'setInitAction',
14 params
: [ 'name', 'action' ],
15 expect
: { result
: false }
18 callUpnpGetStatus
= rpc
.declare({
24 callUpnpDeleteRule
= rpc
.declare({
26 method
: 'delete_rule',
28 expect
: { result
: "OK" },
31 handleDelRule = function(num
, ev
) {
32 dom
.parent(ev
.currentTarget
, '.tr').style
.opacity
= 0.5;
33 ev
.currentTarget
.classList
.add('spinning');
34 ev
.currentTarget
.disabled
= true;
35 ev
.currentTarget
.blur();
36 callUpnpDeleteRule(num
);
47 poll_status: function(nodes
, data
) {
49 var rules
= Array
.isArray(data
[0].rules
) ? data
[0].rules
: [];
51 var rows
= rules
.map(function(rule
) {
56 rule
.host_hint
|| _('Unknown'),
60 'class': 'btn cbi-button-remove',
61 'click': L
.bind(handleDelRule
, this, rule
.num
)
66 cbi_update_table(nodes
.querySelector('#upnp_status_table'), rows
, E('em', _('There are no active redirects.')));
71 render: function(data
) {
75 m
= new form
.Map('upnpd', [_('Universal Plug & Play')],
76 _('UPnP allows clients in the local network to automatically configure the router.'));
78 s
= m
.section(form
.GridSection
, '_active_rules');
80 s
.render
= L
.bind(function(view
, section_id
) {
81 var table
= E('table', { 'class': 'table cbi-section-table', 'id': 'upnp_status_table' }, [
82 E('tr', { 'class': 'tr table-titles' }, [
83 E('th', { 'class': 'th' }, _('Protocol')),
84 E('th', { 'class': 'th' }, _('External Port')),
85 E('th', { 'class': 'th' }, _('Client Address')),
86 E('th', { 'class': 'th' }, _('Host')),
87 E('th', { 'class': 'th' }, _('Client Port')),
88 E('th', { 'class': 'th' }, _('Description')),
89 E('th', { 'class': 'th cbi-section-actions' }, '')
93 var rules
= Array
.isArray(data
[0].rules
) ? data
[0].rules
: [];
95 var rows
= rules
.map(function(rule
) {
100 rule
.host_hint
|| _('Unknown'),
104 'class': 'btn cbi-button-remove',
105 'click': L
.bind(handleDelRule
, this, rule
.num
)
110 cbi_update_table(table
, rows
, E('em', _('There are no active redirects.')));
112 return E('div', { 'class': 'cbi-section cbi-tblsection' }, [
113 E('h3', _('Active UPnP Redirects')), table
]);
116 s
= m
.section(form
.NamedSection
, 'config', 'upnpd', _('MiniUPnP settings'));
118 s
.tab('general', _('General Settings'));
119 s
.tab('advanced', _('Advanced Settings'));
121 o
= s
.taboption('general', form
.Flag
, 'enabled', _('Start UPnP and NAT-PMP service'));
124 s
.taboption('general', form
.Flag
, 'enable_upnp', _('Enable UPnP functionality')).default = '1'
125 s
.taboption('general', form
.Flag
, 'enable_natpmp', _('Enable NAT-PMP functionality')).default = '1'
127 s
.taboption('general', form
.Flag
, 'secure_mode', _('Enable secure mode'),
128 _('Allow adding forwards only to requesting ip addresses')).default = '1'
130 s
.taboption('general', form
.Flag
, 'igdv1', _('Enable IGDv1 mode'),
131 _('Advertise as IGDv1 device instead of IGDv2')).default = '0'
133 s
.taboption('general', form
.Flag
, 'log_output', _('Enable additional logging'),
134 _('Puts extra debugging information into the system log'))
136 s
.taboption('general', form
.Value
, 'download', _('Downlink'),
137 _('Value in KByte/s, informational only')).rmempty
= true
139 s
.taboption('general', form
.Value
, 'upload', _('Uplink'),
140 _('Value in KByte/s, informational only')).rmempty
= true
142 o
= s
.taboption('general', form
.Value
, 'port', _('Port'))
146 s
.taboption('advanced', form
.Flag
, 'system_uptime', _('Report system instead of daemon uptime')).default = '1'
148 s
.taboption('advanced', form
.Value
, 'uuid', _('Device UUID'))
149 s
.taboption('advanced', form
.Value
, 'serial_number', _('Announced serial number'))
150 s
.taboption('advanced', form
.Value
, 'model_number', _('Announced model number'))
152 o
= s
.taboption('advanced', form
.Value
, 'notify_interval', _('Notify interval'))
153 o
.datatype
= 'uinteger'
156 o
= s
.taboption('advanced', form
.Value
, 'clean_ruleset_threshold', _('Clean rules threshold'))
157 o
.datatype
= 'uinteger'
160 o
= s
.taboption('advanced', form
.Value
, 'clean_ruleset_interval', _('Clean rules interval'))
161 o
.datatype
= 'uinteger'
164 o
= s
.taboption('advanced', form
.Value
, 'presentation_url', _('Presentation URL'))
165 o
.placeholder
= 'http://192.168.1.1/'
167 o
= s
.taboption('advanced', form
.Value
, 'upnp_lease_file', _('UPnP lease file'))
168 o
.placeholder
= '/var/run/miniupnpd.leases'
170 s
.taboption('advanced', form
.Flag
, 'use_stun', _('Use STUN'))
172 o
= s
.taboption('advanced', form
.Value
, 'stun_host', _('STUN Host'))
173 o
.depends('use_stun', '1');
176 o
= s
.taboption('advanced', form
.Value
, 'stun_port', _('STUN Port'))
177 o
.depends('use_stun', '1');
179 o
.placeholder
= '0-65535'
181 s
= m
.section(form
.GridSection
, 'perm_rule', _('MiniUPnP ACLs'),
182 _('ACLs specify which external ports may be redirected to which internal addresses and ports'))
188 s
.option(form
.Value
, 'comment', _('Comment'))
190 o
= s
.option(form
.Value
, 'ext_ports', _('External ports'))
191 o
.datatype
= 'portrange'
192 o
.placeholder
= '0-65535'
194 o
= s
.option(form
.Value
, 'int_addr', _('Internal addresses'))
195 o
.datatype
= 'ip4addr'
196 o
.placeholder
= '0.0.0.0/0'
198 o
= s
.option(form
.Value
, 'int_ports', _('Internal ports'))
199 o
.datatype
= 'portrange'
200 o
.placeholder
= '0-65535'
202 o
= s
.option(form
.ListValue
, 'action', _('Action'))
206 return m
.render().then(L
.bind(function(m
, nodes
) {
207 poll
.add(L
.bind(function() {
210 ]).then(L
.bind(this.poll_status
, this, nodes
));