2021-10-21 17:09:51 +08:00
|
|
|
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
|
|
|
|
|
|
|
|
|
package nodes
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
|
|
|
|
)
|
|
|
|
|
|
2021-11-09 17:36:49 +08:00
|
|
|
// 流量限制
|
|
|
|
|
func (this *HTTPRequest) doTrafficLimit() {
|
2022-01-01 20:15:39 +08:00
|
|
|
var config = this.ReqServer.TrafficLimit
|
2021-10-21 17:09:51 +08:00
|
|
|
|
|
|
|
|
this.tags = append(this.tags, "bandwidth")
|
|
|
|
|
|
|
|
|
|
var statusCode = 509
|
|
|
|
|
this.processResponseHeaders(statusCode)
|
|
|
|
|
|
|
|
|
|
this.writer.WriteHeader(statusCode)
|
|
|
|
|
if len(config.NoticePageBody) != 0 {
|
2021-12-02 14:46:40 +08:00
|
|
|
_, _ = this.writer.WriteString(this.Format(config.NoticePageBody))
|
2021-10-21 17:09:51 +08:00
|
|
|
} else {
|
2021-12-02 14:46:40 +08:00
|
|
|
_, _ = this.writer.WriteString(this.Format(serverconfigs.DefaultTrafficLimitNoticePageBody))
|
2021-10-21 17:09:51 +08:00
|
|
|
}
|
|
|
|
|
}
|