Skip to content

Commit 37b06b0

Browse files
luci-app-upnp: Adapt to new/revised package UCI options
The following UI options been added or changed: - Deny unsafe ports (`deny_unsafe_ports`): UI option added to deny unsafe client ports being mapped before checking the ACL - Router/friendly name (`upnp_igd_friendly_name`): UI option added to set name displayed in windows explorer, model/serial number removed - Use STUN (`use_stun`): New option for IPv4 CGNAT use (allow filtered), and updated help with newer wording of RFC 5780 - STUN server (`stun_host`): Allow port inclusion - STUN port: Removed, as now accepted in STUN server - Override public IPv4 (`external_ip`): UI option added for CGNAT use - Allow third-party mapping (`allow_third_party_mapping`): Inverted from secure mode and extended to PCP - Download/upload speed (`upnp_igd_download`/`upnp_igd_upload`): In kbit/s and datatype set, 8/4 Mbit/s default config defaults removed - UPnP IGD compatibility mode (`upnp_igd_compat`): As extensible list - Enable UPnP IGD protocol (`enable_upnp_igd`): UCI option renamed - Enable PCP/NAT-PMP protocols (`enable_pcp_natpmp`): UCI option renamed - Set `notify_interval` minimum to 900s (default), as recommended by [UDA 1.1] (2x=1800 in the standard), because daemon/OpenWrt wrongly suggested 30x less in the past, and to reduce multicast traffic and power consumption in wireless networks, clearer help - ACL: Update help for new empty ACL denied by default, clonable entries and reorder action. The updated package added templates for HTTP/HTTPS and all ports to the default ACL, which resets when the ACL is cleared [UDA 1.1]: https://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.1.pdf#page=30 More details on changed options can be found in the dependent package PR and make Depends on: https://redirect.github.com/openwrt/packages/pull/24988 Signed-off-by: Self-Hosting-Group <[email protected]>
1 parent 823a043 commit 37b06b0

File tree

2 files changed

+69
-46
lines changed
  • applications/luci-app-upnp

2 files changed

+69
-46
lines changed

applications/luci-app-upnp/htdocs/luci-static/resources/view/upnp/upnp.js

Lines changed: 68 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
'require uci';
66
'require rpc';
77
'require form';
8+
'require tools.widgets as widgets';
89

910
const callInitAction = rpc.declare({
1011
object: 'luci',
@@ -141,39 +142,42 @@ return view.extend({
141142
_('Start autonomous port mapping service'));
142143
o.rmempty = false;
143144

144-
o = s.taboption('setup', form.Flag, 'enable_upnp', _('Enable UPnP IGD protocol'));
145+
o = s.taboption('setup', form.Flag, 'enable_upnp_igd', _('Enable UPnP IGD protocol'));
145146
o.default = '1';
146147

147-
o = s.taboption('setup', form.Flag, 'enable_natpmp', _('Enable PCP/NAT-PMP protocols'));
148+
o = s.taboption('setup', form.Flag, 'enable_pcp_natpmp', _('Enable PCP/NAT-PMP protocols'));
148149
o.default = '1';
149150

150-
o = s.taboption('setup', form.Flag, 'igdv1', _('UPnP IGDv1 compatibility mode'),
151-
_('Advertise as IGDv1 (IPv4 only) device instead of IGDv2'));
152-
o.default = '1';
153-
o.rmempty = false;
154-
o.depends('enable_upnp', '1');
151+
o = s.taboption('setup', form.ListValue, 'upnp_igd_compat', _('UPnP IGD compatibility mode'),
152+
_('Act/emulate as specific/different device to workaround/support/handle/bypass/assist/mitigate IGDv2 incompatible clients'));
153+
o.value('igdv1', _('IGDv1 (IPv4 only)'));
154+
o.value('igdv2', _('IGDv2'));
155+
o.default = 'igdv1';
156+
o.depends('enable_upnp_igd', '1');
155157
o.retain = true;
156158

157-
s.taboption('advanced', form.Flag, 'use_stun', _('Use %s', 'Use %s (%s = STUN)')
158-
.format('<a href="https://en.wikipedia.org/wiki/STUN" target="_blank" rel="noreferrer"><abbr title="Session Traversal Utilities for NAT">STUN</abbr></a>'),
159-
_('To detect the public IPv4 address for unrestricted full-cone/one-to-one NATs'));
159+
o = s.taboption('advanced', form.RichListValue, 'use_stun', _('Use %s', 'Use %s (%s = STUN)')
160+
.format('<a href="https://en.wikipedia.org/wiki/STUN" target="_blank" rel="noreferrer"><abbr title="Session Traversal Utilities for NAT">STUN</abbr></a>'),
161+
_('Enables unrestricted endpoint-independent (1:1) CGNAT use and detects public IPv4'));
162+
o.value('0', _('Disabled'), _('Override public IPv4 to allow private IPv4 on external interface'));
163+
o.value('1', _('Enabled'), _('CGNAT test currently requires an extra firewall rule'));
164+
o.value('allow-filtered', _('Enabled (allow filtered)'), _('Allow filtered CGNAT test result'));
165+
o.default = '0';
160166

161-
o = s.taboption('advanced', form.Value, 'stun_host', _('STUN host'));
167+
o = s.taboption('advanced', form.Value, 'stun_host', _('STUN server'));
162168
o.depends('use_stun', '1');
169+
o.depends('use_stun', 'allow-filtered');
163170
o.retain = true;
164-
o.datatype = 'host';
171+
o.datatype = 'or(hostname,hostport,ip4addr("nomask"))';
172+
o.placeholder = 'stun.nextcloud.com';
165173

166-
o = s.taboption('advanced', form.Value, 'stun_port', _('STUN port'));
167-
o.depends('use_stun', '1');
168-
o.retain = true;
169-
o.datatype = 'port';
170-
o.placeholder = '3478';
174+
o = s.taboption('advanced', form.Value, 'external_ip', _('Override public IPv4'),
175+
_('Report custom public/external (WAN) IPv4 address'));
176+
o.depends('use_stun', '0');
177+
o.datatype = 'ip4addr("nomask")';
171178

172-
o = s.taboption('advanced', form.Flag, 'secure_mode', _('Enable secure mode'),
173-
_('Allow adding port maps for requesting IP addresses only'));
174-
o.default = '1';
175-
o.depends('enable_upnp', '1');
176-
o.retain = true;
179+
o = s.taboption('advanced', form.Flag, 'allow_third_party_mapping', _('Allow third-party mapping'),
180+
_('Allow adding port maps for non-requesting IP addresses'));
177181

178182
s.taboption('advanced', form.Flag, 'ipv6_disable', _('Disable IPv6 mapping'));
179183

@@ -185,76 +189,95 @@ return view.extend({
185189
s.taboption('advanced', form.Flag, 'log_output', _('Enable additional logging'),
186190
_('Puts extra debugging information into the system log'));
187191

188-
o = s.taboption('advanced', form.Value, 'upnp_lease_file', _('Service lease file'));
192+
o = s.taboption('advanced', form.Value, 'lease_file', _('Service lease file'));
189193
o.depends('to-disable-rarely-used', '1');
190194
o.retain = true;
191195

192196
o = s.taboption('igd', form.Value, 'port', _('SOAP/HTTP port'));
193197
o.datatype = 'port';
194198
o.placeholder = '5000';
195-
o.depends('enable_upnp', '1');
199+
o.depends('enable_upnp_igd', '1');
196200
o.retain = true;
197201

198202
o = s.taboption('igd', form.Value, 'notify_interval', _('Notify interval'),
199-
_('A 900s interval will result in %s notifications with the minimum max-age of 1800s', 'A 900s interval will result in %s (%s = SSDP) notifications with the minimum max-age of 1800s')
203+
_('A 900s interval sends %s notices with the minimum cache-control max-age header of 1800', 'A 900s interval sends %s (%s = SSDP) notices with the minimum cache-control max-age header of 1800')
200204
.format('<abbr title="Simple Service Discovery Protocol">SSDP</abbr>'));
201-
o.datatype = 'uinteger';
205+
o.datatype = 'min(900)';
202206
o.placeholder = '900';
203-
o.depends('enable_upnp', '1');
207+
o.depends('enable_upnp_igd', '1');
204208
o.retain = true;
205209

206-
o = s.taboption('igd', form.Value, 'download', _('Download speed'),
207-
_('Report maximum download speed in kByte/s'));
208-
o.depends('enable_upnp', '1');
210+
o = s.taboption('igd', form.Value, 'upnp_igd_download', _('Download speed'),
211+
_('Report maximum link speed in kbit/s'));
212+
o.depends('enable_upnp_igd', '1');
209213
o.retain = true;
214+
o.datatype = 'uinteger';
215+
o.placeholder = _('Default interface link speed');
210216

211-
o = s.taboption('igd', form.Value, 'upload', _('Upload speed'),
212-
_('Report maximum upload speed in kByte/s'));
213-
o.depends('enable_upnp', '1');
217+
o = s.taboption('igd', form.Value, 'upnp_igd_upload', _('Upload speed'),
218+
_('Report maximum link speed in kbit/s'));
219+
o.depends('enable_upnp_igd', '1');
214220
o.retain = true;
221+
o.datatype = 'uinteger';
222+
o.placeholder = _('Default interface link speed');
223+
224+
o = s.taboption('igd', form.Value, 'upnp_igd_friendly_name', _('Router/friendly name'));
225+
o.depends('enable_upnp_igd', '1');
226+
o.retain = true;
227+
o.placeholder = 'OpenWrt router';
215228

216229
o = s.taboption('igd', form.Value, 'model_number', _('Announced model number'));
217-
o.depends('enable_upnp', '1');
230+
// o.depends('enable_upnp_igd', '1');
231+
o.depends('to-disable-rarely-used', '1');
218232
o.retain = true;
219233

220234
o = s.taboption('igd', form.Value, 'serial_number', _('Announced serial number'));
221-
o.depends('enable_upnp', '1');
235+
// o.depends('enable_upnp_igd', '1');
236+
o.depends('to-disable-rarely-used', '1');
222237
o.retain = true;
223238

224239
o = s.taboption('igd', form.Value, 'presentation_url', _('Presentation URL'),
225240
_('Report custom router web interface (presentation) URL'));
226241
o.placeholder = 'http://192.168.1.1/';
227-
o.depends('enable_upnp', '1');
242+
o.depends('enable_upnp_igd', '1');
228243
o.retain = true;
229244

230245
o = s.taboption('igd', form.Value, 'uuid', _('Device UUID'));
231-
// o.depends('enable_upnp', '1');
246+
// o.depends('enable_upnp_igd', '1');
232247
o.depends('to-disable-rarely-used', '1');
233248
o.retain = true;
234249

235250
s = m.section(form.GridSection, 'perm_rule', _('Service Access Control List'),
236-
_('ACL specify which client addresses and ports can be mapped, IPv6 always allowed.'));
251+
_('The ACL specifies which client addresses and ports can be mapped. An empty ACL is denied. IPv6 is currently always allowed unless disabled.'));
237252
s.sortable = true;
238253
s.anonymous = true;
239254
s.addremove = true;
255+
s.cloneable = true;
256+
s.modaltitle = _('Edit ACL entry');
240257

241-
s.option(form.Value, 'comment', _('Comment'));
258+
o = s.option(form.Value, 'comment', _('Description'));
259+
o.default = _('Entry');
260+
261+
o = s.option(form.ListValue, 'action', _('Action'));
262+
o.value('allow', _('Allow'));
263+
o.value('deny', _('Deny'));
242264

243265
o = s.option(form.Value, 'int_addr', _('Client Address'));
244266
o.datatype = 'ip4addr';
245-
o.placeholder = '0.0.0.0/0';
267+
o.default = '0.0.0.0/0';
246268

247269
o = s.option(form.Value, 'int_ports', _('Client Port'));
248270
o.datatype = 'portrange';
249-
o.placeholder = '1-65535';
271+
o.default = '1-65535';
250272

251273
o = s.option(form.Value, 'ext_ports', _('External Port'));
252274
o.datatype = 'portrange';
253-
o.placeholder = '1-65535';
275+
o.default = '1-65535';
254276

255-
o = s.option(form.ListValue, 'action', _('Action'));
256-
o.value('allow', _('Allow'));
257-
o.value('deny', _('Deny'));
277+
s = m.section(form.NamedSection, 'config', 'upnpd');
278+
o = s.option(form.Value, 'deny_unsafe_ports', _('Deny unsafe/insecure/risky ports'),
279+
_('By default, deny DCE/NetBIOS/SMB client ports being mapped before checking the ACL'));
280+
o.placeholder = '135 137 138 139 445';
258281

259282
return m.render().then(L.bind(function(m, nodes) {
260283
poll.add(L.bind(function() {

applications/luci-app-upnp/root/usr/share/rpcd/ucode/luci.upnp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { connect } from 'ubus';
88
import { cursor } from 'uci';
99

1010
const uci = cursor();
11-
const leasefilepath = uci.get('upnpd', 'config', 'upnp_lease_file') || '/var/run/miniupnpd.leases';
11+
const leasefilepath = uci.get('upnpd', 'config', 'lease_file') || '/var/run/miniupnpd.leases';
1212

1313
const methods = {
1414
get_status: {

0 commit comments

Comments
 (0)