Skip to content

Commit b42eeac

Browse files
committed
Parse non-numeric DHCP options
Currently this will just skip them, until a lookup table has been written
1 parent c9f1dea commit b42eeac

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/smart_proxy_dhcp_dnsmasq/dhcp_dnsmasq_subnet_service.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def parse_config_for_subnets
9191

9292
next if start_addr.ipv6? # Smart-proxy currently doesn't support IPv6
9393

94-
logger.warning "Failed to fully parse line #{file}:#{line_nr}: '#{line}', remaining data: #{data.inspect}" unless data.empty?
94+
logger.warning "Failed to fully parse line #{file}:#{line_nr}: '#{line}', unparsed data: #{data.inspect}" unless data.empty?
9595

9696
ipv4 = start_addr.ipv4?
9797
subnet_iface = interfaces.find { |i| (ipv4 ? i.addr.ipv4? : i.addr.ipv6?) && i.name == subnet_iface } if subnet_iface
@@ -146,9 +146,13 @@ def parse_config_for_subnets
146146
(data.first if interfaces.find { |i| i.name == data.first }) ||
147147
configuration.keys
148148

149-
data.shift until data.empty? || /\A\d+\z/ =~ data.first
149+
data.shift until data.empty? || /^\d+|option6?:\w+$/ =~ data.first
150150
next if data.empty?
151151

152+
unless data.first =~ /^\d+$/
153+
logger.warning "Found non-numeric DHCP option on line #{file}:#{line_nr}: '#{line}', skipping."
154+
next
155+
end
152156
code = data.shift.to_i
153157

154158
option = ::Proxy::DHCP::Standard.select { |_k, v| v[:code] == code }.first.first

0 commit comments

Comments
 (0)