Class: Ronin::DNS::Proxy::Rule Private
- Inherits:
-
Object
- Object
- Ronin::DNS::Proxy::Rule
- Defined in:
- lib/ronin/dns/proxy/rule.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Represents a DNS rule for the DNS Server.
Instance Attribute Summary collapse
-
#name ⇒ String, Regexp
readonly
private
The record name or regex to match.
-
#result ⇒ String, ...
readonly
private
The result to return.
-
#type ⇒ :A, ...
readonly
private
The record type to match.
Instance Method Summary collapse
-
#call(query_type, query_name, transaction) ⇒ Async::DNS::Transaction
private
Invokes the rule with the given query type, query name, and DNS transaction object.
-
#initialize(type, name, result = nil) {|type, name, transaction| ... } ⇒ Rule
constructor
private
Initializes the DNS rule.
-
#matches?(query_type, query_name) ⇒ Boolean
private
Determines if the rule matches the query type and query name.
Constructor Details
#initialize(type, name, result = nil) {|type, name, transaction| ... } ⇒ Rule
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes the DNS rule.
74 75 76 77 78 79 80 81 82 |
# File 'lib/ronin/dns/proxy/rule.rb', line 74 def initialize(type,name,result=nil,&block) unless (result || block) raise(ArgumentError,"must specify a result value or a block") end @type = type @name = name @result = result || block end |
Instance Attribute Details
#name ⇒ String, Regexp (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The record name or regex to match.
39 40 41 |
# File 'lib/ronin/dns/proxy/rule.rb', line 39 def name @name end |
#result ⇒ String, ... (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The result to return.
44 45 46 |
# File 'lib/ronin/dns/proxy/rule.rb', line 44 def result @result end |
#type ⇒ :A, ... (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The record type to match.
34 35 36 |
# File 'lib/ronin/dns/proxy/rule.rb', line 34 def type @type end |
Instance Method Details
#call(query_type, query_name, transaction) ⇒ Async::DNS::Transaction
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Invokes the rule with the given query type, query name, and DNS transaction object.
113 114 115 116 117 118 119 120 121 |
# File 'lib/ronin/dns/proxy/rule.rb', line 113 def call(query_type,query_name,transaction) if @result.respond_to?(:call) @result.call(query_type,query_name,transaction) elsif @result.kind_of?(Symbol) transaction.fail!(@result) elsif @result transaction.respond!(@result) end end |
#matches?(query_type, query_name) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Determines if the rule matches the query type and query name.
96 97 98 |
# File 'lib/ronin/dns/proxy/rule.rb', line 96 def matches?(query_type,query_name) (@type == query_type) && (@name === query_name) end |