This initial commit for the PyDTLS package includes the following functionality: * DTLS cookie exchange, using secure hmac cookies * A platform-independent routing UDP demultiplexer * SSL handshaking over UDP using the DTLS protocol * Datagram exchange using the DTLS protocol * SSL shutdown over UDP The package is structured as follows: * dtls: top-level package * dtls.demux: demultiplexer package; automatically loads a demultiplexer appropriate for the currently executing platform * dtls.demux.router: a routing demux for platforms whose network stacks cannot assign incoming UDP packets to sockets based on the sockets' connection information * dtls.demux.osnet: a demux that uses the operating system's UDP packet routing functionality * dtls.err: package-wide error handling and error definitions * dtls.sslconnection: a client and server-side connection class for UDP network connections secured with the DTLS protocol * dtls.openssl: a ctypes-based wrapper for the OpenSSL library * dtls.test: test scripts, utilities, and unit tests The following binaries are provided: * libeay32.dll: cryptographic portion of the OpenSSL library * ssleay32.dll: protocol portion of the OpenSSL library (depends on former) * cygcrypto-1.0.0.dll: as libeay32.dll, but with debugging symbols * cygssl-1.0.0.dll: as ssleay32.dll, but with debugging symbols All binaries have been built with the MinGW tool chain, targeted for msvcr90. The unstripped dll's can be debugged on Windows with gdb. Cygwin is not used.
63 lines
2.0 KiB
Python
63 lines
2.0 KiB
Python
# OSNet demux: uses the OS network stack to demultiplex incoming datagrams
|
|
# among sockets bound to the same ports. Written by Ray Brown.
|
|
"""OS Network UDP Demux
|
|
|
|
This module implements a demux that uses the OS network stack to demultiplex
|
|
datagrams coming from different peers among datagram sockets that are all bound
|
|
to the port at which these datagrams are being received. The network stack is
|
|
instructed as to which socket an incoming datagram should be sent to by
|
|
connecting the destination socket to the peer endpoint.
|
|
|
|
The OSNet demux requires operating system functionality that exists in the
|
|
Linux kernel, but not in the Windows network stack.
|
|
|
|
Classes:
|
|
|
|
UDPDemux -- a network stack configuring UDP demux
|
|
|
|
Exceptions:
|
|
|
|
KeyError -- raised for unknown peer addresses
|
|
"""
|
|
|
|
|
|
class UDPDemux(object):
|
|
"""OS network stack configuring demux
|
|
|
|
This class implements a demux that creates sockets connected to peer
|
|
network endpoints, configuring the network stack to demultiplex
|
|
incoming datagrams from these endpoints among these sockets.
|
|
|
|
Methods:
|
|
|
|
get_connection -- create a new connection or retrieve an existing one
|
|
remove_connection -- remove an existing connection
|
|
service -- this method does nothing for this type of demux
|
|
"""
|
|
|
|
def get_connection(self, address):
|
|
"""Create or retrieve a muxed connection
|
|
|
|
Arguments:
|
|
address -- a peer endpoint in IPv4/v6 address format; None refers
|
|
to the connection for unknown peers
|
|
|
|
Return:
|
|
a bound, connected datagram socket instance, or the root socket
|
|
in case address was None
|
|
"""
|
|
|
|
def remove_connection(self, address):
|
|
"""Remove a muxed connection
|
|
|
|
Arguments:
|
|
address -- an address for which a muxed connection was previously
|
|
retrieved through get_connection, which has not yet
|
|
been removed
|
|
|
|
Return:
|
|
the socket object whose connection has been removed
|
|
"""
|
|
|
|
return self.connections.pop(address)
|