From 6e787ced6e44b01aba79bb6661357368a5a5981b Mon Sep 17 00:00:00 2001
From: WJQSERVER <114663932+WJQSERVER@users.noreply.github.com>
Date: Sun, 26 Jan 2025 16:24:37 +0800
Subject: [PATCH 001/273] 2.0.4 (#39)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- RELEASE: v2.0.4正式版发布;
- CHANGE: 优化GitReq的`HTTP Client`参数, 使其更符合本项目使用场景
- CHANGE: 优化Matches
- REMOVE: 移除Caddyfile残留
- REMOVE: 由于v2改进后稳定性增强, 故移除健康检测
---
CHANGELOG.md | 20 ++++++
DEV-VERSION | 2 +-
README.md | 1 +
VERSION | 2 +-
caddyfile/dev/Caddyfile | 102 -----------------------------
caddyfile/nocache/Caddyfile | 99 ----------------------------
caddyfile/release/Caddyfile | 103 ------------------------------
docker/dockerfile/dev/init.sh | 10 +--
docker/dockerfile/release/init.sh | 10 +--
init.sh | 9 +--
main.go | 6 +-
proxy/chunkreq.go | 17 ++---
proxy/gitreq.go | 23 ++++++-
proxy/matchrepo.go | 16 +++--
14 files changed, 67 insertions(+), 353 deletions(-)
delete mode 100644 caddyfile/dev/Caddyfile
delete mode 100644 caddyfile/nocache/Caddyfile
delete mode 100644 caddyfile/release/Caddyfile
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b0e8403..7d1abbb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,25 @@
# 更新日志
+2.0.4
+---
+- RELEASE: v2.0.4正式版发布;
+- CHANGE: 优化GitReq的`HTTP Client`参数, 使其更符合本项目使用场景
+- CHANGE: 优化Matches
+- REMOVE: 移除Caddyfile残留
+- REMOVE: 由于v2改进后稳定性增强, 故移除健康检测
+
+25w08b
+---
+- PRE-RELEASE: 此版本是v2.0.4的预发布版本,请勿在生产环境中使用;
+- REMOVE: 由于v2改进后稳定性增强, 故移除健康检测
+
+25w08a
+---
+- PRE-RELEASE: 此版本是v2.0.4的预发布版本,请勿在生产环境中使用;
+- CHANGE: 优化GitReq的`HTTP Client`参数, 使其更符合本项目使用场景
+- CHANGE: 优化Matches
+- REMOVE: 移除Caddyfile残留
+
2.0.3
---
- RELEASE: v2.0.3正式版发布;
diff --git a/DEV-VERSION b/DEV-VERSION
index c721171..bf16ee9 100644
--- a/DEV-VERSION
+++ b/DEV-VERSION
@@ -1 +1 @@
-25w07b
\ No newline at end of file
+25w08b
\ No newline at end of file
diff --git a/README.md b/README.md
index 77796fd..29aff6b 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
# GHProxy

+
[](https://goreportcard.com/report/github.com/WJQSERVER-STUDIO/ghproxy)
使用Go实现的GHProxy,用于加速部分地区Github仓库的拉取,支持速率限制,用户鉴权,支持Docker部署
diff --git a/VERSION b/VERSION
index 6acdb44..26e3379 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.0.3
\ No newline at end of file
+2.0.4
\ No newline at end of file
diff --git a/caddyfile/dev/Caddyfile b/caddyfile/dev/Caddyfile
deleted file mode 100644
index cd58447..0000000
--- a/caddyfile/dev/Caddyfile
+++ /dev/null
@@ -1,102 +0,0 @@
-{
- debug
- http_port 80
- https_port 443
- order cache before rewrite
- cache {
- cache_name GHProxyCache
- }
- log {
- level INFO
- output file /data/caddy/log/caddy.log {
- roll_size 5MB
- roll_keep 10
- }
- }
- servers :80 {
- protocols h1 h2c
- }
-}
-
-(log) {
- log {
- format transform `{request>headers>X-Forwarded-For>[0]:request>remote_ip} - {user_id} [{ts}] "{request>method} {request>uri} {request>proto}" {status} {size} "{request>headers>Referer>[0]}" "{request>headers>User-Agent>[0]}"` {
- time_format "02/Jan/2006:15:04:05 -0700"
- }
- output file /data/caddy/log/{args[0]}/access.log {
- roll_size 5MB
- roll_keep 10
- roll_keep_for 24h
- }
- }
-}
-
-(error_page) {
- handle_errors {
- rewrite * /{err.status_code}.html
- root * /data/caddy/pages/errors
- file_server
- }
-}
-
-(encode) {
- encode {
- zstd best
- br 5 v2
- gzip 5
- minimum_length 512
- }
-}
-
-(cache) {
- cache {
- allowed_http_verbs GET
- stale {args[0]}
- ttl {args[1]}
- }
-}
-
-(header_realip) {
- header_up X-Real-IP {remote_host}
- header_up X-Real-IP {http.request.header.CF-Connecting-IP}
- header_up X-Forwarded-For {http.request.header.CF-Connecting-IP}
- header_up X-Forwarded-Proto {http.request.header.CF-Visitor}
-}
-
-(rate_limit) {
- route /* {
- rate_limit {remote.ip} {args[0]}r/m 10000 429
- }
-}
-
-:80 {
- reverse_proxy {
- to 127.0.0.1:8080
- import header_realip
- transport http {
- versions 1.1 h2c
- }
- }
- import log ghproxy
- import cache 0s 300s
- import error_page
- import encode
- import rate_limit 60
- route / {
- root /data/www
- file_server
- import cache 0s 24h
- }
- route /favicon.ico {
- root /data/www
- file_server
- import cache 0s 24h
- }
-
- route /api* {
- rate_limit {remote.ip} 15r/m 10000 429
- import cache 0s 6h
- }
-}
-
-import /data/caddy/config.d/*
diff --git a/caddyfile/nocache/Caddyfile b/caddyfile/nocache/Caddyfile
deleted file mode 100644
index b63e936..0000000
--- a/caddyfile/nocache/Caddyfile
+++ /dev/null
@@ -1,99 +0,0 @@
-{
- debug
- http_port 80
- https_port 443
- order cache before rewrite
- cache {
- cache_name GHProxyCache
- }
- log {
- level INFO
- output file /data/caddy/log/caddy.log {
- roll_size 5MB
- roll_keep 10
- }
- }
- servers :80 {
- protocols h1 h2c
- }
-}
-
-
-(log) {
- log {
- format transform `{request>headers>X-Forwarded-For>[0]:request>remote_ip} - {user_id} [{ts}] "{request>method} {request>uri} {request>proto}" {status} {size} "{request>headers>Referer>[0]}" "{request>headers>User-Agent>[0]}"` {
- time_format "02/Jan/2006:15:04:05 -0700"
- }
- output file /data/caddy/log/{args[0]}/access.log {
- roll_size 5MB
- roll_keep 10
- roll_keep_for 24h
- }
- }
-}
-
-(error_page) {
- handle_errors {
- rewrite * /{err.status_code}.html
- root * /data/caddy/pages/errors
- file_server
- }
-}
-
-(encode) {
- encode {
- zstd best
- br 5 v2
- gzip 5
- minimum_length 256
- }
-}
-
-(cache) {
- cache {
- allowed_http_verbs GET
- stale {args[0]}
- ttl {args[1]}
- }
-}
-
-(header_realip) {
- header_up X-Real-IP {remote_host}
- header_up X-Real-IP {http.request.header.CF-Connecting-IP}
- header_up X-Forwarded-For {http.request.header.CF-Connecting-IP}
- header_up X-Forwarded-Proto {http.request.header.CF-Visitor}
-}
-
-(rate_limit) {
- route /* {
- rate_limit {remote.ip} {args[0]}r/m 10000 429
- }
-}
-
-:80 {
- reverse_proxy {
- to h2c://127.0.0.1:8080
- import header_realip
- }
- import log ghproxy
- import error_page
- import encode
- import rate_limit 60
- route / {
- root /data/www
- file_server
- import cache 300s
- }
- route /favicon.ico {
- root /data/www
- file_server
- import cache 300s
- }
-
- route /api* {
- rate_limit {remote.ip} 15r/m 10000 429
- import cache 300s
- }
-}
-
-import /data/caddy/config.d/*
diff --git a/caddyfile/release/Caddyfile b/caddyfile/release/Caddyfile
deleted file mode 100644
index 962fa39..0000000
--- a/caddyfile/release/Caddyfile
+++ /dev/null
@@ -1,103 +0,0 @@
-{
- debug
- http_port 80
- https_port 443
- order cache before rewrite
- cache {
- cache_name GHProxyCache
- }
- log {
- level INFO
- output file /data/caddy/log/caddy.log {
- roll_size 5MB
- roll_keep 10
- }
- }
- servers :80 {
- protocols h1 h2c
- }
-}
-
-(log) {
- log {
- format transform `{request>headers>X-Forwarded-For>[0]:request>remote_ip} - {user_id} [{ts}] "{request>method} {request>uri} {request>proto}" {status} {size} "{request>headers>Referer>[0]}" "{request>headers>User-Agent>[0]}"` {
- time_format "02/Jan/2006:15:04:05 -0700"
- }
- output file /data/caddy/log/{args[0]}/access.log {
- roll_size 5MB
- roll_keep 10
- roll_keep_for 24h
- }
- }
-}
-
-(error_page) {
- handle_errors {
- rewrite * /{err.status_code}.html
- root * /data/caddy/pages/errors
- file_server
- }
-}
-
-(encode) {
- encode {
- zstd best
- br 5 v2
- gzip 5
- minimum_length 512
- }
-}
-
-(cache) {
- cache {
- allowed_http_verbs GET
- stale {args[0]}
- ttl {args[1]}
- }
-}
-
-(header_realip) {
- header_up X-Real-IP {remote_host}
- header_up X-Real-IP {http.request.header.CF-Connecting-IP}
- header_up X-Forwarded-For {http.request.header.CF-Connecting-IP}
- header_up X-Forwarded-Proto {http.request.header.CF-Visitor}
-}
-
-(rate_limit) {
- route /* {
- rate_limit {remote.ip} {args[0]}r/m 10000 429
- }
-}
-
-:80 {
- reverse_proxy {
- to 127.0.0.1:8080
- import header_realip
- transport http {
- versions 1.1 h2c
- }
- }
- import log ghproxy
- import cache 0s 300s
- import error_page
- import encode
- import rate_limit 60
- route / {
- root /data/www
- file_server
- import cache 0s 24h
- }
- route /favicon.ico {
- root /data/www
- file_server
- import cache 0s 24h
-
- }
-
- route /api* {
- rate_limit {remote.ip} 15r/m 10000 429
- import cache 0s 6h
- }
-}
-
-import /data/caddy/config.d/*
diff --git a/docker/dockerfile/dev/init.sh b/docker/dockerfile/dev/init.sh
index 21c150a..f9a10e7 100644
--- a/docker/dockerfile/dev/init.sh
+++ b/docker/dockerfile/dev/init.sh
@@ -14,12 +14,4 @@ if [ ! -f /data/${APPLICATION}/config/config.toml ]; then
cp /data/${APPLICATION}/config.toml /data/${APPLICATION}/config/config.toml
fi
-/data/${APPLICATION}/${APPLICATION} -cfg /data/${APPLICATION}/config/config.toml > /data/${APPLICATION}/log/run.log 2>&1 &
-
-sleep 30
-
-while [[ true ]]; do
- # Failure Circuit Breaker
- curl -f --max-time 5 -retry 3 http://127.0.0.1:8080/api/healthcheck || exit 1
- sleep 120
-done
\ No newline at end of file
+/data/${APPLICATION}/${APPLICATION} -cfg /data/${APPLICATION}/config/config.toml > /data/${APPLICATION}/log/run.log 2>&1
diff --git a/docker/dockerfile/release/init.sh b/docker/dockerfile/release/init.sh
index 0555c6f..f9a10e7 100644
--- a/docker/dockerfile/release/init.sh
+++ b/docker/dockerfile/release/init.sh
@@ -14,12 +14,4 @@ if [ ! -f /data/${APPLICATION}/config/config.toml ]; then
cp /data/${APPLICATION}/config.toml /data/${APPLICATION}/config/config.toml
fi
-/data/${APPLICATION}/${APPLICATION} -cfg /data/${APPLICATION}/config/config.toml > /data/${APPLICATION}/log/run.log 2>&1 &
-
-sleep 30
-
-while [[ true ]]; do
- # Failure Circuit Breaker
- curl -f --max-time 5 -retry 3 http://127.0.0.1:8080/api/healthcheck || exit 1
- sleep 120
-done
\ No newline at end of file
+/data/${APPLICATION}/${APPLICATION} -cfg /data/${APPLICATION}/config/config.toml > /data/${APPLICATION}/log/run.log 2>&1
diff --git a/init.sh b/init.sh
index 70da645..601185f 100644
--- a/init.sh
+++ b/init.sh
@@ -14,12 +14,5 @@ if [ ! -f /data/${APPLICATON}/config/config.yaml ]; then
cp /data/${APPLICATON}/config.yaml /data/${APPLICATON}/config/config.yaml
fi
-/data/${APPLICATON}/${APPLICATON} > /data/${APPLICATON}/log/run.log 2>&1 &
-
-sleep 30
-
-while [[ true ]]; do
- curl -f http://localhost:8080/api/healthcheck || exit 1
- sleep 120
-done
+/data/${APPLICATON}/${APPLICATON} > /data/${APPLICATON}/log/run.log 2>&1
diff --git a/main.go b/main.go
index 4cd1968..d7e5c6d 100644
--- a/main.go
+++ b/main.go
@@ -91,8 +91,8 @@ func setupRateLimit(cfg *config.Config) {
}
}
-func InitChunkedReq() {
- proxy.InitChunkedReq(cfg.Server.BufferSize)
+func InitReq() {
+ proxy.InitReq(cfg.Server.BufferSize)
}
func init() {
@@ -100,7 +100,7 @@ func init() {
flag.Parse()
loadConfig()
setupLogger(cfg)
- InitChunkedReq()
+ InitReq()
loadlist(cfg)
setupRateLimit(cfg)
diff --git a/proxy/chunkreq.go b/proxy/chunkreq.go
index e94f5ec..02893b9 100644
--- a/proxy/chunkreq.go
+++ b/proxy/chunkreq.go
@@ -14,13 +14,14 @@ import (
var chunkedBufferSize int
var (
- client *http.Client
- tr *http.Transport
+ cclient *http.Client
+ ctr *http.Transport
)
-func InitChunkedReq(cfgBufferSize int) {
+func InitReq(cfgBufferSize int) {
initChunkedBufferSize(cfgBufferSize)
initChunkedHTTPClient()
+ initGitHTTPClient()
}
func initChunkedBufferSize(cfgBufferSize int) {
@@ -32,13 +33,13 @@ func initChunkedBufferSize(cfgBufferSize int) {
}
func initChunkedHTTPClient() {
- tr = &http.Transport{
+ ctr = &http.Transport{
MaxIdleConns: 100,
MaxConnsPerHost: 60,
IdleConnTimeout: 20 * time.Second,
}
- client = &http.Client{
- Transport: tr,
+ cclient = &http.Client{
+ Transport: ctr,
}
}
@@ -59,7 +60,7 @@ func ChunkedProxyRequest(c *gin.Context, u string, cfg *config.Config, mode stri
removeWSHeader(headReq) // 删除Conection Upgrade头, 避免与HTTP/2冲突(检查是否存在Upgrade头)
AuthPassThrough(c, cfg, headReq)
- headResp, err := client.Do(headReq)
+ headResp, err := cclient.Do(headReq)
if err != nil {
HandleError(c, fmt.Sprintf("Failed to send request: %v", err))
return
@@ -91,7 +92,7 @@ func ChunkedProxyRequest(c *gin.Context, u string, cfg *config.Config, mode stri
removeWSHeader(req) // 删除Conection Upgrade头, 避免与HTTP/2冲突(检查是否存在Upgrade头)
AuthPassThrough(c, cfg, req)
- resp, err := client.Do(req)
+ resp, err := cclient.Do(req)
if err != nil {
HandleError(c, fmt.Sprintf("发送请求失败: %v", err))
return
diff --git a/proxy/gitreq.go b/proxy/gitreq.go
index a429c6c..424951e 100644
--- a/proxy/gitreq.go
+++ b/proxy/gitreq.go
@@ -6,16 +6,33 @@ import (
"ghproxy/config"
"io"
"net/http"
+ "time"
"github.com/gin-gonic/gin"
)
+var (
+ gclient *http.Client
+ gtr *http.Transport
+)
+
+func initGitHTTPClient() {
+ gtr = &http.Transport{
+ MaxIdleConns: 30,
+ MaxConnsPerHost: 30,
+ IdleConnTimeout: 30 * time.Second,
+ }
+ gclient = &http.Client{
+ Transport: gtr,
+ }
+}
+
func GitReq(c *gin.Context, u string, cfg *config.Config, mode string, runMode string) {
method := c.Request.Method
logInfo("%s %s %s %s %s", c.ClientIP(), method, u, c.Request.Header.Get("User-Agent"), c.Request.Proto)
// 创建HTTP客户端
- client := &http.Client{}
+ //client := &http.Client{}
// 发送HEAD请求, 预获取Content-Length
headReq, err := http.NewRequest("HEAD", u, nil)
@@ -26,7 +43,7 @@ func GitReq(c *gin.Context, u string, cfg *config.Config, mode string, runMode s
setRequestHeaders(c, headReq)
AuthPassThrough(c, cfg, headReq)
- headResp, err := client.Do(headReq)
+ headResp, err := gclient.Do(headReq)
if err != nil {
HandleError(c, fmt.Sprintf("Failed to send request: %v", err))
return
@@ -55,7 +72,7 @@ func GitReq(c *gin.Context, u string, cfg *config.Config, mode string, runMode s
setRequestHeaders(c, req)
AuthPassThrough(c, cfg, req)
- resp, err := client.Do(req)
+ resp, err := gclient.Do(req)
if err != nil {
HandleError(c, fmt.Sprintf("Failed to send request: %v", err))
return
diff --git a/proxy/matchrepo.go b/proxy/matchrepo.go
index 58090c7..5a5d000 100644
--- a/proxy/matchrepo.go
+++ b/proxy/matchrepo.go
@@ -9,17 +9,19 @@ import (
"github.com/gin-gonic/gin"
)
+// 预定义regex
+var (
+ pathRegex = regexp.MustCompile(`^([^/]+)/([^/]+)/([^/]+)/.*`) // 匹配路径
+ gistRegex = regexp.MustCompile(`^(?:https?://)?gist\.github(?:usercontent|)\.com/([^/]+)/([^/]+)/.*`) // 匹配gist路径
+)
+
// 提取用户名和仓库名
func MatchUserRepo(rawPath string, cfg *config.Config, c *gin.Context, matches []string) (string, string) {
- var gistregex = regexp.MustCompile(`^(?:https?://)?gist\.github(?:usercontent|)\.com/([^/]+)/([^/]+)/.*`)
- var gistmatches []string
- if gistregex.MatchString(rawPath) {
- gistmatches = gistregex.FindStringSubmatch(rawPath)
- logInfo("%s %s %s %s %s Matched-Username: %s", c.ClientIP(), c.Request.Method, rawPath, c.Request.Header.Get("User-Agent"), c.Request.Proto, gistmatches[1])
- return gistmatches[1], ""
+ if gistMatches := gistRegex.FindStringSubmatch(rawPath); len(gistMatches) == 3 {
+ logInfo("%s %s %s %s %s Matched-Username: %s", c.ClientIP(), c.Request.Method, rawPath, c.Request.Header.Get("User-Agent"), c.Request.Proto, gistMatches[1])
+ return gistMatches[1], ""
}
// 定义路径
- pathRegex := regexp.MustCompile(`^([^/]+)/([^/]+)/([^/]+)/.*`)
if pathMatches := pathRegex.FindStringSubmatch(matches[2]); len(pathMatches) >= 4 {
return pathMatches[2], pathMatches[3]
}
From 5d08993cbc8a8f647b202fadbfad67c90cf579ad Mon Sep 17 00:00:00 2001
From: WJQSERVER <114663932+WJQSERVER@users.noreply.github.com>
Date: Mon, 27 Jan 2025 15:00:19 +0800
Subject: [PATCH 002/273] 2.0.5 (#40)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- RELEASE: v2.0.5正式版发布;
- CHANGE: 优化响应体分块复制实现
- ADD: 加入缓存池
- CHANGE: 改进缓存实现
- CHANGE: 部分杂项改进
---
CHANGELOG.md | 19 ++++++++++++++++
DEV-VERSION | 2 +-
README.md | 1 -
VERSION | 2 +-
config/config.go | 11 +++++----
config/config.toml | 1 -
deploy/config.toml | 1 -
go.mod | 4 ++--
go.sum | 4 ++++
main.go | 2 +-
pages/index.html | 3 +--
proxy/chunkreq.go | 56 +++++++++++++++++-----------------------------
proxy/gitreq.go | 9 ++------
13 files changed, 56 insertions(+), 59 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7d1abbb..c18c1a3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,24 @@
# 更新日志
+2.0.5
+---
+- RELEASE: v2.0.5正式版发布;
+- CHANGE: 优化响应体分块复制实现
+- ADD: 加入缓存池
+- CHANGE: 改进缓存实现
+- CHANGE: 部分杂项改进
+
+25w09b
+---
+- PRE-RELEASE: 此版本是v2.0.5的预发布版本,请勿在生产环境中使用;
+- REMOVE: 移除残留配置
+
+25w09a
+---
+- PRE-RELEASE: 此版本是v2.0.5的预发布版本,请勿在生产环境中使用;
+- CHANGE: 改进缓存实现
+- ADD: 加入缓存池
+
2.0.4
---
- RELEASE: v2.0.4正式版发布;
diff --git a/DEV-VERSION b/DEV-VERSION
index bf16ee9..e0ca1d4 100644
--- a/DEV-VERSION
+++ b/DEV-VERSION
@@ -1 +1 @@
-25w08b
\ No newline at end of file
+25w09b
\ No newline at end of file
diff --git a/README.md b/README.md
index 29aff6b..131a8e4 100644
--- a/README.md
+++ b/README.md
@@ -83,7 +83,6 @@ wget -O install.sh https://raw.githubusercontent.com/WJQSERVER-STUDIO/ghproxy/ma
host = "0.0.0.0" # 监听地址
port = 8080 # 监听端口
sizeLimit = 125 # 125MB
-bufferSize = 4096 # Bytes 缓冲区大小
enableH2C = "on" # 是否开启H2C传输(latest和dev版本请开启) on/off
[pages]
diff --git a/VERSION b/VERSION
index 26e3379..b9d2bdf 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.0.4
\ No newline at end of file
+2.0.5
\ No newline at end of file
diff --git a/config/config.go b/config/config.go
index 0747d62..ea325a4 100644
--- a/config/config.go
+++ b/config/config.go
@@ -16,12 +16,11 @@ type Config struct {
}
type ServerConfig struct {
- Port int `toml:"port"`
- Host string `toml:"host"`
- SizeLimit int `toml:"sizeLimit"`
- EnableH2C string `toml:"enableH2C"`
- BufferSize int `toml:"bufferSize"`
- Debug bool `toml:"debug"`
+ Port int `toml:"port"`
+ Host string `toml:"host"`
+ SizeLimit int `toml:"sizeLimit"`
+ EnableH2C string `toml:"enableH2C"`
+ Debug bool `toml:"debug"`
}
type PagesConfig struct {
diff --git a/config/config.toml b/config/config.toml
index c1995b9..5d1900f 100644
--- a/config/config.toml
+++ b/config/config.toml
@@ -3,7 +3,6 @@ host = "0.0.0.0"
port = 8080
sizeLimit = 125 # MB
enableH2C = "on" # "on" or "off"
-bufferSize = 4096 # Bytes
debug = false
[pages]
diff --git a/deploy/config.toml b/deploy/config.toml
index cc49eff..6053f12 100644
--- a/deploy/config.toml
+++ b/deploy/config.toml
@@ -2,7 +2,6 @@
host = "127.0.0.1"
port = 8080
sizeLimit = 125 # MB
-bufferSize = 4096 # Bytes
enableH2C = false
debug = false
diff --git a/go.mod b/go.mod
index 3244d27..f52b9f7 100644
--- a/go.mod
+++ b/go.mod
@@ -10,7 +10,7 @@ require (
)
require (
- github.com/bytedance/sonic v1.12.7 // indirect
+ github.com/bytedance/sonic v1.12.8 // indirect
github.com/bytedance/sonic/loader v0.2.3 // indirect
github.com/cloudwego/base64x v0.1.5 // indirect
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
@@ -34,6 +34,6 @@ require (
golang.org/x/net v0.34.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/text v0.21.0 // indirect
- google.golang.org/protobuf v1.36.3 // indirect
+ google.golang.org/protobuf v1.36.4 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
diff --git a/go.sum b/go.sum
index 84d44b3..1a03802 100644
--- a/go.sum
+++ b/go.sum
@@ -4,6 +4,8 @@ github.com/WJQSERVER-STUDIO/go-utils/logger v1.1.1 h1:YS3q54SroxQpEM7c12ZKjLNAaS
github.com/WJQSERVER-STUDIO/go-utils/logger v1.1.1/go.mod h1:oW884JCCPDU6c906LI0uKXndWLiRvjb9LkGYC2cqRO8=
github.com/bytedance/sonic v1.12.7 h1:CQU8pxOy9HToxhndH0Kx/S1qU/CuS9GnKYrGioDcU1Q=
github.com/bytedance/sonic v1.12.7/go.mod h1:tnbal4mxOMju17EGfknm2XyYcpyCnIROYOEYuemj13I=
+github.com/bytedance/sonic v1.12.8 h1:4xYRVRlXIgvSZ4e8iVTlMF5szgpXd4AfvuWgA8I8lgs=
+github.com/bytedance/sonic v1.12.8/go.mod h1:uVvFidNmlt9+wa31S1urfwwthTWteBgG0hWuoKAXTx8=
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
github.com/bytedance/sonic/loader v0.2.3 h1:yctD0Q3v2NOGfSWPLPvG2ggA2kV6TS6s4wioyEqssH0=
github.com/bytedance/sonic/loader v0.2.3/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
@@ -82,6 +84,8 @@ golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY=
golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
google.golang.org/protobuf v1.36.3 h1:82DV7MYdb8anAVi3qge1wSnMDrnKK7ebr+I0hHRN1BU=
google.golang.org/protobuf v1.36.3/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
+google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM=
+google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/main.go b/main.go
index d7e5c6d..36be801 100644
--- a/main.go
+++ b/main.go
@@ -92,7 +92,7 @@ func setupRateLimit(cfg *config.Config) {
}
func InitReq() {
- proxy.InitReq(cfg.Server.BufferSize)
+ proxy.InitReq()
}
func init() {
diff --git a/pages/index.html b/pages/index.html
index e2e81cc..bffeb0a 100644
--- a/pages/index.html
+++ b/pages/index.html
@@ -8,7 +8,6 @@
-
-
-
-
-
-
Github文件加速
-
为访问Github文件进行加速
-
-
-
-
-
-
-
GitHub 链接带不带协议头均可,支持 release、archive 以及文件,转换后链接均可使用。
+
+
+
+ GitHub 文件加速服务
+ 高速稳定的 GitHub 资源访问解决方案
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
文件大小限制
+ 最大支持文件尺寸
+
...
-
-
-
+
+
-
-
-
+
+
+
+
+
黑名单状态
+ 屏蔽列表状态
+
+
...
+
+
+
+
+
+
+
+
📚 详细使用指南
+
+
+
支持的工具
+
+ - ✅ 终端工具:Git / Wget / Curl
+ - ✅ 支持域名:github.com
+ - ✅ 支持域名:raw.githubusercontent.com
+ - ✅ 支持域名:gist.githubusercontent.com
+ - ❌ 不支持 SSH 协议克隆
+
+
+
+
+
基础用法示例
+
+
+
Git 克隆
+ git clone https://example.com/https://github.com/user/project.git
+
+ 私有仓库克隆
+ git clone https://user:your_token@example.com/https://github.com/user/project.git
+
+
+
+
文件下载
+ wget https://example.com/https://raw.githubusercontent.com/user/project/main/README.md
+
+ 版本发布
+ curl -LO https://example.com/https://github.com/user/project/releases/download/v1.0.0./project_1.0.0.amd64.tar.gz
+
+
+
+
+
支持的文件类型
+
+
+
+
+
原始文件
+ https://raw.githubusercontent.com/user/repo/main/file.txt
+
+
+
+
+
+
分支源码
+ https://github.com/user/repo/archive/main.zip
+
+
+
+
+
+
版本发布
+ https://github.com/user/repo/releases/download/v1.0.0/app.zip
+
+
+
+
+
+
Gist 文件
+ https://gist.githubusercontent.com/user/gist_id/raw/file.txt
-
-
+
+
-