コード例 #1
0
 def FromFleetspeakProto(cls,
                         proto: common_pb2.Message) -> "ApiFleetspeakMessage":
   result = ApiFleetspeakMessage(
       message_id=proto.message_id,
       source_message_id=proto.source_message_id,
       message_type=proto.message_type,
       priority=cls._PriorityFromFleetspeakProto(proto.priority),
       background=proto.background,
   )
   if proto.HasField("source"):
     result.source = ApiFleetspeakAddress.FromFleetspeakProto(proto.source)
   if proto.HasField("destination"):
     result.destination = ApiFleetspeakAddress.FromFleetspeakProto(
         proto.destination)
   if proto.HasField("creation_time"):
     result.creation_time = rdfvalue.RDFDatetime.FromDatetime(
         proto.creation_time.ToDatetime())
   if proto.HasField("data"):
     result.data = cls._AnyFromFleetspeakProto(proto.data)
   if proto.HasField("validation_info"):
     result.validation_info = ApiFleetspeakValidationInfo.FromFleetspeakProto(
         proto.validation_info)
   if proto.HasField("result"):
     result.result = ApiFleetspeakMessageResult.FromFleetspeakProto(
         proto.result)
   if proto.HasField("annotations"):
     result.annotations = ApiFleetspeakAnnotations.FromFleetspeakProto(
         proto.annotations)
   return result
コード例 #2
0
ファイル: frr_client.py プロジェクト: tsehori/fleetspeak
def main(argv):
    del argv  # Unused.

    connection = FleetspeakConnection(version="0.0.1")
    while True:
        request, _ = connection.Recv()
        if request.message_type != "TrafficRequest":
            continue

        request_data = TrafficRequestData()
        request.data.Unpack(request_data)

        response_data = TrafficResponseData(master_id=request_data.master_id,
                                            request_id=request_data.request_id,
                                            response_index=0,
                                            data=b"client response",
                                            fin=True)

        response = Message()
        response.destination.service_name = request.source.service_name
        response.data.Pack(response_data)
        response.message_type = "TrafficResponse"

        connection.Send(response)
コード例 #3
0
ファイル: stat.py プロジェクト: kokhnovich/rust-stat
def main(argv=None):
    del argv  # Unused.

    service_client = InsecureGRPCServiceClient("stat")
    service_client.Listen(listener)

    while True:
        request = Request()
        request.path = input("Enter a path to stat: ")

        message = Message()
        message.destination.client_id = binascii.unhexlify(FLAGS.client_id)
        message.destination.service_name = "stater"
        message.data.Pack(request)

        service_client.Send(message)