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
- DEFAULT_PORT =
Default IMAP port
143
Class Method Summary (collapse)
-
+ (Integer) default_port
The default Ronin IMAP port.
-
+ (Object) default_port=(port)
Sets the default Ronin IMAP port.
Instance Method Summary (collapse)
-
- (Net::IMAP) imap_connect(host, options = {}) {|session| ... }
Creates a connection to the IMAP server.
-
- (nil) imap_session(host, options = {}) {|session| ... }
Starts an IMAP session with the IMAP server.
Class Method Details
+ (Integer) default_port
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 |
+ (Object) default_port=(port)
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
- (Net::IMAP) imap_connect(host, options = {}) {|session| ... }
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 |
- (nil) imap_session(host, options = {}) {|session| ... }
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 |