This commit is contained in:
WJQSERVER 2024-10-16 12:48:02 +08:00
parent ac859c39a6
commit 2187514da7
5 changed files with 28 additions and 7 deletions

View file

@ -1,5 +1,12 @@
# 更新日志
24w17b
---
- PRE-RELEASE: 此版本是v1.5.2的预发布版本,请勿在生产环境中使用
- FIX: 修正flag传入问题
- CHANGE: 去除/路径重定向,改为返回403,并记录对应请求日志
- CHANGE: 优化Proxy模块的日志记录,记录请求详细信息
24w17a
---
- PRE-RELEASE: 此版本是v1.5.2的预发布版本,请勿在生产环境中使用

View file

@ -63,7 +63,12 @@ wget -O /root/data/ghproxy/ghproxy https://github.com/WJQSERVER-STUDIO/ghproxy/r
chmod +x /root/data/ghproxy/ghproxy
# 下载配置文件
wget -O /root/data/ghproxy/config/config.toml https://raw.githubusercontent.com/WJQSERVER-STUDIO/ghproxy/main/deploy/config.toml
if [ -f /root/data/ghproxy/config/config.toml ]; then
echo "配置文件已存在, 跳过下载"
else
wget -O /root/data/ghproxy/config/config.toml https://raw.githubusercontent.com/WJQSERVER-STUDIO/ghproxy/main/config.toml
fi
# 替换 port = 8080
sed -i "s/port = 8080/port = $PORT/g" /root/data/ghproxy/config/config.toml

View file

@ -63,7 +63,12 @@ wget -O /root/data/ghproxy/ghproxy https://github.com/WJQSERVER-STUDIO/ghproxy/r
chmod +x /root/data/ghproxy/ghproxy
# 下载配置文件
wget -O /root/data/ghproxy/config/config.toml https://raw.githubusercontent.com/WJQSERVER-STUDIO/ghproxy/main/deploy/config.toml
if [ -f /root/data/ghproxy/config/config.toml ]; then
echo "配置文件已存在, 跳过下载"
else
wget -O /root/data/ghproxy/config/config.toml https://raw.githubusercontent.com/WJQSERVER-STUDIO/ghproxy/main/config.toml
fi
# 替换 port = 8080
sed -i "s/port = 8080/port = $PORT/g" /root/data/ghproxy/config/config.toml

11
main.go
View file

@ -41,6 +41,7 @@ func loadConfig() {
if err != nil {
log.Fatalf("Failed to load config: %v", err)
}
fmt.Println("Config File Path: ", cfgfile)
fmt.Printf("Loaded config: %v\n", cfg)
}
@ -51,7 +52,8 @@ func setupLogger(cfg *config.Config) {
if err != nil {
log.Fatalf("Failed to initialize logger: %v", err)
}
logInfo("Logger initialized")
logInfo("Config File Path: ", cfgfile)
logInfo("Loaded config: %v\n", cfg)
logInfo("Init Completed")
}
@ -71,8 +73,6 @@ func init() {
setupLogger(cfg)
Loadlist(cfg)
fmt.Println("Config File Path: ", cfgfile)
// 设置 Gin 模式
gin.SetMode(gin.ReleaseMode)
@ -83,7 +83,10 @@ func init() {
// 定义路由
router.GET("/", func(c *gin.Context) {
c.Redirect(http.StatusMovedPermanently, "https://ghproxy0rtt.1888866.xyz/")
// 返回403错误
c.String(http.StatusForbidden, "403 Forbidden This route is not allowed to access.")
// 记录访问者IP UA METHOD
LogWarning("Forbidden: IP:%s UA:%s METHOD:%s", c.ClientIP(), c.Request.UserAgent(), c.Request.Method)
})
// 未匹配路由处理

View file

@ -117,7 +117,8 @@ func NoRouteHandler(cfg *config.Config) gin.HandlerFunc {
func ProxyRequest(c *gin.Context, u string, cfg *config.Config, mode string) {
method := c.Request.Method
logInfo("%s %s", method, u)
// 记录 IP Method URL UA
logInfo("%s %s %s %s", c.ClientIP(), method, u, c.Request.Header.Get("User-Agent"))
client := createHTTPClient(mode)