def __init__(self):
    self._fs = fs_client.FleetspeakConnection(
        version=config.CONFIG["Source.version_string"])

    self._sender_queue = queue.Queue(
        maxsize=GRRFleetspeakClient._SENDER_QUEUE_MAXSIZE)

    self._threads = {}

    if platform.system() == "Windows":
      internal_nanny_monitoring = False
      heart_beat_cb = self._fs.Heartbeat
    else:
      # TODO(amoser): Once the Fleetspeak nanny functionality is
      # production ready, change this to
      # internal_nanny_monitoring=False
      # heart_beat_cb=self._fs.Heartbeat
      internal_nanny_monitoring = True
      heart_beat_cb = None

    # The client worker does all the real work here.
    # In particular, we delegate sending messages to Fleetspeak to a separate
    # threading.Thread here.
    self._threads["Worker"] = comms.GRRClientWorker(
        out_queue=_FleetspeakQueueForwarder(self._sender_queue),
        heart_beat_cb=heart_beat_cb,
        internal_nanny_monitoring=internal_nanny_monitoring,
        client=self)
    self._threads["Foreman"] = self._CreateThread(self._ForemanOp)
    self._threads["Sender"] = self._CreateThread(self._SendOp)
    self._threads["Receiver"] = self._CreateThread(self._ReceiveOp)
Esempio n. 2
0
def Freezed():
    """Connects to Fleetspeak, then sleeps indefinitely."""
    logging.info("starting freezed")
    con = connector.FleetspeakConnection(version="0.5")
    logging.info("connection created")
    while True:
        time.sleep(1)
Esempio n. 3
0
def Heartbeat():
    """Sends a heartbeat every second, indefinitely."""
    logging.info("starting heartbeat")
    con = connector.FleetspeakConnection(version="0.5")
    logging.info("connection created")
    while True:
        time.sleep(1)
        con.Heartbeat()
Esempio n. 4
0
def MemoryHog():
    """Takes 20MB of memory, then sleeps forever."""
    logging.info("starting memory leak")
    con = connector.FleetspeakConnection(version="0.5")
    logging.info("connection created")
    buf = "a" * (1024 * 1024 * 20)
    while True:
        time.sleep(1)
Esempio n. 5
0
def Loopback():
    logging.info("starting loopback")
    con = connector.FleetspeakConnection(version="0.5")
    logging.info("connection created")
    while True:
        msg, _ = con.Recv()
        msg.message_type += "Response"
        con.Send(msg)