Skip to content

Commit

Permalink
Parse non-numeric DHCP options
Browse files Browse the repository at this point in the history
Currently this will just skip them, until a lookup table has been
written
  • Loading branch information
ananace committed Apr 28, 2020
1 parent c9f1dea commit b42eeac
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/smart_proxy_dhcp_dnsmasq/dhcp_dnsmasq_subnet_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def parse_config_for_subnets

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

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

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

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

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

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

0 comments on commit b42eeac

Please sign in to comment.