circuits.node.server module

class circuits.node.server.Server(port, server_ip='0.0.0.0', channel='node', receive_event_firewall=None, send_event_firewall=None, **kwargs)

Bases: circuits.core.components.BaseComponent

Node server.

Create server on node system.

Parameters:
  • port (int) – start server on this port.
  • server_ip (str) – An optional keyword argument which which define ip where the socket has listen to. Default: 0.0.0.0 (all ip is allowed)
  • channel (str) – An optional keyword argument which if defined, set channel used for node event. Default: node
  • receive_event_firewall (method) – An optional keyword argument which if defined, set function or method to call to check if event is allowed for sending Default: None (no firewall)
  • send_event_firewall (method) – An optional keyword argument which if defined, set function or method to call to check if event is allowed for executing Default: None (no firewall)
channel = 'node'
get_socks()

Get clients sockets list

Returns:The list of client socket
Return type:list of socket.socket
host
port
send(event, sock, no_result=False)

Send event to peer

Parameters:
  • event (circuits.core.events.Event) – Event to execute remotely.
  • sock (socket.socket) – Client’s socket (peer selection).
  • no_result (bool) – An optional keyword argument which if True don’t return the event result. Default: False (wait the result)
Returns:

The result of remote event

Return type:

generator

send_all(event)

Send event to all peer

Parameters:event (circuits.core.events.Event) – Event to execute remotely.
send_to(event, socks)

Send event to multiple peer

Parameters:
  • event (circuits.core.events.Event) – Event to execute remotely.
  • socks (list of socket.socket) – Client’s socket list (peer selection).