Module: Ronin::Network::IMAP
- Included in:
- Net, Mixins::IMAP, Support
- Defined in:
- lib/ronin/network/imap.rb
Overview
Provides helper methods for communicating with IMAP services.
Constant Summary collapse
- DEFAULT_PORT =
Default IMAP port
143
Class Method Summary collapse
-
.default_port ⇒ Integer
The default Ronin IMAP port.
-
.default_port=(port) ⇒ Object
Sets the default Ronin IMAP port.
Instance Method Summary collapse
-
#imap_connect(host, options = {}) {|session| ... } ⇒ Net::IMAP
Creates a connection to the IMAP server.
-
#imap_session(host, options = {}) {|session| ... } ⇒ nil
Starts an IMAP session with the IMAP server.
Class Method Details
.default_port ⇒ Integer
Returns The default Ronin IMAP port.
39 40 41 |
# File 'lib/ronin/network/imap.rb', line 39 def self.default_port @default_port ||= DEFAULT_PORT end |
.default_port=(port) ⇒ Object
Sets the default Ronin IMAP port.
51 52 53 |
# File 'lib/ronin/network/imap.rb', line 51 def self.default_port=(port) @default_port = port end |
Instance Method Details
#imap_connect(host, options = {}) {|session| ... } ⇒ Net::IMAP
Creates a connection to the IMAP server.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/ronin/network/imap.rb', line 92 def imap_connect(host,={}) host = host.to_s port = ([:port] || IMAP.default_port) certs = [:certs] auth = [:auth] user = [:user] passwd = [:password] if [:ssl] ssl = true ssl_certs = [:ssl][:certs] ssl_verify = SSL::VERIFY[[:ssl][:verify]] else ssl = false ssl_certs = nil ssl_verify = false end session = Net::IMAP.new(host,port,ssl,ssl_certs,ssl_verify) if user if auth == :cram_md5 session.authenticate('CRAM-MD5',user,passwd) else session.authenticate('LOGIN',user,passwd) end end yield session if block_given? return session end |
#imap_session(host, options = {}) {|session| ... } ⇒ nil
Starts an IMAP session with the IMAP server.
146 147 148 149 150 151 152 153 154 155 |
# File 'lib/ronin/network/imap.rb', line 146 def imap_session(host,={}) session = imap_connect(host,) yield session if block_given? session.logout if [:user] session.close session.disconnect return nil end |