Class: EventMachine::DNS::Resolver

### Home Classes Methods

### In Files

- lib/em/resolver.rb

### Parent

Object

### Methods

- ::hosts
- ::nameserver
- ::nameservers
- ::nameservers=
- ::resolve
- ::socket

### Files

- ChangeLog
- DEFERRABLES
- EPOLL
- INSTALL
- KEYBOARD
- LEGAL
- LIGHTWEIGHT_CONCURRENCY
- PURE_RUBY
- RELEASE_NOTES
- SMTP
- SPAWNED_PROCESSES
- TODO

### Class/Module Index

Quicksearch

- EventMachine
- EventMachine
- EventMachine::Channel
- EventMachine::Completion
- EventMachine::Connection
- EventMachine::DNS
- EventMachine::DNS::Request
- EventMachine::DNS::RequestIdAlreadyUsed
- EventMachine::DNS::Resolver
- EventMachine::DNS::Socket
- EventMachine::DatagramObject
- EventMachine::DefaultDeferrable
- EventMachine::Deferrable
- EventMachine::DeferrableChildProcess
- EventMachine::Error
- EventMachine::EvmaKeyboard
- EventMachine::EvmaTCPClient
- EventMachine::EvmaTCPServer
- EventMachine::EvmaUDPSocket
- EventMachine::EvmaUNIXClient
- EventMachine::EvmaUNIXServer
- EventMachine::FileNotFoundException
- EventMachine::FileStreamer
- EventMachine::FileWatch
- EventMachine::Iterator
- EventMachine::LoopbreakReader
- EventMachine::PeriodicTimer
- EventMachine::Pool
- EventMachine::ProcessWatch
- EventMachine::Protocols
- EventMachine::Protocols
- EventMachine::Protocols::HeaderAndContentProtocol
- EventMachine::Protocols::HttpClient
- EventMachine::Protocols::HttpClient2
- EventMachine::Protocols::HttpClient2::Request
- EventMachine::Protocols::LineAndTextProtocol
- EventMachine::Protocols::LineProtocol
- EventMachine::Protocols::LineText2
- EventMachine::Protocols::Memcache
- EventMachine::Protocols::Memcache::ParserError
- EventMachine::Protocols::ObjectProtocol
- EventMachine::Protocols::Postgres3
- EventMachine::Protocols::SASLauth
- EventMachine::Protocols::SASLauthclient
- EventMachine::Protocols::SmtpClient
- EventMachine::Protocols::SmtpServer
- EventMachine::Protocols::Socks4
- EventMachine::Protocols::Stomp
- EventMachine::Protocols::Stomp::Message
- EventMachine::Protocols::TcpConnectTester
- EventMachine::Queue
- EventMachine::Reactor
- EventMachine::Selectable
- EventMachine::SpawnedProcess
- EventMachine::StreamObject
- EventMachine::SystemCmd
- EventMachine::ThreadedResource
- EventMachine::TickLoop
- EventMachine::Timer
- EventMachine::UuidGenerator
- EventMachine::YieldBlockFromSpawnedProcess
- Object
- Object::EM
- Object::P
- BufferedTokenizer
- IO
- StringIO
- TestConnection

No matching classes.

# EventMachine::DNS::Resolver

### Public Class Methods

hosts() click to toggle source

    # File lib/em/resolver.rb, line 51
    def self.hosts
      @hosts
    end

nameserver() click to toggle source

    # File lib/em/resolver.rb, line 47
    def self.nameserver
      nameservers.shuffle.first
    end

nameservers() click to toggle source

    # File lib/em/resolver.rb, line 35
    def self.nameservers
      if !@nameservers
        @nameservers = []
        IO.readlines('/etc/resolv.conf').each do |line|
          if line =~ /^nameserver (.+)$/
            @nameservers << $1.split(/\s+/).first
          end
        end
      end
      @nameservers
    end

nameservers=(ns) click to toggle source

    # File lib/em/resolver.rb, line 31
    def self.nameservers=(ns)
      @nameservers = ns
    end

resolve(hostname) click to toggle source

    # File lib/em/resolver.rb, line 5
    def self.resolve(hostname)
      Request.new(socket, hostname)
    end

socket() click to toggle source

    # File lib/em/resolver.rb, line 11
    def self.socket
      if !@socket || (@socket && @socket.error?)
        @socket = Socket.open

        @hosts  = {}
        IO.readlines('/etc/hosts').each do |line|
          next if line =~ /^#/
          addr, host = line.split(/\s+/)

          if @hosts[host]
            @hosts[host] << addr
          else
            @hosts[host] = [addr]
          end
        end
      end

      @socket
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.