trixy

The main Trixy module contains the parent classes that can be modified for custom functionality.

class trixy.TrixyInput(sock, addr)[source]

Bases: trixy.TrixyNode, asyncore.dispatcher_with_send

Once a connection is open, establish an output chain.

add_downstream_node(node)

Add a one direction downstream link to the node parameter.

Parameters:node (TrixyNode) – The downstream node to create a unidirectional link to.
add_upstream_node(node)

Add a one direction upstream link to the node parameter.

Parameters:node (TrixyNode) – The upstream node to create a unidirectional link to.
connect_node(node)

Create a bidirectional connection between the two nodes with the downstream node being the parameter.

Parameters:node (TrixyNode) – The downstream node to create a bidirectional connection to.
forward_packet_down(data)

Forward data to all downstream nodes.

Parameters:data (bytes) – The data to forward.
forward_packet_up(data)

Forward data to all upstream nodes.

Parameters:data (bytes) – The data to forward.
handle_packet_down(data)

Hadle data moving downwards. TrixyProcessor children should perform some action on data whereas TrixyOutput children should send the data to the desired output location.

Generally, the a child implementation of this method should be implemented such that it calls self.forward_packet_down with the data (post-modification if necessary) to forward the data to other processors in the chain. However, if the processor is a filter, it may drop the packet by omitting that call.

Parameters:data (bytes) – The data that is being handled.
class trixy.TrixyNode[source]

Bases: builtins.object

A base class for TrixyNodes that implements some default packet forwarding and node linking.

add_downstream_node(node)[source]

Add a one direction downstream link to the node parameter.

Parameters:node (TrixyNode) – The downstream node to create a unidirectional link to.
add_upstream_node(node)[source]

Add a one direction upstream link to the node parameter.

Parameters:node (TrixyNode) – The upstream node to create a unidirectional link to.
connect_node(node)[source]

Create a bidirectional connection between the two nodes with the downstream node being the parameter.

Parameters:node (TrixyNode) – The downstream node to create a bidirectional connection to.
forward_packet_down(data)[source]

Forward data to all downstream nodes.

Parameters:data (bytes) – The data to forward.
forward_packet_up(data)[source]

Forward data to all upstream nodes.

Parameters:data (bytes) – The data to forward.
handle_close(direction='down')[source]

The connection has closed on one end. So, shutdown what we are doing and notify the nodes we are connected to.

Parameters:direction (str) – ‘down’ or ‘up’ depending on if downstream nodes need to be closed, or upstream nodes need to be closed.
handle_packet_down(data)[source]

Hadle data moving downwards. TrixyProcessor children should perform some action on data whereas TrixyOutput children should send the data to the desired output location.

Generally, the a child implementation of this method should be implemented such that it calls self.forward_packet_down with the data (post-modification if necessary) to forward the data to other processors in the chain. However, if the processor is a filter, it may drop the packet by omitting that call.

Parameters:data (bytes) – The data that is being handled.
handle_packet_up(data)[source]

Hadle data moving upwards. TrixyProcessor children should perform some action on data whereas TrixyOutput children should send the data to the desired output location.

Generally, the a child implementation of this method should be implemented such that it calls self.forward_packet_down with the data (post-modification if necessary) to forward the data to other processors in the chain. However, if the processor is a filter, it may drop the packet by omitting that call.

Parameters:data (bytes) – The data that is being handled.
class trixy.TrixyOutput(host, port, autoconnect=True)[source]

Bases: trixy.TrixyNode, asyncore.dispatcher_with_send

Output the data, generally to another network service.

add_downstream_node(node)

Add a one direction downstream link to the node parameter.

Parameters:node (TrixyNode) – The downstream node to create a unidirectional link to.
add_upstream_node(node)

Add a one direction upstream link to the node parameter.

Parameters:node (TrixyNode) – The upstream node to create a unidirectional link to.
assume_connected(host, port, sock)[source]

Assume that the connection has already been made. Setup all state accordingly. This is useful in situations where one output wants to pass off work to a different output (for example, a proxy output might establish the connection and then pass it off to an SSL output (which needs to act on the raw socket object).

connect_node(node)

Create a bidirectional connection between the two nodes with the downstream node being the parameter.

Parameters:node (TrixyNode) – The downstream node to create a bidirectional connection to.
forward_packet_down(data)

Forward data to all downstream nodes.

Parameters:data (bytes) – The data to forward.
forward_packet_up(data)

Forward data to all upstream nodes.

Parameters:data (bytes) – The data to forward.
handle_packet_up(data)

Hadle data moving upwards. TrixyProcessor children should perform some action on data whereas TrixyOutput children should send the data to the desired output location.

Generally, the a child implementation of this method should be implemented such that it calls self.forward_packet_down with the data (post-modification if necessary) to forward the data to other processors in the chain. However, if the processor is a filter, it may drop the packet by omitting that call.

Parameters:data (bytes) – The data that is being handled.
setup_socket(host, port, autoconnect=True)[source]

Establish the outbound connection.

Parameters:
  • host (str) – The hostname to connect to.
  • port (int) – The port on the host to connect to.
  • autoconnect (bool) – Should the connection be established now, or should it be manually triggered later?
supports_assumed_connections = True

Denotes whether assumed connections are assumed by the class.

class trixy.TrixyProcessor[source]

Bases: trixy.TrixyNode

Perform processing on data moving through Trixy.

add_downstream_node(node)

Add a one direction downstream link to the node parameter.

Parameters:node (TrixyNode) – The downstream node to create a unidirectional link to.
add_upstream_node(node)

Add a one direction upstream link to the node parameter.

Parameters:node (TrixyNode) – The upstream node to create a unidirectional link to.
connect_node(node)

Create a bidirectional connection between the two nodes with the downstream node being the parameter.

Parameters:node (TrixyNode) – The downstream node to create a bidirectional connection to.
forward_packet_down(data)

Forward data to all downstream nodes.

Parameters:data (bytes) – The data to forward.
forward_packet_up(data)

Forward data to all upstream nodes.

Parameters:data (bytes) – The data to forward.
handle_close(direction='down')

The connection has closed on one end. So, shutdown what we are doing and notify the nodes we are connected to.

Parameters:direction (str) – ‘down’ or ‘up’ depending on if downstream nodes need to be closed, or upstream nodes need to be closed.
handle_packet_down(data)

Hadle data moving downwards. TrixyProcessor children should perform some action on data whereas TrixyOutput children should send the data to the desired output location.

Generally, the a child implementation of this method should be implemented such that it calls self.forward_packet_down with the data (post-modification if necessary) to forward the data to other processors in the chain. However, if the processor is a filter, it may drop the packet by omitting that call.

Parameters:data (bytes) – The data that is being handled.
handle_packet_up(data)

Hadle data moving upwards. TrixyProcessor children should perform some action on data whereas TrixyOutput children should send the data to the desired output location.

Generally, the a child implementation of this method should be implemented such that it calls self.forward_packet_down with the data (post-modification if necessary) to forward the data to other processors in the chain. However, if the processor is a filter, it may drop the packet by omitting that call.

Parameters:data (bytes) – The data that is being handled.
class trixy.TrixyServer(tinput, host, port)[source]

Bases: asyncore.dispatcher

Main server to grab incoming connections and forward them.