Module: Ronin::Network::Mixins::POP3

Includes:
Mixin
Defined in:
lib/ronin/network/mixins/pop3.rb

Overview

Adds POP3 convenience methods and connection parameters to a class.

Defines the following parameters:

  • host (String) - POP3 host.
  • port (Integer) - POP3 port.
  • pop3_user (String) - POP3 user to login as.
  • pop3_password (String) - POP3 password to login with.

Instance Method Summary collapse

Methods included from Mixin

included

Instance Method Details

#pop3_connect(options = {}) {|session| ... } ⇒ Net::POP3 (protected)

Creates a connection to the POP3 server. The host},port, pop3_userandpop3_password` parameters will also be used to connect to the server.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Options Hash (options):

  • :port (Integer) — default: Ronin::Network::POP3.default_port

    The port the POP3 server is running on.

  • :user (String)

    The user to authenticate with when connecting to the POP3 server.

  • :password (String)

    The password to authenticate with when connecting to the POP3 server.

Yields:

  • (session)

    If a block is given, it will be passed the newly created POP3 session.

Yield Parameters:

  • session (Net::POP3)

    The newly created POP3 session.

Returns:

  • (Net::POP3)

    The newly created POP3 session.



95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/ronin/network/mixins/pop3.rb', line 95

def pop3_connect(options={},&block)
  options[:port] ||= self.port
  options[:user] ||= self.pop3_user
  options[:password] ||= self.pop3_password

  if self.port
    print_info "Connecting to #{self.host}:#{self.port} ..."
  else
    print_info "Connecting to #{self.host} ..."
  end

  return ::Net.pop3_connect(self.host,options,&block)
end

#pop3_session(options = {}) {|session| ... } ⇒ Object (protected)

Starts a session with the POP3 server. The host, port, pop3_user and pop3_password parameters will also be used to connect to the server.

Yields:

  • (session)

    If a block is given, it will be passed the newly created POP3 session. After the block has returned, the session will be closed.

Yield Parameters:

  • session (Net::POP3)

    The newly created POP3 session.

See Also:



126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/ronin/network/mixins/pop3.rb', line 126

def pop3_session(options={})
  pop3_connect(options) do |sess|
    yield sess if block_given?
    sess.finish

    if @port
      print_info "Disconnecting to #{self.host}:#{self.port}"
    else
      print_info "Disconnecting to #{self.host}"
    end
  end
end