Skip to content

Commit 1a07ab5

Browse files
committed
Improved comments on functions
1 parent 987bed6 commit 1a07ab5

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

lib/rex/proto/dns/custom_nameserver_provider.rb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ def init
3636
self.next_id = 0
3737
end
3838

39+
#
40+
# Save the custom settings to the MSF config file
41+
#
3942
def save_config
4043
new_config = {}
4144
[self.entries_with_rules, self.entries_without_rules].each do |entry_set|
@@ -52,6 +55,9 @@ def save_config
5255
Msf::Config.save(CONFIG_KEY => new_config)
5356
end
5457

58+
#
59+
# Load the custom settings from the MSF config file
60+
#
5561
def load_config
5662
config = Msf::Config.load
5763

@@ -92,8 +98,8 @@ def load_config
9298
end
9399

94100
# Add a custom nameserver entry to the custom provider
95-
# @param [wildcard_rules] Array<String> The wildcard rules to match a DNS request against
96-
# @param [dns_server] Array<String> The list of IP addresses that would be used for this custom rule
101+
# @param wildcard_rules [Array<String>] The wildcard rules to match a DNS request against
102+
# @param dns_server [Array<String>] The list of IP addresses that would be used for this custom rule
97103
# @param comm [Msf::Session::Comm] The communication channel to be used for these DNS requests
98104
def add_nameserver(wildcard_rules, dns_server, comm)
99105
raise ::ArgumentError.new("Invalid DNS server: #{dns_server}") unless Rex::Socket.is_ip_addr?(dns_server)
@@ -118,7 +124,7 @@ def add_nameserver(wildcard_rules, dns_server, comm)
118124
#
119125
# Remove entries with the given IDs
120126
# Ignore entries that are not found
121-
# @param [Array<Integer>] The IDs to removed
127+
# @param ids [Array<Integer>] The IDs to removed
122128
# @return [Array<Hash>] The removed entries
123129
#
124130
def remove_ids(ids)
@@ -140,6 +146,7 @@ def remove_ids(ids)
140146
#
141147
# The custom nameserver entries that have been configured
142148
# @return [Array<Array>] An array containing two elements: The entries with rules, and the entries without rules
149+
#
143150
def nameserver_entries
144151
[entries_with_rules, entries_without_rules]
145152
end
@@ -148,6 +155,11 @@ def purge
148155
init
149156
end
150157

158+
# The nameservers that match the given packet
159+
# @param packet [Dnsruby::Message] The DNS packet to be sent
160+
# @raise [ResolveError] If the packet contains multiple questions, which would end up sending to a different set of nameservers
161+
# @return [Array<Array>] A list of nameservers, each with Rex::Socket options
162+
#
151163
def nameservers_for_packet(packet)
152164
# Leaky abstraction: a packet could have multiple question entries,
153165
# and each of these could have different nameservers, or travel via

lib/rex/proto/dns/resolver.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def proxies=(prox, timeout_added = 250)
115115
# @param dns_message [Dnsruby::Message] The DNS message to be sent
116116
#
117117
# @return [Array<Array>] A list of nameservers, each with Rex::Socket options
118+
#
118119
def nameservers_for_packet(dns_message)
119120
@config[:nameservers].map {|ns| [ns, {}]}
120121
end
@@ -125,8 +126,8 @@ def nameservers_for_packet(dns_message)
125126
# @param argument [Object] An object holding the DNS message to be processed.
126127
# @param type [Fixnum] Type of record to look up
127128
# @param cls [Fixnum] Class of question to look up
128-
#
129129
# @return [Dnsruby::Message] DNS response
130+
#
130131
def send(argument, type = Dnsruby::Types::A, cls = Dnsruby::Classes::IN)
131132
method = self.use_tcp? ? :send_tcp : :send_udp
132133

0 commit comments

Comments
 (0)