Skip to content

Commit

Permalink
Allow to set manual DNS in TUI for autoconf
Browse files Browse the repository at this point in the history
Signed-off-by: BenjiReis <benjamin.reis@vates.fr>
  • Loading branch information
benjamreis committed Jun 19, 2023
1 parent 0f18e5d commit 6ffa420
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions tui/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def dhcp_change():
for x in [ ip_field, gateway_field, subnet_field, dns_field ]:
x.setFlags(FLAG_DISABLED, static_rb.selected())

# Allow manual DNS for autoconf
if autoconf_rb.selected():
dns_field.setFlags(FLAG_DISABLED, False)

ipv6 = iface_class == NetInterfaceV6

gf = GridFormHelp(tui.screen, 'Networking', 'ifconfig', 1, 10)
Expand Down Expand Up @@ -124,16 +128,19 @@ def dhcp_change():
dns_text = Textbox(15, 1, "Nameserver:")
vlan_text = Textbox(15, 1, "VLAN (1-4094):")

entry_grid = Grid(2, include_dns and 4 or 3)
entry_grid = Grid(2, 3)
entry_grid.setField(ip_text, 0, 0)
entry_grid.setField(ip_field, 1, 0)
entry_grid.setField(subnet_text, 0, 1)
entry_grid.setField(subnet_field, 1, 1)
entry_grid.setField(gateway_text, 0, 2)
entry_grid.setField(gateway_field, 1, 2)

dns_grid = None
if include_dns:
entry_grid.setField(dns_text, 0, 3)
entry_grid.setField(dns_field, 1, 3)
dns_grid = Grid(2, 1)
dns_grid.setField(dns_text, 0, 0)
dns_grid.setField(dns_field, 1, 0)

vlan_grid = Grid(2, 1)
vlan_grid.setField(vlan_text, 0, 0)
Expand All @@ -145,9 +152,11 @@ def dhcp_change():
gf.add(entry_grid, 0, 4, padding=(0, 0, 0, 1))
if ipv6:
gf.add(autoconf_rb, 0, 5, anchorLeft=True)
gf.add(vlan_cb, 0, 6, anchorLeft=True)
gf.add(vlan_grid, 0, 7, padding=(0, 0, 0, 1))
gf.add(buttons, 0, 8, growx=1)
if include_dns:
gf.add(dns_grid, 0, 6, padding=(0, 0, 0, 1))
gf.add(vlan_cb, 0, 7, anchorLeft=True)
gf.add(vlan_grid, 0, 8, padding=(0, 0, 0, 1))
gf.add(buttons, 0, 9, growx=1)

loop = True
ip_family = socket.AF_INET6 if ipv6 else socket.AF_INET
Expand Down

0 comments on commit 6ffa420

Please sign in to comment.