mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 08:11:11 +08:00
24w18b
This commit is contained in:
parent
d6b8f2b812
commit
52fdaf5f81
5 changed files with 20 additions and 49 deletions
|
|
@ -1,5 +1,11 @@
|
||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
|
24w18b
|
||||||
|
---
|
||||||
|
- PRE-RELEASE: 此版本是预发布版本,请勿在生产环境中使用
|
||||||
|
- CHANGE: 经团队考量,移除 Docker 代理功能,若造成了不便敬请谅解
|
||||||
|
- CHANGE: 修改日志检查周期
|
||||||
|
|
||||||
24w18a
|
24w18a
|
||||||
---
|
---
|
||||||
- PRE-RELEASE: 此版本是预发布版本,请勿在生产环境中使用
|
- PRE-RELEASE: 此版本是预发布版本,请勿在生产环境中使用
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
24w18a
|
24w18b
|
||||||
|
|
@ -88,44 +88,11 @@
|
||||||
file_server
|
file_server
|
||||||
import cache 0s 24h
|
import cache 0s 24h
|
||||||
}
|
}
|
||||||
handle_errors {
|
|
||||||
@redirects `{err.status_code} in [301, 302, 307]`
|
|
||||||
reverse_proxy @redirects {
|
|
||||||
header_up Location {http.response.header.Location}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
route /v2* {
|
route /api* {
|
||||||
reverse_proxy https://registry-1.docker.io {
|
rate_limit 15r/m 10000 429
|
||||||
header_up Host {reverse_proxy.upstream.hostport}
|
import cache 0s 6h
|
||||||
header_up X-Real-IP {remote}
|
}
|
||||||
header_up X-Forwarded-For {http.request.header.X-Forwarded-For}
|
|
||||||
header_up X-Forwarded-Proto {scheme}
|
|
||||||
header_up Authorization {http.request.header.Authorization}
|
|
||||||
header_down WWW-Authenticate "https://auth.docker.io" "https://{host}"
|
|
||||||
header_down Location "https://production.cloudflare.docker.com" "https://{host}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
route /token* {
|
|
||||||
reverse_proxy https://auth.docker.io {
|
|
||||||
header_up Host {reverse_proxy.upstream.hostport}
|
|
||||||
header_up X-Real-IP {remote}
|
|
||||||
header_up X-Forwarded-For {http.request.header.X-Forwarded-For}
|
|
||||||
header_up X-Forwarded-Proto {scheme}
|
|
||||||
header_up Authorization {http.request.header.Authorization}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
route /registry-v2* {
|
|
||||||
reverse_proxy https://production.cloudflare.docker.com {
|
|
||||||
header_up Host {reverse_proxy.upstream.hostport}
|
|
||||||
header_up X-Real-IP {remote}
|
|
||||||
header_up X-Forwarded-For {http.request.header.X-Forwarded-For}
|
|
||||||
header_up X-Forwarded-Proto {scheme}
|
|
||||||
header_up Authorization {http.request.header.Authorization}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
import /data/caddy/config.d/*
|
import /data/caddy/config.d/*
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,11 @@ var (
|
||||||
logger *log.Logger
|
logger *log.Logger
|
||||||
logChannel = make(chan string, 100)
|
logChannel = make(chan string, 100)
|
||||||
quitChannel = make(chan struct{})
|
quitChannel = make(chan struct{})
|
||||||
logFileMutex sync.Mutex // 保护 logFile 的互斥锁
|
logFileMutex sync.Mutex
|
||||||
logFilePath = "/data/ghproxy/log/ghproxy.log"
|
logFilePath = "/data/ghproxy/log/ghproxy.log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Init 初始化日志记录器,接受日志文件路径作为参数
|
// 初始化,接受日志文件路径作为参数
|
||||||
func Init(logFilePath_input string, maxLogsize int) error {
|
func Init(logFilePath_input string, maxLogsize int) error {
|
||||||
logFileMutex.Lock()
|
logFileMutex.Lock()
|
||||||
defer logFileMutex.Unlock()
|
defer logFileMutex.Unlock()
|
||||||
|
|
@ -40,7 +40,6 @@ func Init(logFilePath_input string, maxLogsize int) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// logWorker 处理日志记录
|
|
||||||
func logWorker() {
|
func logWorker() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
|
@ -53,38 +52,37 @@ func logWorker() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log 直接记录日志的函数
|
|
||||||
func Log(customMessage string) {
|
func Log(customMessage string) {
|
||||||
logChannel <- customMessage
|
logChannel <- customMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logw 用于格式化日志记录
|
// 格式化日志记录
|
||||||
func Logw(format string, args ...interface{}) {
|
func Logw(format string, args ...interface{}) {
|
||||||
message := fmt.Sprintf(format, args...)
|
message := fmt.Sprintf(format, args...)
|
||||||
Log(message)
|
Log(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 日志等级INFO
|
// INFO
|
||||||
func LogInfo(format string, args ...interface{}) {
|
func LogInfo(format string, args ...interface{}) {
|
||||||
message := fmt.Sprintf(format, args...)
|
message := fmt.Sprintf(format, args...)
|
||||||
output := fmt.Sprintf("[INFO] %s", message)
|
output := fmt.Sprintf("[INFO] %s", message)
|
||||||
Log(output)
|
Log(output)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 日志等级WARNING
|
// WARNING
|
||||||
func LogWarning(format string, args ...interface{}) {
|
func LogWarning(format string, args ...interface{}) {
|
||||||
message := fmt.Sprintf(format, args...)
|
message := fmt.Sprintf(format, args...)
|
||||||
output := fmt.Sprintf("[WARNING] %s", message)
|
output := fmt.Sprintf("[WARNING] %s", message)
|
||||||
Log(output)
|
Log(output)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 日志等级ERROR
|
// ERROR
|
||||||
func LogError(format string, args ...interface{}) {
|
func LogError(format string, args ...interface{}) {
|
||||||
message := fmt.Sprintf(format, args...)
|
message := fmt.Sprintf(format, args...)
|
||||||
Log(message)
|
Log(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close 关闭日志文件
|
// 关闭日志文件
|
||||||
func Close() {
|
func Close() {
|
||||||
logFileMutex.Lock()
|
logFileMutex.Lock()
|
||||||
defer logFileMutex.Unlock()
|
defer logFileMutex.Unlock()
|
||||||
|
|
@ -100,7 +98,7 @@ func Close() {
|
||||||
func monitorLogSize(logFilePath string, maxLogsize int) {
|
func monitorLogSize(logFilePath string, maxLogsize int) {
|
||||||
var maxLogsizeBytes int64 = int64(maxLogsize) * 1024 * 1024 // 最大日志文件大小,单位为MB
|
var maxLogsizeBytes int64 = int64(maxLogsize) * 1024 * 1024 // 最大日志文件大小,单位为MB
|
||||||
for {
|
for {
|
||||||
time.Sleep(600 * time.Second) // 每10分钟检查一次
|
time.Sleep(120 * time.Minute) // 每120分钟检查一次日志文件大小
|
||||||
logFileMutex.Lock()
|
logFileMutex.Lock()
|
||||||
info, err := logFile.Stat()
|
info, err := logFile.Stat()
|
||||||
logFileMutex.Unlock()
|
logFileMutex.Unlock()
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,7 @@ func createHTTPClient(mode string) *req.Client {
|
||||||
client := req.C()
|
client := req.C()
|
||||||
switch mode {
|
switch mode {
|
||||||
case "chrome":
|
case "chrome":
|
||||||
client.SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36").
|
client.SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36").
|
||||||
SetTLSFingerprintChrome().
|
SetTLSFingerprintChrome().
|
||||||
ImpersonateChrome()
|
ImpersonateChrome()
|
||||||
case "git":
|
case "git":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue