lib/ronin/network/mixins/smtp.rb in ronin-1.0.0 vs lib/ronin/network/mixins/smtp.rb in ronin-1.1.0.rc1
- old
+ new
@@ -16,59 +16,70 @@
# You should have received a copy of the GNU General Public License
# along with Ronin. If not, see <http://www.gnu.org/licenses/>.
#
require 'ronin/network/smtp'
+require 'ronin/ui/output/helpers'
+require 'ronin/mixin'
require 'parameters'
module Ronin
module Network
module Mixins
#
# Adds SMTP convenience methods and connection parameters to a class.
#
+ # Defines the following parameters:
+ #
+ # * `host` (`String`) - SMTP host.
+ # * `port` (`Integer`) - SMTP port.
+ # * `smtp_login` (`String`) - SMTP authentication method.
+ # * `smtp_user` (`String`) - SMTP user to login as.
+ # * `smtp_password` (`String`) - SMTP password to login with.
+ #
module SMTP
- include Parameters
+ include Mixin
- # SMTP host
- parameter :host,
- :type => String,
- :description => 'SMTP host'
+ mixin UI::Output::Helpers, Parameters
- # SMTP port
- parameter :port,
- :type => Integer,
- :description => 'SMTP port'
+ mixin do
+ # SMTP host
+ parameter :host, :type => String,
+ :description => 'SMTP host'
- # SMTP authentication method
- parameter :smtp_login,
- :type => String,
- :description => 'SMTP authentication method'
+ # SMTP port
+ parameter :port, :type => Integer,
+ :description => 'SMTP port'
- # SMTP user to login as
- parameter :smtp_user,
- :type => String,
- :description => 'SMTP user to login as'
+ # SMTP authentication method
+ parameter :smtp_login, :type => String,
+ :description => 'SMTP authentication method'
- # SMTP user to login with
- parameter :smtp_password,
- :type => String,
- :description => 'SMTP password to login with'
+ # SMTP user to login as
+ parameter :smtp_user, :type => String,
+ :description => 'SMTP user to login as'
+ # SMTP user to login with
+ parameter :smtp_password, :type => String,
+ :description => 'SMTP password to login with'
+ end
+
protected
#
# @see Ronin::Network::SMTP.message
#
+ # @api public
+ #
def smtp_message(options={},&block)
Network::SMTP.message(options,&block)
end
#
- # Creates a connection to the SMTP server. The {#host}, {#port},
- # {#smtp_login}, {#smtp_user} and {#smtp_password} parameters
+ # Creates a connection to the SMTP server. The `host`, `port`,
+ # `smtp_login`, `smtp_user` and `smtp_password` parameters
# will also be used to connect to the server.
#
# @param [Hash] options
# Additional options.
#
@@ -95,10 +106,12 @@
# The SMTP session.
#
# @return [Net::SMTP]
# The SMTP session.
#
+ # @api public
+ #
def smtp_connect(options={},&block)
options[:port] ||= self.port
options[:login] ||= self.smtp_login
options[:user] ||= self.smtp_user
options[:password] ||= self.smtp_password
@@ -111,21 +124,23 @@
return ::Net.smtp_connect(self.host,options,&block)
end
#
- # Starts a session with the SMTP server. The {#host}, {#port},
- # {#smtp_login}, {#smtp_user} and {#smtp_password} parameters
+ # Starts a session with the SMTP server. The `host`, `port`,
+ # `smtp_login`, `smtp_user` and `smtp_password` parameters
# will also be used to connect to the server.
#
# @yield [session]
# If a block is given, it will be passed an SMTP session object.
# After the block has returned, the session will be closed.
#
# @yieldparam [Net::SMTP] session
# The SMTP session.
#
# @see smtp_connect
+ #
+ # @api public
#
def smtp_session(options={},&block)
smtp_connect(options) do |sess|
yield sess if block_given?
sess.close