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.
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
=== 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(*addresses) ⇒ Object
(also: #add_black, #deny, #block)
-
#blacklist!(*addresses) ⇒ Object
(also: #add_black!, #deny!, #block!)
-
#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(*addresses) ⇒ Object
(also: #unblock, #del_black)
-
#unblacklist!(*addresses) ⇒ Object
(also: #unblock!, #del_black!)
-
#unwhitelist(*addresses) ⇒ Object
(also: #del_white)
-
#unwhitelist!(*addresses) ⇒ Object
(also: #del_white!)
-
#whitelist(*addresses) ⇒ Object
-
#whitelist!(*addresses) ⇒ Object
-
#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
.
194 195 196 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 194 def initialize # Real code hidden. end |
Instance Attribute Details
#acl ⇒ Object
176 177 178 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 176 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
.
212 213 214 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 212 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.
225 226 227 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 225 def acl_recheck # Real code hidden. end |
#blacklist(*addresses) ⇒ Object #blacklist(list, *addresses) ⇒ Object Also known as: add_black, deny, block
113 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 113 def blacklist(*addresses); end |
#blacklist!(*addresses) ⇒ Object #blacklist!(list, *addresses) ⇒ Object Also known as: add_black!, deny!, block!
108 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 108 def blacklist!(*addresses); end |
#blacklist_reasonable(reason, *addresses) ⇒ Object
This method works like blacklist but allows to set reason.
162 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 162 def blacklist_reasonable(reason, *addresses); end |
#blacklist_reasonable!(reason, *addresses) ⇒ Object
This method works like blacklist! but allows to set reason.
158 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 158 def blacklist_reasonable!(reason, *addresses); end |
#unblacklist(*addresses) ⇒ Object #unblacklist(list, *addresses) ⇒ Object Also known as: unblock, del_black
133 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 133 def unblacklist(*addresses); end |
#unblacklist!(*addresses) ⇒ Object #unblacklist!(list, *addresses) ⇒ Object Also known as: unblock!, del_black!
128 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 128 def unblacklist!(*addresses); end |
#unwhitelist(*addresses) ⇒ Object #unwhitelist(list, *addresses) ⇒ Object Also known as: del_white
123 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 123 def unwhitelist(*addresses); end |
#unwhitelist!(*addresses) ⇒ Object #unwhitelist!(list, *addresses) ⇒ Object Also known as: del_white!
118 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 118 def unwhitelist!(*addresses); end |
#whitelist(*addresses) ⇒ Object #whitelist(list, *addresses) ⇒ Object
103 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 103 def whitelist(*addresses); end |
#whitelist!(*addresses) ⇒ Object #whitelist!(list, *addresses) ⇒ Object
98 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 98 def whitelist!(*addresses); end |
#whitelist_reasonable(reason, *addresses) ⇒ Object
This method works like whitelist but allows to set reason.
154 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 154 def whitelist_reasonable(reason, *addresses); end |
#whitelist_reasonable!(reason, *addresses) ⇒ Object
This method works like whitelist! but allows to set reason.
150 |
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_ftp.rb', line 150 def whitelist_reasonable!(reason, *addresses); end |