Package pike :: Module model :: Class Connection
[hide private]
[frames] | no frames]

Class Connection

source code

         object --+    
                  |    
transport.Transport --+
                      |
                     Connection

Connection to server.

Represents a connection to a server and handles all socket operations and request/response dispatch.

Nested Classes [hide private]
  SessionSetupContext
Instance Methods [hide private]
 
__init__(self, client, server, port=445)
Constructor.
source code
 
callback(*args, **kwds)
Register a callback function for the context block, then unregister it
source code
 
register_callback(self, event, cb)
Registers a callback function, cb for the given event.
source code
 
unregister_callback(self, event, cb)
Unregisters a callback function, cb for the given event.
source code
 
process_callbacks(self, event, obj)
Fire callbacks for the given event, passing obj as the parameter
source code
 
smb3_pa_integrity(self, packet, data=None)
perform smb3 pre-auth integrity hash update if needed
source code
 
next_mid_range(self, length)
multicredit requests must reserve 1 message id per credit charged.
source code
 
next_mid(self) source code
 
reserve_mid(mid) source code
 
handle_connect(self)
callback fired when connection is established
source code
 
handle_read(self)
callback fired when the socket has data available
source code
 
handle_write(self)
callback fired when the socket is available for writing
source code
 
handle_close(self)
callback fired when the socket is closed
source code
 
handle_error(self)
callback fired if a non-recoverable exception is raised
source code
 
close(self)
Close connection.
source code
 
_prepare_outgoing(self) source code
 
_find_oplock_future(self, file_id) source code
 
_find_lease_future(self, lease_key) source code
 
_dispatch_incoming(self, res) source code
 
submit(self, req)
Submit request.
source code
 
transceive(self, req)
Submit request and wait for responses.
source code
 
negotiate_request(self, hash_algorithms=None, salt=None, ciphers=None) source code
 
negotiate_submit(self, negotiate_request) source code
 
negotiate(self, hash_algorithms=None, salt=None, ciphers=None)
Perform dialect negotiation.
source code
 
session_setup(self, creds=None, bind=None, resume=None)
Establish a session.
source code
 
frame(self) source code
 
request(self, parent=None) source code
 
let(self, **kwargs) source code
 
session(self, session_id) source code
 
signing_key(self, session_id) source code
 
encryption_context(self, session_id) source code
 
signing_digest(self) source code
 
get_request(self, message_id) source code

Inherited from transport.Transport: connect, create_socket, handle_connect_event, recv, send, set_socket

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables [hide private]
Client client
The Client object associated with this connection.
  port
The server port
  server
The server name or address
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, client, server, port=445)
(Constructor)

source code 

Constructor.

This should generally not be used directly. Instead, use Client.connect().

Overrides: object.__init__

callback(*args, **kwds)

source code 

Register a callback function for the context block, then unregister it

Decorators:
  • @contextlib.contextmanager

register_callback(self, event, cb)

source code 

Registers a callback function, cb for the given event. When the event fires, cb will be called with the relevant top-level Netbios frame as the single paramter.

process_callbacks(self, event, obj)

source code 

Fire callbacks for the given event, passing obj as the parameter

Connection-specific callbacks will be fired first, followed by client callbacks

next_mid_range(self, length)

source code 

multicredit requests must reserve 1 message id per credit charged. the message id of the request should be the first id of the range.

handle_connect(self)

source code 

callback fired when connection is established

Overrides: transport.Transport.handle_connect
(inherited documentation)

handle_read(self)

source code 

callback fired when the socket has data available

Overrides: transport.Transport.handle_read
(inherited documentation)

handle_write(self)

source code 

callback fired when the socket is available for writing

note: unlike asyncore, write notifications are not provided by default. this is a performance optimization because the socket is usually available for writing, and the application usually knows when it wants to write. There is no point in filling the event queues with write ready messages that will be ignored if the client has no data to send.

Instead, applications are expected to implement handle_write, but to call it directly when data is to be sent. IF the socket would block, EALREADY will be handled by the Transport. The Transport requests a single write notification from the pollwer; when received, handle_write will be called once signalling that the socket may now be ready to retry

If the application would prefer to be notified when the socket is ready to write, transport.poller.defer_write(transport) may be called to schedule a single handle_write callback.

Overrides: transport.Transport.handle_write
(inherited documentation)

handle_close(self)

source code 

callback fired when the socket is closed

Overrides: transport.Transport.handle_close
(inherited documentation)

handle_error(self)

source code 

callback fired if a non-recoverable exception is raised

Overrides: transport.Transport.handle_error
(inherited documentation)

close(self)

source code 

Close connection.

This unceremoniously terminates the connection and fails all outstanding requests with EOFError.

Overrides: transport.Transport.close

submit(self, req)

source code 

Submit request.

Submits a netbios.Netbios frame for sending. Returns a list of Future objects, one for each corresponding smb2.Smb2 frame in the request.

transceive(self, req)

source code 

Submit request and wait for responses.

Submits a netbios.Netbios frame for sending. Waits for and returns a list of smb2.Smb2 response objects, one for each corresponding smb2.Smb2 frame in the request.

negotiate(self, hash_algorithms=None, salt=None, ciphers=None)

source code 

Perform dialect negotiation.

This must be performed before setting up a session with Connection.session_setup().

session_setup(self, creds=None, bind=None, resume=None)

source code 

Establish a session.

Establishes a session, performing GSS rounds as necessary. Returns a Channel object which can be used for further requests on the given connection and session.

Parameters:
  • creds (str) - A set of credentials of the form '<domain>\<user>%<password>'. If specified, NTLM authentication will be used. If None, Kerberos authentication will be attempted.
  • bind (Session) - An existing session to bind.
  • resume (Session) - An previous session to resume.