private void UpdateTunnelStatus(TunnelStatus status) { switch (status) { case TunnelStatus.Unknown: simpStatusLbl.Text = "未知"; simpStatusLbl.ForeColor = Color.Gray; simpStartBtn.Enabled = false; simpStopBtn.Enabled = false; break; case TunnelStatus.Downloading: simpStatusLbl.Text = "下载客户端..."; simpStatusLbl.ForeColor = Color.CornflowerBlue; simpStartBtn.Enabled = false; simpStopBtn.Enabled = false; break; case TunnelStatus.Launching: simpStatusLbl.Text = "启动中..."; simpStatusLbl.ForeColor = Color.CornflowerBlue; simpStartBtn.Enabled = false; simpStopBtn.Enabled = false; break; case TunnelStatus.Active: simpStatusLbl.Text = "运行中"; simpStatusLbl.ForeColor = Color.ForestGreen; simpStartBtn.Enabled = false; simpStopBtn.Enabled = true; break; case TunnelStatus.Inactive: simpStatusLbl.Text = "停止"; simpStatusLbl.ForeColor = Color.Gray; simpStartBtn.Enabled = true; simpStopBtn.Enabled = false; break; case TunnelStatus.Error: simpStatusLbl.Text = "出现错误"; simpStatusLbl.ForeColor = Color.DarkRed; simpStartBtn.Enabled = true; simpStopBtn.Enabled = false; break; } }
private void UpdateTunnelStatus(TunnelStatus status) { switch (status) { case TunnelStatus.Unknown: simpStatusLbl.Text = "Unknown"; simpStatusLbl.ForeColor = Color.Gray; simpStartBtn.Enabled = false; simpStopBtn.Enabled = false; break; case TunnelStatus.Downloading: simpStatusLbl.Text = "Downloading client..."; simpStatusLbl.ForeColor = Color.CornflowerBlue; simpStartBtn.Enabled = false; simpStopBtn.Enabled = false; break; case TunnelStatus.Launching: simpStatusLbl.Text = "Launching..."; simpStatusLbl.ForeColor = Color.CornflowerBlue; simpStartBtn.Enabled = false; simpStopBtn.Enabled = false; break; case TunnelStatus.Active: simpStatusLbl.Text = "Active"; simpStatusLbl.ForeColor = Color.ForestGreen; simpStartBtn.Enabled = false; simpStopBtn.Enabled = true; break; case TunnelStatus.Inactive: simpStatusLbl.Text = "Inactive"; simpStatusLbl.ForeColor = Color.Gray; simpStartBtn.Enabled = true; simpStopBtn.Enabled = false; break; case TunnelStatus.Error: simpStatusLbl.Text = "Error"; simpStatusLbl.ForeColor = Color.DarkRed; simpStartBtn.Enabled = true; simpStopBtn.Enabled = false; break; } }
public async Task InvokeAsync(HttpContext context, IConfiguration configuration) { if (context.Request.Headers.ContainsKey(TunnelIsAliveHeader)) { context.Response.StatusCode = StatusCodes.Status200OK; var status = new TunnelStatus { Mode = this.mode, Runtime = StatusMiddleware.Runtime, ForwardConfiguration = configuration.GetForwardConfiguration(), BackwardConfiguration = configuration.GetBackwardConfiguration(), }; context.Response.ContentType = "application/json"; await context.Response.WriteAsync(JsonSerializer.Serialize(status, this.jsonSerializerOptions)); await context.Response.CompleteAsync(); } else { await this.next(context); } }