From c546b9fc7d636651950307eab435dce57d67b966 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Tue, 9 Nov 2021 15:36:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A5=97=E9=A4=90=E6=97=A5?= =?UTF-8?q?=E6=9C=9F=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/http_request.go | 7 +++++++ internal/nodes/http_request_plan_expires.go | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 internal/nodes/http_request_plan_expires.go diff --git a/internal/nodes/http_request.go b/internal/nodes/http_request.go index a778370..9d3a6b7 100644 --- a/internal/nodes/http_request.go +++ b/internal/nodes/http_request.go @@ -137,6 +137,13 @@ func (this *HTTPRequest) Do() { } } + // 套餐 + if this.Server.UserPlan != nil && !this.Server.UserPlan.IsAvailable() { + this.doPlanExpires() + this.doEnd() + return + } + // 带宽限制 if this.Server.BandwidthLimit != nil && this.Server.BandwidthLimit.IsOn && !this.Server.BandwidthLimit.IsEmpty() && this.Server.BandwidthLimitStatus != nil && this.Server.BandwidthLimitStatus.IsValid() { this.doBandwidthLimit() diff --git a/internal/nodes/http_request_plan_expires.go b/internal/nodes/http_request_plan_expires.go new file mode 100644 index 0000000..622dd22 --- /dev/null +++ b/internal/nodes/http_request_plan_expires.go @@ -0,0 +1,19 @@ +// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved. + +package nodes + +import ( + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" + "net/http" +) + +// 带宽限制 +func (this *HTTPRequest) doPlanExpires() { + this.tags = append(this.tags, "plan") + + var statusCode = http.StatusNotFound + this.processResponseHeaders(statusCode) + + this.writer.WriteHeader(statusCode) + _, _ = this.writer.WriteString(serverconfigs.DefaultPlanExpireNoticePageBody) +}