Esempio n. 1
0
        public static VersionModel Version(string versionText)
        {
            VersionModel version = new VersionModel();

            version.key   = "";
            version.value = versionText;
            return(version);
        }
Esempio n. 2
0
 private static VersionModel ConvertVersion(string versionText)
 {
     VersionModel version = new VersionModel {
         key = "",
         value = versionText
     };
     return version;
 }
Esempio n. 3
0
        private static VersionModel ConvertVersion(string versionText)
        {
            VersionModel version = new VersionModel {
                key   = "",
                value = versionText
            };

            return(version);
        }
Esempio n. 4
0
        public HomeModule()
        {
            this.RequiresAuthentication();

            Get["/"] = x => {
                return(Response.AsRedirect("/anthillasp"));
            };

            Get["/info"] = x => {
                return(View["page-info"]);
            };

            Get["/paramlist"] = x => {
                return(View["page-paramlist"]);
            };

            Get["/meminfo"] = x => {
                List <MeminfoModel> meminfo = Meminfo.GetModel();
                if (meminfo == null)
                {
                    return(View["page-meminfo"]);
                }
                return(View["page-meminfo", meminfo]);
            };

            Get["/meminfo/text"] = x => {
                var meminfo = Meminfo.GetText();
                return(Response.AsJson(meminfo));
            };

            Get["/network"] = x => {
                NetworkModel network = NetworkInfo.GetModel();
                if (network == null)
                {
                    return(View["page-network"]);
                }
                return(View["page-network", network]);
            };

            Post["/network"] = x => {
                string       hostname = (string)this.Request.Form.Hostname;
                NetworkModel network  = Antd.NetworkInfo.GetModel(hostname);
                if (network == null)
                {
                    return(View["page-network"]);
                }
                return(View["page-network", network]);
            };

            Get["/cpuinfo"] = x => {
                List <CpuinfoModel> cpuinfo = Cpuinfo.GetModel();
                if (cpuinfo == null)
                {
                    return(View["page-cpuinfo"]);
                }
                return(View["page-cpuinfo", cpuinfo]);
            };

            Get["/cpuinfo/text"] = x => {
                var cpuinfo = Cpuinfo.GetText();
                return(Response.AsJson(cpuinfo));
            };

            Get["/version"] = x => {
                VersionModel version = Version.GetModel();
                if (version == null)
                {
                    return(View["page-version"]);
                }
                return(View["page-version", version]);
            };

            Get["/version/text"] = x => {
                var version = Version.GetText();
                return(Response.AsJson(version));
            };

            Get["/dmidecode"] = x => {
                CommandModel command = Command.Launch("dmidecode", "");
                return(View["page-dmidecode", command]);
            };

            Get["/dmidecode/uuid"] = x => {
                CommandModel command = Command.Launch("dmidecode", "");
                string       uuid    = command.isError() ? null
                    : Dmidecode.GetUUID(command.outputTable);
                return(Response.AsJson(uuid));
            };

            Get["/dmidecode/text"] = x => {
                CommandModel command = Command.Launch("dmidecode", "");
                return(JsonConvert.SerializeObject(command.output));
            };

            Get["/ifconfig"] = x => {
                CommandModel command = Command.Launch("ifconfig", "");
                return(View["page-ifconfig", command]);
            };

            Get["/ifconfig/ether"] = x => {
                return(JsonConvert.SerializeObject(Ifconfig.GetEther()));
            };

            Get["/ifconfig/text"] = x => {
                CommandModel command = Command.Launch("ifconfig", "");
                return(JsonConvert.SerializeObject(command.output));
            };

            Get["/command"] = x => {
                return(View["page-command"]);
            };

            Post["/command"] = x => {
                string file = (string)this.Request.Form.File;
                string args = (string)this.Request.Form.Arguments;

                CommandModel command = Command.Launch(file, args);
                return(View["page-command", command]);
            };

            Get["/procs"] = x => {
                List <ProcModel> procs = Proc.All;
                return(View["page-procs", procs]);
            };

            Get["/procs/text"] = x => {
                CommandModel command = Command.Launch("ps", "-aef");
                return(JsonConvert.SerializeObject(command.output.Replace("\"", "")));
            };

            Post["/procs/kill"] = x => {
                string       pid     = (string)this.Request.Form.data;
                CommandModel command = Command.Launch("kill", pid);
                return(Response.AsRedirect("/procs"));
            };
        }