Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/rex/proto/dns/upstream_resolver.rb
Views: 11704
# -*- coding: binary -*-12module Rex3module Proto4module DNS5##6# This represents a single upstream DNS resolver target of one of the predefined types.7##8class UpstreamResolver9module Type10BLACK_HOLE = :"black-hole"11DNS_SERVER = :"dns-server"12STATIC = :static13SYSTEM = :system14end1516attr_reader :type, :destination, :socket_options1718# @param [Symbol] type The resolver type.19# @param [String] destination An optional destination, as used by some resolver types.20# @param [Hash] socket_options Options to use for sockets when connecting to the destination, as used by some21# resolver types.22def initialize(type, destination: nil, socket_options: {})23@type = type24@destination = destination25@socket_options = socket_options26end2728# Initialize a new black-hole resolver.29def self.create_black_hole30self.new(Type::BLACK_HOLE)31end3233# Initialize a new dns-server resolver.34#35# @param [String] destination The IP address of the upstream DNS server.36# @param [Hash] socket_options Options to use when connecting to the upstream DNS server.37def self.create_dns_server(destination, socket_options: {})38self.new(39Type::DNS_SERVER,40destination: destination,41socket_options: socket_options42)43end4445# Initialize a new static resolver.46def self.create_static47self.new(Type::STATIC)48end4950# Initialize a new system resolver.51def self.create_system52self.new(Type::SYSTEM)53end5455def to_s56if type == Type::DNS_SERVER57destination.to_s58else59type.to_s60end61end6263def eql?(other)64return false unless other.is_a?(self.class)65return false unless other.type == type66return false unless other.destination == destination67return false unless other.socket_options == socket_options68true69end7071alias == eql?72end73end74end75end767778