-
Notifications
You must be signed in to change notification settings - Fork 2.9k
luci-mod-system: improve Dropbear interface binding selection #8948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,16 +17,39 @@ return view.extend({ | |||||||||
| o = s.option(form.Flag, 'enable', _('Enable Instance'), _('Enable <abbr title="Secure Shell">SSH</abbr> service instance')); | ||||||||||
| o.default = o.enabled; | ||||||||||
|
|
||||||||||
| o = s.option(form.Flag, '_direct', _('Bind to Interface')); | ||||||||||
| o.default = o.disabled; | ||||||||||
| // Virtual option: derives UI mode from Interface/DirectInterface, | ||||||||||
| // is not stored in UCI; inactive real options are removed on save | ||||||||||
| o = s.option(form.ListValue, '_bind_to', _('Bind to'), _('Select how the SSH service should be bound to network interfaces or IP addresses')); | ||||||||||
| o.widget = 'radio'; | ||||||||||
| o.value('all', _('All interfaces (unspecified)')); | ||||||||||
| o.value('interface', _('IP addresses of interface')); | ||||||||||
| o.value('direct', _('Network interface')); | ||||||||||
| o.default = 'all'; | ||||||||||
| o.cfgvalue = function(section) { | ||||||||||
| if (this.section.cfgvalue(section, 'DirectInterface')) | ||||||||||
| return 'direct'; | ||||||||||
| if (this.section.cfgvalue(section, 'Interface')) | ||||||||||
| return 'interface'; | ||||||||||
| return 'all'; | ||||||||||
| }; | ||||||||||
| o.forcewrite = true; | ||||||||||
| o.write = function(section) { | ||||||||||
| this.remove(section); | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| o = s.option(widgets.NetworkSelect, 'DirectInterface', _('Interface'), _('Listen only on the given interface or, if unspecified, on all')); | ||||||||||
| o = s.option(widgets.NetworkSelect, 'DirectInterface', _('Interface'), _('Listen only on the given interface')); | ||||||||||
| o.nocreate = true; | ||||||||||
| o.depends('_direct', '1'); | ||||||||||
| o.depends('_bind_to', 'direct'); | ||||||||||
| o.validate = function(section, value) { | ||||||||||
| return value ? true : _('Please select an interface'); | ||||||||||
| }; | ||||||||||
|
Comment on lines
+43
to
+45
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The dropdown still offers an explicit Setting
Suggested change
Same applies to lines 50-52 for Generated by Claude Code |
||||||||||
|
|
||||||||||
| o = s.option(widgets.NetworkSelect, 'Interface', _('Interface'), _('Listen on up to 10 IPs on the given interface or, if unspecified, on all interfaces')); | ||||||||||
| o = s.option(widgets.NetworkSelect, 'Interface', _('Interface'), _('Listen on up to 10 IPs on the given interface')); | ||||||||||
| o.nocreate = true; | ||||||||||
| o.depends('_direct', '0'); | ||||||||||
| o.depends('_bind_to', 'interface'); | ||||||||||
| o.validate = function(section, value) { | ||||||||||
| return value ? true : _('Please select an interface'); | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| o = s.option(form.Value, 'Port', _('Port')); | ||||||||||
| o.datatype = 'port'; | ||||||||||
|
|
||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Every other uci-defaults file shipped by a LuCI package names its LuCI package: Generated by Claude Code |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,24 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #!/bin/sh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| . /lib/functions.sh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # remove the "_direct" UI state from existing Dropbear configs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| is_commit=0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dropbear_update() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local _direct | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config_get _direct "$1" _direct | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [ -n "$_direct" ] || return 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if uci -q delete dropbear."$1"._direct; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| is_commit=1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config_load "dropbear" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config_foreach dropbear_update dropbear | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [ $is_commit -eq 0 ] || uci commit dropbear | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+7
to
+22
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: the An unconditional
Suggested change
Generated by Claude Code |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: the replaced
_directflag was actually persisted to/etc/config/dropbear, unlike the new_bind_to.form.Flag.parse()writes any non-default value (form.js:5153-5156) anduci.set()only filters option names starting with., not_(uci.js:607). So every instance where a user had ticked "Bind to Interface" carries a staleoption _direct '1'that nothing reads any more (the dropbear init script only consumesInterface/DirectInterface), and this PR never removes it.Would it be worth clearing it here, e.g.
this.map.data.unset('dropbear', section, '_direct')alongside thethis.remove(section)in thewritehandler below, so configs get tidied up on the next save?Unrelated to that: the comment says the virtual option "clears the real options on change", but the clearing actually comes from the framework removing
Interface/DirectInterfaceonce theirdepends()stop matching —write()here only suppresses_bind_toitself.Generated by Claude Code