lib/async/dns/server.rb in async-dns-0.12.0 vs lib/async/dns/server.rb in async-dns-1.0.0
- old
+ new
@@ -17,30 +17,30 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
require 'async'
-require 'async/io/address'
+require 'async/io/endpoint'
require_relative 'transaction'
require_relative 'logger'
module Async::DNS
class Server
# The default server interfaces
- DEFAULT_INTERFACES = [[:udp, "0.0.0.0", 53], [:tcp, "0.0.0.0", 53]]
+ DEFAULT_ENDPOINTS = [[:udp, "0.0.0.0", 53], [:tcp, "0.0.0.0", 53]]
# Instantiate a server with a block
#
# server = Server.new do
# match(/server.mydomain.com/, IN::A) do |transaction|
# transaction.respond!("1.2.3.4")
# end
# end
#
- def initialize(listen: DEFAULT_INTERFACES, origin: '.', logger: Async.logger)
- @interfaces = listen
+ def initialize(endpoints = DEFAULT_ENDPOINTS, origin: '.', logger: Async.logger)
+ @endpoints = endpoints
@origin = origin
@logger = logger
@handlers = []
end
@@ -122,17 +122,17 @@
private
def setup_handlers
fire(:setup)
- Async::IO::Address.each(@interfaces) do |address|
- case address.type
+ Async::IO::Endpoint.each(@endpoints) do |endpoint|
+ case endpoint.socket_type
when Socket::SOCK_DGRAM
- @logger.info "<> Listening for datagrams on #{address.inspect}"
- @handlers << DatagramHandler.new(self, address)
+ @logger.info "<> Listening for datagrams on #{endpoint.inspect}"
+ @handlers << DatagramHandler.new(self, endpoint)
when Socket::SOCK_STREAM
- @logger.info "<> Listening for connections on #{address.inspect}"
- @handlers << StreamHandler.new(self, address)
+ @logger.info "<> Listening for connections on #{endpoint.inspect}"
+ @handlers << StreamHandler.new(self, endpoint)
else
raise ArgumentError.new("Don't know how to handle #{address}")
end
end
end