mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 16:21:11 +08:00
1.2.0
This commit is contained in:
parent
8588d66a6c
commit
822c08d4c0
4 changed files with 23 additions and 10 deletions
|
|
@ -1,5 +1,11 @@
|
||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
|
v1.2.0
|
||||||
|
---
|
||||||
|
- CHANGE: 优化代码结构,提升性能
|
||||||
|
- CHANGE: 同步更新logger模块,与golang-temp项目定义的开发规范保持一致
|
||||||
|
- ADD: 新增日志翻转功能
|
||||||
|
|
||||||
24w08a
|
24w08a
|
||||||
---
|
---
|
||||||
- CHANGE: 同步更新logger模块,与golang-temp项目定义的开发规范保持一致
|
- CHANGE: 同步更新logger模块,与golang-temp项目定义的开发规范保持一致
|
||||||
|
|
|
||||||
2
VERSION
2
VERSION
|
|
@ -1 +1 @@
|
||||||
1.1.1
|
1.2.0
|
||||||
10
main.go
10
main.go
|
|
@ -14,10 +14,12 @@ import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cfg *config.Config
|
var (
|
||||||
var logw = logger.Logw
|
cfg *config.Config
|
||||||
var router *gin.Engine
|
logw = logger.Logw
|
||||||
var configfile = "/data/ghproxy/config/config.yaml"
|
router *gin.Engine
|
||||||
|
configfile = "/data/ghproxy/config/config.yaml"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
exps = []*regexp.Regexp{
|
exps = []*regexp.Regexp{
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,7 @@ func SendRequest(req *req.Request, method, url string) (*req.Response, error) {
|
||||||
case "DELETE":
|
case "DELETE":
|
||||||
return req.Delete(url)
|
return req.Delete(url)
|
||||||
default:
|
default:
|
||||||
|
logw("Unsupported method: %s", method)
|
||||||
return nil, fmt.Errorf("unsupported method: %s", method)
|
return nil, fmt.Errorf("unsupported method: %s", method)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -148,9 +149,13 @@ func HandleResponseSize(resp *req.Response, cfg *config.Config, c *gin.Context)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CopyResponseHeaders(resp *req.Response, c *gin.Context, cfg *config.Config) {
|
func CopyResponseHeaders(resp *req.Response, c *gin.Context, cfg *config.Config) {
|
||||||
headersToRemove := []string{"Content-Security-Policy", "Referrer-Policy", "Strict-Transport-Security"}
|
headersToRemove := map[string]struct{}{
|
||||||
|
"Content-Security-Policy": {},
|
||||||
|
"Referrer-Policy": {},
|
||||||
|
"Strict-Transport-Security": {},
|
||||||
|
}
|
||||||
|
|
||||||
for _, header := range headersToRemove {
|
for header := range headersToRemove {
|
||||||
resp.Header.Del(header)
|
resp.Header.Del(header)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -160,10 +165,9 @@ func CopyResponseHeaders(resp *req.Response, c *gin.Context, cfg *config.Config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.Header("Access-Control-Allow-Origin", "")
|
||||||
if cfg.CORSOrigin {
|
if cfg.CORSOrigin {
|
||||||
c.Header("Access-Control-Allow-Origin", "*")
|
c.Header("Access-Control-Allow-Origin", "*")
|
||||||
} else {
|
|
||||||
c.Header("Access-Control-Allow-Origin", "")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -179,6 +183,7 @@ func CheckURL(u string) []string {
|
||||||
return matches[1:]
|
return matches[1:]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logw("Invalid URL: %s", u)
|
errMsg := fmt.Sprintf("Invalid URL: %s", u)
|
||||||
|
logw(errMsg)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue