Method: MacWifi::BaseModel#nameservers

Defined in:
lib/mac-wifi/base_model.rb

#nameserversObject

Though this is strictly not OS-agnostic, it will be used by most OS’s, and can be overridden by subclasses (e.g. Windows).

Returns:

  • array of nameserver IP addresses from /etc/resolv.conf, or nil if not found



233
234
235
236
237
238
239
# File 'lib/mac-wifi/base_model.rb', line 233

def nameservers
  begin
    File.readlines('/etc/resolv.conf').grep(/^nameserver /).map { |line| line.split.last }
  rescue Errno::ENOENT
    nil
  end
end