mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-02 22:10:25 +08:00
特殊页面支持请求变量
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
<h3>403 Forbidden</h3>
|
||||
<p>Sorry, your access to the page has been denied. Please try again later.</p>
|
||||
|
||||
<footer>Powered by TeaEdge.</footer>
|
||||
<footer>Powered by GoEdge.</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -9,7 +9,7 @@
|
||||
<h3>404 Not Found</h3>
|
||||
<p>Sorry, the page you are looking for is not found. Please try again later.</p>
|
||||
|
||||
<footer>Powered by TeaEdge.</footer>
|
||||
<footer>Powered by GoEdge.</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -9,7 +9,7 @@
|
||||
<h3>An error occurred.</h3>
|
||||
<p>Sorry, the page you are looking for is currently unavailable. Please try again later.</p>
|
||||
|
||||
<footer>Powered by TeaEdge.</footer>
|
||||
<footer>Powered by GoEdge.</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -9,7 +9,7 @@
|
||||
<h3>The website is shutdown.</h3>
|
||||
<p>Sorry, the page you are looking for is currently unavailable. Please try again later.</p>
|
||||
|
||||
<footer>Powered by TeaEdge.</footer>
|
||||
<footer>Powered by GoEdge.</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -9,7 +9,7 @@
|
||||
<h3>网站升级中</h3>
|
||||
<p>为了给您提供更好的服务,我们正在升级网站,请稍后重新访问。</p>
|
||||
|
||||
<footer>Powered by TeaEdge.</footer>
|
||||
<footer>Powered by GoEdge.</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -9,7 +9,7 @@
|
||||
<h3>网站暂时关闭</h3>
|
||||
<p>网站已被暂时关闭,请耐心等待我们的重新开通通知。</p>
|
||||
|
||||
<footer>Powered by TeaEdge.</footer>
|
||||
<footer>Powered by GoEdge.</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -2,9 +2,9 @@ package nodes
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeNode/internal/remotelogs"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/utils"
|
||||
"github.com/iwind/TeaGo/Tea"
|
||||
"github.com/iwind/TeaGo/logs"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"regexp"
|
||||
@@ -48,7 +48,9 @@ func (this *HTTPRequest) doPage(status int) (shouldStop bool) {
|
||||
this.writer.WriteHeader(status)
|
||||
}
|
||||
buf := bytePool1k.Get()
|
||||
_, err = io.CopyBuffer(this.writer, fp, buf)
|
||||
_, err = utils.CopyWithFilter(this.writer, fp, buf, func(p []byte) []byte {
|
||||
return []byte(this.Format(string(p)))
|
||||
})
|
||||
bytePool1k.Put(buf)
|
||||
if err != nil {
|
||||
if !this.canIgnore(err) {
|
||||
|
||||
@@ -2,9 +2,9 @@ package nodes
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeNode/internal/remotelogs"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/utils"
|
||||
"github.com/iwind/TeaGo/Tea"
|
||||
"github.com/iwind/TeaGo/logs"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
@@ -64,7 +64,9 @@ func (this *HTTPRequest) doShutdown() {
|
||||
this.writer.WriteHeader(http.StatusOK)
|
||||
}
|
||||
buf := bytePool1k.Get()
|
||||
_, err = io.CopyBuffer(this.writer, fp, buf)
|
||||
_, err = utils.CopyWithFilter(this.writer, fp, buf, func(p []byte) []byte {
|
||||
return []byte(this.Format(string(p)))
|
||||
})
|
||||
bytePool1k.Put(buf)
|
||||
if err != nil {
|
||||
if !this.canIgnore(err) {
|
||||
|
||||
25
internal/utils/reader_utils.go
Normal file
25
internal/utils/reader_utils.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
|
||||
package utils
|
||||
|
||||
import "io"
|
||||
|
||||
func CopyWithFilter(writer io.Writer, reader io.Reader, buf []byte, filter func(p []byte) []byte) (written int64, err error) {
|
||||
for {
|
||||
n, err := reader.Read(buf)
|
||||
if n > 0 {
|
||||
n2, err := writer.Write(filter(buf[:n]))
|
||||
written += int64(n2)
|
||||
if err != nil {
|
||||
return written, err
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
return written, err
|
||||
}
|
||||
}
|
||||
return written, nil
|
||||
}
|
||||
Reference in New Issue
Block a user