From df7efca8b82921b8f301312f2fc4394119201caa Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Tue, 14 May 2013 15:00:21 +0200 Subject: [PATCH] feature #1793: Don't serve the USED leases in the VR's dhcp.(cherry picked from commit e4d3eef2713238decc6bd517b01d922fe521ed84) --- share/router/vmcontext.rb | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/share/router/vmcontext.rb b/share/router/vmcontext.rb index de0be7afda..78fb8e616b 100644 --- a/share/router/vmcontext.rb +++ b/share/router/vmcontext.rb @@ -167,7 +167,7 @@ class Router ############################################################################ def mount_context - FileUtils.mkdir_p('/mnt/context') + FileUtils.mkdir_p("/mnt/context") run "mount -t iso9660 /dev/cdrom /mnt/context 2>/dev/null" end @@ -382,12 +382,20 @@ private ip = int_to_ip(int_ip) mac = ip2mac(ip) + used_node = netxml.elements["LEASES/LEASE[IP='#{ip}']/USED"] + used = (used_node.text.to_i == 1 if used_node) || false + next if used + pairs << [mac, ip, int_ip] end elsif netxml.elements['LEASES/LEASE'] netxml.elements.each('LEASES/LEASE') do |lease| - ip = lease.elements['IP'].text - mac = lease.elements['MAC'].text + used = lease.elements['USED'].text.to_i == 1 + next if used + + ip = lease.elements['IP'].text + mac = lease.elements['MAC'].text + int_ip = ip_to_int(ip) pairs << [mac, ip, int_ip] @@ -511,15 +519,9 @@ if router.pubnet end end -if router.privnet - if router.dhcp - router.configure_dnsmasq - router.service("dnsmasq") - end - - if router.ntp - router.service("ntpd") - end +if router.privnet and router.dhcp + router.configure_dnsmasq + router.service("dnsmasq") end if router.root_password