Class: IPAccess::TCPSocket

Inherits:
TCPSocket
  • Object
show all
Includes:
Patches::TCPSocket
Defined in:
lib/ipaccess/ghost_doc/ghost_doc_sockets.rb,
lib/ipaccess/socket.rb

Overview

TCPSocket class with IP access control. It uses output access lists.

This class acts the same way as TCPSocket 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 TCPSocket class, just the patched variants that make use of IP access control.

Example

require 'ipaccess/socket'                                         # load sockets subsystem

acl_set = IPAccess::Set.new                                            # create shared access set
acl_set.output.block 'randomseed.pl'                              # block connections to this host

socket = IPAccess::TCPSocket.new('randomseed.pl', 80)

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, #blacklist_reasonable, #blacklist_reasonable!, #close_on_deny, #close_on_deny=, #default_list, #terminate, #valid_acl?, #whitelist_reasonable, #whitelist_reasonable!

Constructor Details

#initializeTCPSocket

:call-seq:

new(addr, port) <tt>{|socket| …}</tt><br />
new(addr, port, acl) <tt>{|socket| …}</tt>

Creates a new object and attempts to connect to the host and port. If a block is provided, it is yielded as socket object. 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.



447
448
449
# File 'lib/ipaccess/ghost_doc/ghost_doc_sockets.rb', line 447

def initialize
  # Real code hidden.
end

Instance Attribute Details

#aclObject

This member keeps the information about currently used access set. You may use it to do low-level operations on IPAccess::Set object associated with instance. You cannot however call any of global access set operations – to do that use IPAccess::Set.Global contant referencing to global ACL.



432
433
434
# File 'lib/ipaccess/ghost_doc/ghost_doc_sockets.rb', line 432

def acl
  @acl
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.



460
461
462
# File 'lib/ipaccess/ghost_doc/ghost_doc_sockets.rb', line 460

def acl_recheck
  # Real code hidden.
end

#blacklistObject Also known as: add_black, deny, block

:include:ghost_doc_p_blacklist.rb



378
# File 'lib/ipaccess/ghost_doc/ghost_doc_sockets.rb', line 378

def blacklist; end

#blacklist!Object Also known as: add_black!, deny!, block!

:include:ghost_doc_p_blacklist_e.rb



375
# File 'lib/ipaccess/ghost_doc/ghost_doc_sockets.rb', line 375

def blacklist!; end

#unblacklistObject Also known as: unblock, del_black

:include:ghost_doc_p_unblacklist.rb



390
# File 'lib/ipaccess/ghost_doc/ghost_doc_sockets.rb', line 390

def unblacklist; end

#unblacklist!Object Also known as: unblock!, del_black!

:include:ghost_doc_p_unblacklist_e.rb



387
# File 'lib/ipaccess/ghost_doc/ghost_doc_sockets.rb', line 387

def unblacklist!; end

#unwhitelistObject Also known as: del_white

:include:ghost_doc_p_unwhitelist.rb



384
# File 'lib/ipaccess/ghost_doc/ghost_doc_sockets.rb', line 384

def unwhitelist; end

#unwhitelist!Object Also known as: del_white!

:include:ghost_doc_p_unwhitelist_e.rb



381
# File 'lib/ipaccess/ghost_doc/ghost_doc_sockets.rb', line 381

def unwhitelist!; end

#whitelistObject

:include:ghost_doc_p_whitelist.rb



372
# File 'lib/ipaccess/ghost_doc/ghost_doc_sockets.rb', line 372

def whitelist; end

#whitelist!Object

:include:ghost_doc_p_whitelist_e.rb



369
# File 'lib/ipaccess/ghost_doc/ghost_doc_sockets.rb', line 369

def whitelist!; end