Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6193a07837 | ||
|
|
bb2f7bcda6 | ||
|
|
4ec36da9b5 | ||
|
|
83a1211067 | ||
|
|
367038a4b5 |
3
.gitattributes
vendored
3
.gitattributes
vendored
@@ -1 +1,2 @@
|
||||
* text=auto eol=lf
|
||||
* text=auto eol=lf
|
||||
*.html linguist-vendored
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
.idea
|
||||
.vscode
|
||||
.DS_Store
|
||||
hubproxy*
|
||||
hubproxy*
|
||||
!hubproxy.service
|
||||
@@ -122,6 +122,12 @@ func proxyGitHubWithRedirect(c *gin.Context, u string, redirectCount int) {
|
||||
}
|
||||
}()
|
||||
|
||||
// 如果Github上游404,则返回错误信息
|
||||
if resp.StatusCode == http.StatusNotFound {
|
||||
c.String(http.StatusForbidden, "无效的GitHub地址")
|
||||
return
|
||||
}
|
||||
|
||||
// 检查文件大小限制
|
||||
cfg := config.GetConfig()
|
||||
if contentLength := resp.Header.Get("Content-Length"); contentLength != "" {
|
||||
|
||||
@@ -116,16 +116,17 @@ func main() {
|
||||
router.NoRoute(handlers.GitHubProxyHandler)
|
||||
|
||||
cfg := config.GetConfig()
|
||||
fmt.Printf("🚀 HubProxy 启动成功\n")
|
||||
fmt.Printf("📡 监听地址: %s:%d\n", cfg.Server.Host, cfg.Server.Port)
|
||||
fmt.Printf("⚡ 限流配置: %d请求/%g小时\n", cfg.RateLimit.RequestLimit, cfg.RateLimit.PeriodHours)
|
||||
fmt.Printf("HubProxy 启动成功\n")
|
||||
fmt.Printf("监听地址: %s:%d\n", cfg.Server.Host, cfg.Server.Port)
|
||||
fmt.Printf("限流配置: %d请求/%g小时\n", cfg.RateLimit.RequestLimit, cfg.RateLimit.PeriodHours)
|
||||
|
||||
// 显示HTTP/2支持状态
|
||||
if cfg.Server.EnableH2C {
|
||||
fmt.Printf("H2c: 已启用\n")
|
||||
}
|
||||
|
||||
fmt.Printf("🔗 项目地址: https://github.com/sky22333/hubproxy\n")
|
||||
fmt.Printf("版本号: v1.1.6\n")
|
||||
fmt.Printf("项目地址: https://github.com/sky22333/hubproxy\n")
|
||||
|
||||
// 创建HTTP2服务器
|
||||
server := &http.Server{
|
||||
|
||||
@@ -71,9 +71,6 @@ func InitGlobalLimiter() *IPRateLimiter {
|
||||
ratePerSecond := rate.Limit(float64(cfg.RateLimit.RequestLimit) / (cfg.RateLimit.PeriodHours * 3600))
|
||||
|
||||
burstSize := cfg.RateLimit.RequestLimit
|
||||
if burstSize < 1 {
|
||||
burstSize = 1
|
||||
}
|
||||
|
||||
limiter := &IPRateLimiter{
|
||||
ips: make(map[string]*rateLimiterEntry),
|
||||
|
||||
Reference in New Issue
Block a user