Class: IPAccess::Net::FTP
- Inherits:
-
Net::FTP
- Object
- Net::FTP
- IPAccess::Net::FTP
- Includes:
- Patches::Net::FTP
- Defined in:
- lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb,
lib/ipaccess/net/ftp.rb
Overview
Net::FTP class with IP access control. It uses output and occasionally input access lists. It and acts the same way as Net::FTP class but provides special member called acl and a few new instance methods for controlling IP access.
:include:ghost_doc_patched_usage.rb
This documentation doesn’t cover description of all class and instance methods of the original Net::FTP class, just the patched variants that make use of IP access control.
Examples
Using IPAccess::Net::FTP variant instead of Net::FTP, private access set
require 'ipaccess/net/ftp'
# set up FTP object with private ACL assigned
ftp = IPAccess::Net::FTP.new('ftp.pld-linux.org', :private)
ftp.passive = true
# login to remote host
ftp.login
files = ftp.chdir('/')
# blacklist the host (a bit late but we'll try)
ftp.blacklist 'ftp.pld-linux.org'
# try to get listing
files = ftp.list('n*')
ftp.close
Using patched Net::FTP instance
require 'ipaccess/net/ftp'
# create shared access set
acl = IPAccess::Set.new
acl.output.blacklist 'ftp.pld-linux.org'
# create an object and connect
ftp = Net::FTP.new('ftp.pld-linux.org')
ftp.passive = true
ftp.login
# arm the object and associate shared access set with it
IPAccess.arm ftp, acl
# perform some operations (an exception should be raised earlier)
files = ftp.chdir('/')
files = ftp.list('n*')
ftp.close
Using patched Net::FTP class
acl = IPAccess::Set.new
IPAccess.arm Net::FTP
ftp = Net::FTP.new('ftp.pld-linux.org')
ftp.acl = acl
ftp.passive = true
ftp.login
files = ftp.chdir('/')
acl.output.blacklist 'ftp.pld-linux.org'
files = ftp.list('n*')
ftp.close
Instance Attribute Summary collapse
-
#acl ⇒ Object
:include:ghost_doc_acl.rb === Example.
Attributes included from Patches::ACL
Class Method Summary collapse
-
.open ⇒ Object
:call-seq: open(host, acl)
{|ftp| …}|<br /> open(host, user, passwd, acl){|ftp| …}|<br /> open(host, user, passwd, account, acl){|ftp| …}|.
Instance Method Summary collapse
-
#acl_recheck ⇒ Object
This method allows you to re-check access on demad.
-
#blacklist ⇒ Object
(also: #add_black, #deny, #block)
:include:ghost_doc_p_blacklist.rb.
-
#blacklist! ⇒ Object
(also: #add_black!, #deny!, #block!)
:include:ghost_doc_p_blacklist_e.rb.
-
#blacklist_reasonable(reason, *addresses) ⇒ Object
This method works like blacklist but allows to set reason.
-
#blacklist_reasonable!(reason, *addresses) ⇒ Object
This method works like blacklist! but allows to set reason.
-
#initialize ⇒ FTP
constructor
:call-seq: new()<br /> new(acl)<br /> new(host, acl)<br /> new(host, user, passwd, acl)<br /> new(host, user, passwd, account, acl).
-
#unblacklist ⇒ Object
(also: #unblock, #del_black)
:include:ghost_doc_p_unblacklist.rb.
-
#unblacklist! ⇒ Object
(also: #unblock!, #del_black!)
:include:ghost_doc_p_unblacklist_e.rb.
-
#unwhitelist ⇒ Object
(also: #del_white)
:include:ghost_doc_p_unwhitelist.rb.
-
#unwhitelist! ⇒ Object
(also: #del_white!)
:include:ghost_doc_p_unwhitelist_e.rb.
-
#whitelist ⇒ Object
:include:ghost_doc_p_whitelist.rb.
-
#whitelist! ⇒ Object
:include:ghost_doc_p_whitelist_e.rb.
-
#whitelist_reasonable(reason, *addresses) ⇒ Object
This method works like whitelist but allows to set reason.
-
#whitelist_reasonable!(reason, *addresses) ⇒ Object
This method works like whitelist! but allows to set reason.
Methods included from Patches::ACL
#__ipa_wrap_socket_call, #close_on_deny, #close_on_deny=, #default_list, #terminate, #valid_acl?
Constructor Details
#initialize ⇒ FTP
:call-seq:
new()<br />
new(acl)<br />
new(host, acl)<br />
new(host, user, passwd, acl)<br />
new(host, user, passwd, account, acl)
Creates and returns a new FTP object. If a host is given, a connection is made. Additionally, if the user is given, the given user name, password, and (optionally) account are used to log in.
It optionally sets an access set given as the last parameter. If acl parameter is not given it defaults to IPAccess::Set.Global.
178 179 180 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 178 def initialize # Real code hidden. end |
Instance Attribute Details
#acl ⇒ Object
:include:ghost_doc_acl.rb
Example
require 'ipaccess/net/ftp' # load Net::FTP variant
ftp = IPAccess::Net::FTP.new('host') # create connected Telnet object
ftp.acl = :global # use global access set
ftp.acl = :private # create and use individual access set
ftp.acl = IPAccess::Set.new # use external (shared) access set
160 161 162 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 160 def acl @acl end |
Class Method Details
.open ⇒ Object
:call-seq:
open(host, acl) <tt>{|ftp| …}</tt>|<br />
open(host, user, passwd, acl) <tt>{|ftp| …}</tt>|<br />
open(host, user, passwd, account, acl) <tt>{|ftp| …}</tt>|
A synonym for new, but with a mandatory host parameter. If a block is given, it is passed the FTP object, which will be closed when the block finishes, or when an exception is raised.
It optionally sets an access set given as the last parameter. If the parameter is not given it defaults to IPAccess::Set.Global.
196 197 198 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 196 def self.open # Real code hidden. end |
Instance Method Details
#acl_recheck ⇒ Object
This method allows you to re-check access on demad. It uses internal socket’s address and access set assigned to an object. It will close your communication session before throwing an exception in case of denied access – you can prevent it by setting the flag opened_on_deny to true. The flag can be set while initializing object (through argument :opened_on_deny) or by setting the attribute.
209 210 211 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 209 def acl_recheck # Real code hidden. end |
#blacklist ⇒ Object Also known as: add_black, deny, block
:include:ghost_doc_p_blacklist.rb
105 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 105 def blacklist; end |
#blacklist! ⇒ Object Also known as: add_black!, deny!, block!
:include:ghost_doc_p_blacklist_e.rb
102 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 102 def blacklist!; end |
#blacklist_reasonable(reason, *addresses) ⇒ Object
This method works like blacklist but allows to set reason.
146 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 146 def blacklist_reasonable(reason, *addresses); end |
#blacklist_reasonable!(reason, *addresses) ⇒ Object
This method works like blacklist! but allows to set reason.
142 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 142 def blacklist_reasonable!(reason, *addresses); end |
#unblacklist ⇒ Object Also known as: unblock, del_black
:include:ghost_doc_p_unblacklist.rb
117 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 117 def unblacklist; end |
#unblacklist! ⇒ Object Also known as: unblock!, del_black!
:include:ghost_doc_p_unblacklist_e.rb
114 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 114 def unblacklist!; end |
#unwhitelist ⇒ Object Also known as: del_white
:include:ghost_doc_p_unwhitelist.rb
108 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 108 def unwhitelist; end |
#unwhitelist! ⇒ Object Also known as: del_white!
:include:ghost_doc_p_unwhitelist_e.rb
111 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 111 def unwhitelist!; end |
#whitelist ⇒ Object
:include:ghost_doc_p_whitelist.rb
99 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 99 def whitelist; end |
#whitelist! ⇒ Object
:include:ghost_doc_p_whitelist_e.rb
96 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 96 def whitelist!; end |
#whitelist_reasonable(reason, *addresses) ⇒ Object
This method works like whitelist but allows to set reason.
138 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 138 def whitelist_reasonable(reason, *addresses); end |
#whitelist_reasonable!(reason, *addresses) ⇒ Object
This method works like whitelist! but allows to set reason.
134 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 134 def whitelist_reasonable!(reason, *addresses); end |