コード例 #1
0
        protected override void InitActionListImpl(CgiActionList noAuth, CgiActionList reqAuth)
        {
            try
            {
                noAuth.AddAction("/", WebMethodBits.GET | WebMethodBits.HEAD, async(ctx) =>
                {
                    await Task.CompletedTask;

                    var hostname = ctx.QueryString._GetStrFirst("hostname");
                    var body     = ctx.QueryString._GetStrFirst("body");

                    if (hostname._IsFilled() && body._IsFilled())
                    {
                        ReportedItem r = new ReportedItem(DateTimeOffset.Now, hostname, ctx.ClientIpAddress.ToString(), body);

                        this.AddReport(r);

                        return(new HttpStringResult("ok"));
                    }

                    return(new HttpStringResult(GenerateReportString()));
                });

                noAuth.AddAction("/reset", WebMethodBits.GET | WebMethodBits.HEAD, async(ctx) =>
                {
                    await Task.CompletedTask;
                    this.Reset();

                    return(new HttpStringResult(GenerateReportString()));
                });

                noAuth.AddAction("/", WebMethodBits.POST, async(ctx) =>
                {
                    await Task.CompletedTask;
                    var hostname = ctx.QueryString._GetStrFirst("hostname");

                    if (hostname._IsFilled())
                    {
                        ReportedItem r = new ReportedItem(DateTimeOffset.Now, hostname, ctx.ClientIpAddress.ToString(), await ctx.Request._RecvStringContentsAsync(CoresConfig.StressMonServer.MaxBodySize, cancel: ctx.Cancel));

                        this.AddReport(r);

                        return(new HttpStringResult("ok"));
                    }

                    return(new HttpStringResult("error"));
                });
            }
            catch
            {
                this._DisposeSafe();
                throw;
            }
        }
コード例 #2
0
 protected override void InitActionListImpl(CgiActionList noAuth, CgiActionList reqAuth)
 {
     try
     {
         noAuth.AddAction("{*path}", WebMethodBits.GET | WebMethodBits.HEAD, async(ctx) =>
         {
             return(new HttpStringResult((await Host.GetResponseAsync(ctx, ctx.Cancel))._NormalizeCrlf(CrlfStyle.Lf), contentType: Consts.MimeTypes.Text));
         });
     }
     catch
     {
         this._DisposeSafe();
         throw;
     }
 }
コード例 #3
0
ファイル: SnmpWork.cs プロジェクト: IPA-CyberLab/IPA-DN-Cores
 protected override void InitActionListImpl(CgiActionList noAuth, CgiActionList reqAuth)
 {
     try
     {
         noAuth.AddAction("/", WebMethodBits.GET | WebMethodBits.HEAD, async(ctx) =>
         {
             await Task.CompletedTask;
             var method = ctx.QueryString._GetStrFirst("method")._ParseEnum(SnmpWorkGetMethod.Get);
             return(new HttpStringResult(Host.GetSnmpBody(method, ctx.QueryString._GetStrFirst("oid"), ctx.QueryString._GetStrFirst("retnone")._ToBool())._NormalizeCrlf(CrlfStyle.Lf, true)));
         });
     }
     catch
     {
         this._DisposeSafe();
         throw;
     }
 }
コード例 #4
0
        protected override void InitActionListImpl(CgiActionList noAuth, CgiActionList reqAuth)
        {
            try
            {
                noAuth.AddAction("/", WebMethodBits.GET | WebMethodBits.HEAD, async(ctx) =>
                {
                    await Task.CompletedTask;

                    string password = ctx.QueryString.ToString();

                    if (password._IsEmpty())
                    {
                        return(new HttpStringResult("Hello"));
                    }
                    else
                    {
                        PublishConfigData data = new PublishConfigData
                        {
                            Username = "******",
                            Password = Secure.SaltPassword(password),
                        };

                        return(new HttpStringResult(data._ObjectToJson(), Consts.MimeTypes.Json));
                    }
                });

                noAuth.AddAction("/hook", WebMethodBits.GET | WebMethodBits.HEAD | WebMethodBits.POST, async(ctx) =>
                {
                    await Task.CompletedTask;
                    this.App.HookFiredTick = TickNow;
                    return(new HttpStringResult("OK"));
                });
            }
            catch
            {
                this._DisposeSafe();
                throw;
            }
        }
コード例 #5
0
 protected override void InitActionListImpl(CgiActionList noAuth, CgiActionList reqAuth)
 {
 }
コード例 #6
0
ファイル: Cgi.cs プロジェクト: IPA-CyberLab/IPA-DN-Cores
 protected abstract void InitActionListImpl(CgiActionList noAuth, CgiActionList reqAuth);