Changeset 7229
- Timestamp:
- 06/25/11 22:51:12 (2 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
luci/trunk/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua
r7115 r7229 3 3 4 4 Copyright 2008 Steven Barth <steven@midlink.org> 5 Copyright 2008 Jo-Philipp Wich <xm@subsignal.org>5 Copyright 2008-2011 Jo-Philipp Wich <xm@subsignal.org> 6 6 7 7 Licensed under the Apache License, Version 2.0 (the "License"); … … 660 660 if has_dnsmasq and net:proto() == "static" then 661 661 m2 = Map("dhcp", "", "") 662 663 local section_id = "-" 664 662 665 function m2.on_parse() 663 local has_section = false664 665 666 m2.uci:foreach("dhcp", "dhcp", function(s) 666 667 if s.interface == arg[1] then 667 has_section = true668 section_id = s['.name'] 668 669 return false 669 670 end 670 671 end) 671 672 if not has_section then673 m2.uci:section("dhcp", "dhcp", nil, { interface = arg[1], ignore = "1" })674 m2.uci:save("dhcp")675 end676 672 end 677 673 … … 682 678 s:tab("advanced", translate("Advanced Settings")) 683 679 684 function s. filter(self, section)685 return m2.uci:get("dhcp", section, "interface") == arg[1]680 function s.cfgsections(self) 681 return { section_id } 686 682 end 687 683 … … 692 688 693 689 ignore.rmempty = false 690 691 function ignore.cfgvalue(self, section) 692 return (section == "-") and self.enabled or Flag.cfgvalue(self, section) 693 end 694 695 function ignore.write(self, section, value) 696 section_id = m2.uci:section("dhcp", "dhcp", nil, { 697 ignore = value, 698 interface = arg[1] 699 }) 700 end 701 694 702 695 703 local start = s:taboption("general", Value, "start", translate("Start"), … … 735 743 "192.168.2.2</code>\" which advertises different DNS servers to clients.")) 736 744 745 746 local function write_opt(self, section, value) 747 return getmetatable(self).__index.write(self, section_id, value) 748 end 749 750 local function remove_opt(self, section, value) 751 return getmetatable(self).__index.remove(self, section_id, value) 752 end 753 737 754 for i, n in ipairs(s.children) do 738 755 if n ~= ignore then 739 756 n:depends("ignore", "") 757 n.write = write_opt 758 n.remove = remove_opt 740 759 end 741 760 end
