示例#1
0
 public ExtensionStatus deregisterExtension(long uuid)
 {
     ExtensionManager.Client client = new ClientManager().getClient();
     if (uuid == -1)
     {
         throw new ExtensionException {
                   Code = 1, Message = "Extension Manager does not have a valid UUID", Uuid = uuid
         };
     }
     try
     {
         ExtensionStatus status = client.deregisterExtension(uuid);
         if (status.Code != 0)
         {
             throw new ExtensionException {
                       Code = 1, Message = status.Message, Uuid = uuid
             };
         }
         return(status);
     }
     catch (TException e)
     {
         throw new ExtensionException {
                   Code = 1, Message = "Could not connect to socket", Uuid = uuid
         };
     }
 }
示例#2
0
        /**
         * OSQuery ping method.
         *
         * @throws TException
         * @see osquery.extensions.Extension.Iface#ping()
         */
        public ExtensionStatus ping()
        {
            ExtensionStatus status = new ExtensionStatus
            {
                Code    = 0,
                Message = "OK",
                Uuid    = uuid != null ? uuid.Value : 0L
            };

            return(status);
        }
示例#3
0
        public void startExtension(string name, string version, string sdkVersion, string minSdkVersion)
        {
            ExtensionManager.Client client = new ClientManager(EXTENSION_SOCKET).getClient();
            InternalExtensionInfo   info   = new InternalExtensionInfo {
                Name = name, Version = version, Sdk_version = sdkVersion, Min_sdk_version = minSdkVersion
            };

            try
            {
                client.OutputProtocol.Transport.Open();
                ExtensionStatus status = client.registerExtension(info, registry);
                if (status.Code == 0)
                {
                    this.uuid = status.Uuid;
                    var    processor        = new ExtensionManager.Processor(this);
                    String serverSocketPath = EXTENSION_SOCKET + "." + uuid.ToString();

                    if (File.Exists(serverSocketPath))
                    {
                        File.Delete(serverSocketPath);
                    }
                    //TODO: uncomment below

                    //var socket1 = new UnixEndPoint(EXTENSION_SOCKET);
                    var socket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.IP);

                    //var listener = new TcpListener(IPAddress.Any, 9090);
                    //TServerSocket transport = new TServerSocket(9090);
                    TTransportFactory transportFactory = new TTransportFactory();
                    TProtocolFactory  protocolFactory  = new TBinaryProtocol.Factory();

                    TServerTransport serverTransport = new TNamedPipeServerTransport(serverSocketPath);
                    TTransport       trans           = client.InputProtocol.Transport;
                    TServer          server          = new TSimpleServer(processor, serverTransport, transportFactory, protocolFactory);
                    server.Serve(); //Starting the server
                }
                else
                {
                    throw new ExtensionException {
                              Code = 1, Message = status.Message, Uuid = uuid ?? -1
                    };
                }
            }
            catch (TException e)
            {
                throw new ExtensionException {
                          Code = 1, Message = "Could not connect to socket", Uuid = uuid ?? -1
                };
            }
        }
示例#4
0
        public void Read(TProtocol iprot)
        {
            iprot.IncrementRecursionDepth();
            try
            {
                TField field;
                iprot.ReadStructBegin();
                while (true)
                {
                    field = iprot.ReadFieldBegin();
                    if (field.Type == TType.Stop)
                    {
                        break;
                    }
                    switch (field.ID)
                    {
                    case 0:
                        if (field.Type == TType.Struct)
                        {
                            Success = new ExtensionStatus();
                            Success.Read(iprot);
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    default:
                        TProtocolUtil.Skip(iprot, field.Type);
                        break;
                    }
                    iprot.ReadFieldEnd();
                }
                iprot.ReadStructEnd();
            }
            finally
            {
                iprot.DecrementRecursionDepth();
            }
        }
    public void Read(TProtocol iprot)
    {
        iprot.IncrementRecursionDepth();
        try
        {
            TField field;
            iprot.ReadStructBegin();
            while (true)
            {
                field = iprot.ReadFieldBegin();
                if (field.Type == TType.Stop)
                {
                    break;
                }
                switch (field.ID)
                {
                case 1:
                    if (field.Type == TType.Struct)
                    {
                        Status = new ExtensionStatus();
                        Status.Read(iprot);
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 2:
                    if (field.Type == TType.List)
                    {
                        {
                            Response = new List <Dictionary <string, string> >();
                            TList _list0 = iprot.ReadListBegin();
                            for (int _i1 = 0; _i1 < _list0.Count; ++_i1)
                            {
                                Dictionary <string, string> _elem2;
                                {
                                    _elem2 = new Dictionary <string, string>();
                                    TMap _map3 = iprot.ReadMapBegin();
                                    for (int _i4 = 0; _i4 < _map3.Count; ++_i4)
                                    {
                                        string _key5;
                                        string _val6;
                                        _key5         = iprot.ReadString();
                                        _val6         = iprot.ReadString();
                                        _elem2[_key5] = _val6;
                                    }
                                    iprot.ReadMapEnd();
                                }
                                Response.Add(_elem2);
                            }
                            iprot.ReadListEnd();
                        }
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                default:
                    TProtocolUtil.Skip(iprot, field.Type);
                    break;
                }
                iprot.ReadFieldEnd();
            }
            iprot.ReadStructEnd();
        }
        finally
        {
            iprot.DecrementRecursionDepth();
        }
    }