Class: IPAccess::Net::Telnet

Inherits:
Net::Telnet
  • Object
show all
Includes:
Patches::Net::Telnet
Defined in:
lib/ipaccess/ghost_doc/ghost_doc_net_telnet.rb,
lib/ipaccess/net/telnet.rb

Overview

Net::Telnet class with IP access control. It uses output access lists and acts the same way as Net::Telnet class but provides 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::Telnet class, just the patched variants that make use of IP access control.

Examples

Global access set, using IPAccess::Net::Telnet

require 'ipaccess/net/telnet'         # load Net::Telnet version and IPAccess.arm method

opts = {}               
opts["Host"]  = 'randomseed.pl'   
opts["Port"]  = '80'

IPAccess::Set::Global.output.blacklist 'randomseed.pl' # blacklist host
t = IPAccess::Net::Telnet.new(opts)               # try to connect to remote host

Global access set, single object patched, direct blacklisting

require 'ipaccess/net/telnet'     # load Net::Telnet version and IPAccess.arm method

opts = {}
opts["Host"]  = 'randomseed.pl'
opts["Port"]  = '80'

t = Net::Telnet.new(opts)       # try to connect to remote host
IPAccess.arm t                  # arm single Telnet object (will use global access set)
t.blacklist! 'randomseed.pl'    # blacklist host while being connected

Shared access set, single object patched

require 'ipaccess/net/telnet'         # load Net::Telnet version and IPAccess.arm method

opts = {}                          
opts["Host"]  = 'randomseed.pl'    
opts["Port"]  = '80'               

t = Net::Telnet.new(opts)             # try to connect to remote host

acl = IPAccess::Set.new                    # create custom access set
acl.output.blacklist 'randomseed.pl'  # blacklist host in access set
IPAccess.arm t, acl                   # arm single Telnet object with access set passed

Shared access set, single object patched, direct blacklisting

require 'ipaccess/net/telnet'         # load Net::Telnet version and IPAccess.arm method

opts = {}                          
opts["Host"]  = 'randomseed.pl'
opts["Port"]  = '80'               

t = Net::Telnet.new(opts)             # try to connect to remote host

acl = IPAccess::Set.new                    # create custom access set
IPAccess.arm t, acl                   # arm single Telnet object with access set passed
t.blacklist 'randomseed.pl'           # blacklist host

Shared access set, class patched

require 'ipaccess/net/telnet'         # load Net::Telnet version and IPAccess.arm method

opts = {}
opts["Host"]  = 'randomseed.pl'
opts["Port"]  = '80'

IPAccess.arm Net::Telnet                      # patch Net::Telnet class  
opts['ACL'] = IPAccess::Set.new                    # create custom access set and add it to options
opts['ACL'].output.blacklist 'randomseed.pl'  # blacklist host

t = Net::Telnet.new(opts)             # try to connect to remote host

Private access set, class patched, direct blacklisting

require 'ipaccess/net/telnet'         # load Net::Telnet version and IPAccess.arm method

opts = {}
opts["Host"]  = 'randomseed.pl'
opts["Port"]  = '80'

IPAccess.arm Net::Telnet              # patch Net::Telnet class  

t = Net::Telnet.new(opts, :private)   # try to connect to remote host
t.blacklist 'randomseed.pl'           # blacklist host

Instance Attribute Summary collapse

Attributes included from Patches::ACL

#opened_on_deny

Instance Method Summary collapse

Methods included from Patches::ACL

#__ipa_wrap_socket_call, #close_on_deny, #close_on_deny=, #default_list, #terminate, #valid_acl?

Constructor Details

#initializeTelnet

:call-seq:

new(opts) <tt>{|mesg| …}</tt><br />
new(opts, acl) <tt>{|mesg| …}</tt>

Creates a new object and attempts to connect to the host (unless the Proxy option is provided). If a block is provided, it is yielded as status messages on the attempt to connect to the server. It optionally sets an access set given as the last parameter or as ACL member of opts. The access set given as an argument has precedence over access set given in options. If ACL parameter is not given it defaults to ACL to IPAccess::Set.Global.



226
227
228
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_telnet.rb', line 226

def initialize
  # Real code hidden.
end

Instance Attribute Details

#aclObject

Example

require 'ipaccess/net/telnet'             # load Net::Telnet variant

opts = {}
opts["Host"] = 'randomseed.pl'
telnet = IPAccess::Net::Telnet.new(opts)  # create connected Telnet object

telnet.acl = :global                      # use global access set
telnet.acl = :private                     # create and use individual access set
telnet.acl = IPAccess::Set.new                 # use external (shared) access set


203
204
205
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_telnet.rb', line 203

def acl
  @acl
end

#sockObject (readonly)

The socket the Telnet object is using, which is kind of TCPSocket and responds to all methods of IPAccess::TCPSocket. Note that this object becomes a delegate of the Telnet object, so normally you invoke its methods directly on the Telnet object.



210
211
212
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_telnet.rb', line 210

def sock
  @sock
end

Instance Method Details

#acl_recheckObject

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.



239
240
241
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_telnet.rb', line 239

def acl_recheck
  # Real code hidden.
end

#blacklist(*addresses) ⇒ Object #blacklist(list, *addresses) ⇒ Object Also known as: add_black, deny, block



138
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_telnet.rb', line 138

def blacklist(*addresses); end

#blacklist!(*addresses) ⇒ Object #blacklist!(list, *addresses) ⇒ Object Also known as: add_black!, deny!, block!



133
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_telnet.rb', line 133

def blacklist!(*addresses); end

#blacklist_reasonable(reason, *addresses) ⇒ Object

This method works like blacklist but allows to set reason.



187
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_telnet.rb', line 187

def blacklist_reasonable(reason, *addresses); end

#blacklist_reasonable!(reason, *addresses) ⇒ Object

This method works like blacklist! but allows to set reason.



183
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_telnet.rb', line 183

def blacklist_reasonable!(reason, *addresses); end

#unblacklist(*addresses) ⇒ Object #unblacklist(list, *addresses) ⇒ Object Also known as: unblock, del_black



158
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_telnet.rb', line 158

def unblacklist(*addresses); end

#unblacklist!(*addresses) ⇒ Object #unblacklist!(list, *addresses) ⇒ Object Also known as: unblock!, del_black!



153
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_telnet.rb', line 153

def unblacklist!(*addresses); end

#unwhitelist(*addresses) ⇒ Object #unwhitelist(list, *addresses) ⇒ Object Also known as: del_white



148
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_telnet.rb', line 148

def unwhitelist(*addresses); end

#unwhitelist!(*addresses) ⇒ Object #unwhitelist!(list, *addresses) ⇒ Object Also known as: del_white!



143
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_telnet.rb', line 143

def unwhitelist!(*addresses); end

#whitelist(*addresses) ⇒ Object #whitelist(list, *addresses) ⇒ Object



128
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_telnet.rb', line 128

def whitelist(*addresses); end

#whitelist!(*addresses) ⇒ Object #whitelist!(list, *addresses) ⇒ Object



123
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_telnet.rb', line 123

def whitelist!(*addresses); end

#whitelist_reasonable(reason, *addresses) ⇒ Object

This method works like whitelist but allows to set reason.



179
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_telnet.rb', line 179

def whitelist_reasonable(reason, *addresses); end

#whitelist_reasonable!(reason, *addresses) ⇒ Object

This method works like whitelist! but allows to set reason.



175
# File 'lib/ipaccess/ghost_doc/ghost_doc_net_telnet.rb', line 175

def whitelist_reasonable!(reason, *addresses); end