Skip to content
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

luci-mod-network: Fix 'instances' fields for dnsmasq dhcp config entries #6579

Merged
merged 1 commit into from
Dec 4, 2023
Merged

luci-mod-network: Fix 'instances' fields for dnsmasq dhcp config entries #6579

merged 1 commit into from
Dec 4, 2023

Conversation

systemcrash
Copy link
Contributor

@systemcrash systemcrash commented Sep 19, 2023

Fix an error wherein luci erroneously saved the iterator integer of the current dnsmasq config object to a host (and boot/PXE) config entry 'instance' field, instead of correctly referring to its name.

Now we use the correct .name field of the dnsmasq config entry. Anonymous entries have e.g. cfg01411c. The .name field corresponds to 'myName' in /etc/config/dhcp entries of:

config dnsmasq 'myName'
  ...

In this way, host and other entry types are bound correctly to specific dnsmasq instances.

Looks like:

Screenshot 2023-11-22 at 19 09 17

Tested on 23.05.2

See forum discussion here

FAO: @jow- @hnyman

@systemcrash systemcrash changed the title Fix 'instances' fields for dnsmasq (dhcp) config entries. luci-mod-network: Fix 'instances' fields for dnsmasq dhcp config entries Sep 19, 2023
@jow-
Copy link
Contributor

jow- commented Sep 21, 2023

Please make the caption translatable and provide a translation context hint:
_('%s (Name: %s, Domain: %s, Local: %s)', 'dnsmasq instance description value').format(...)

@systemcrash
Copy link
Contributor Author

Yessir. Done.

@systemcrash
Copy link
Contributor Author

LGTM

@systemcrash
Copy link
Contributor Author

ping @jow- @stangri @hnyman

@stangri
Copy link
Member

stangri commented Nov 21, 2023

@systemcrash My 2 cents: while it's certainly an improvement and the code looks very neat, would it not be better to instead do something like: Instance: dnsmasq[0] (for unnamed instances) or Instance: schaft (for named ones) and if domain and local are unset do not show them at all, rather than: Domain: unset and Local: unset? The cfg01411c doesn't mean much to users and I don't even know how would one translate it to the dnsmasq unnamed instances indexes.

@systemcrash
Copy link
Contributor Author

systemcrash commented Nov 21, 2023

@systemcrash My 2 cents: while it's certainly an improvement and the code looks very neat, would it not be better to instead do something like: Instance: dnsmasq[0] (for unnamed instances) or Instance: schaft (for named ones) and if domain and local are unset do not show them at all, rather than: Domain: unset and Local: unset? The cfg01411c doesn't mean much to users and I don't even know how would one translate it to the dnsmasq unnamed instances indexes.

Valid points! The first one I might steal. Although I don't think it's a bad idea that users see what's going on also under the hood (and see those anonymous names). I'll give those a try and see how they look. Thanks for the input.

@jow-
Copy link
Contributor

jow- commented Nov 21, 2023

You also need to make noname and unset translatable (with some added meaningful translation context)

@systemcrash
Copy link
Contributor Author

systemcrash commented Nov 22, 2023

That should satisfy everything, I think. The only translatables in there are Name, Domain and Local.

0 (Name: dnsmasq[0], Domain: lan, Local: /lan/)
1 (Name: schaft)
2 (Name: test3)
3 (Name: dnsmasq[3])

Fixed error wherein luci erroneously saved the iterator integer of the
current dnsmasq config object to a host (and boot/PXE) config entry
'instance' field, instead of correctly referring to its name.

Now we use the correct ".name" field of the dnsmasq config entry.
Anonymous entries have e.g. "cfg01411c". The ".name" field corresponds
to 'myName' in /etc/config/dhcp entries of:

config dnsmasq 'myName'
  ...

In this way, host and other entry types are bound correctly to specific
dnsmasq instances. For anonymous entries, display "dnsmasq[x]" as name.

Signed-off-by: Paul Donald <newtwen@gmail.com>
@systemcrash systemcrash merged commit d353bc5 into openwrt:master Dec 4, 2023
2 checks passed
systemcrash added a commit that referenced this pull request Dec 4, 2023
luci-mod-network: Fix 'instances' fields for dnsmasq dhcp config entries
(cherry picked from commit d353bc5)
@systemcrash systemcrash deleted the fix_dnsmasq_instance_fields branch December 4, 2023 23:28
systemcrash added a commit that referenced this pull request Jan 28, 2024
luci-mod-network: Fix 'instances' fields for dnsmasq dhcp config entries
(cherry picked from commit d353bc5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants