mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 08:11:11 +08:00
update for touka-httpc 0.4.0
This commit is contained in:
parent
d6d54b222f
commit
8af107c584
4 changed files with 42 additions and 15 deletions
|
|
@ -1,5 +1,10 @@
|
||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
|
25w28t-1 - 2025-04-11
|
||||||
|
---
|
||||||
|
- TEST: 测试验证版本
|
||||||
|
- CHANGE: 更新httpc 0.4.0
|
||||||
|
|
||||||
3.0.1 - 2025-04-08
|
3.0.1 - 2025-04-08
|
||||||
---
|
---
|
||||||
- CHANGE: 加入`memLimit`指示gc
|
- CHANGE: 加入`memLimit`指示gc
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
25w27a
|
25w28t-1
|
||||||
5
main.go
5
main.go
|
|
@ -26,6 +26,8 @@ import (
|
||||||
"github.com/cloudwego/hertz/pkg/common/adaptor"
|
"github.com/cloudwego/hertz/pkg/common/adaptor"
|
||||||
"github.com/cloudwego/hertz/pkg/common/hlog"
|
"github.com/cloudwego/hertz/pkg/common/hlog"
|
||||||
|
|
||||||
|
//"github.com/cloudwego/hertz/pkg/network/standard"
|
||||||
|
|
||||||
"github.com/hertz-contrib/http2/factory"
|
"github.com/hertz-contrib/http2/factory"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -146,6 +148,7 @@ func setupHertZLogger(cfg *config.Config) {
|
||||||
} else {
|
} else {
|
||||||
hlog.SetOutput(hertZfile)
|
hlog.SetOutput(hertZfile)
|
||||||
}
|
}
|
||||||
|
hlog.SetLevel(hlog.LevelInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -377,6 +380,8 @@ func main() {
|
||||||
r = server.New(
|
r = server.New(
|
||||||
server.WithHostPorts(addr),
|
server.WithHostPorts(addr),
|
||||||
server.WithH2C(true),
|
server.WithH2C(true),
|
||||||
|
// server.WithALPN(true),
|
||||||
|
// server.WithTransport(standard.NewTransporter),
|
||||||
)
|
)
|
||||||
r.AddProtocol("h2", factory.NewServerFactory())
|
r.AddProtocol("h2", factory.NewServerFactory())
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -87,23 +87,12 @@ func initHTTPClient(cfg *config.Config) {
|
||||||
|
|
||||||
func initGitHTTPClient(cfg *config.Config) {
|
func initGitHTTPClient(cfg *config.Config) {
|
||||||
|
|
||||||
var proTolcols = new(http.Protocols)
|
|
||||||
proTolcols.SetHTTP1(true)
|
|
||||||
proTolcols.SetHTTP2(true)
|
|
||||||
proTolcols.SetUnencryptedHTTP2(true)
|
|
||||||
if cfg.GitClone.ForceH2C {
|
|
||||||
proTolcols.SetHTTP1(false)
|
|
||||||
proTolcols.SetHTTP2(false)
|
|
||||||
proTolcols.SetUnencryptedHTTP2(true)
|
|
||||||
}
|
|
||||||
if cfg.Httpc.Mode == "auto" {
|
if cfg.Httpc.Mode == "auto" {
|
||||||
|
|
||||||
gittr = &http.Transport{
|
gittr = &http.Transport{
|
||||||
//MaxIdleConns: 160,
|
//MaxIdleConns: 160,
|
||||||
IdleConnTimeout: 30 * time.Second,
|
IdleConnTimeout: 30 * time.Second,
|
||||||
WriteBufferSize: 32 * 1024, // 32KB
|
WriteBufferSize: 32 * 1024, // 32KB
|
||||||
ReadBufferSize: 32 * 1024, // 32KB
|
ReadBufferSize: 32 * 1024, // 32KB
|
||||||
Protocols: proTolcols,
|
|
||||||
}
|
}
|
||||||
} else if cfg.Httpc.Mode == "advanced" {
|
} else if cfg.Httpc.Mode == "advanced" {
|
||||||
gittr = &http.Transport{
|
gittr = &http.Transport{
|
||||||
|
|
@ -112,7 +101,6 @@ func initGitHTTPClient(cfg *config.Config) {
|
||||||
MaxIdleConnsPerHost: cfg.Httpc.MaxIdleConnsPerHost,
|
MaxIdleConnsPerHost: cfg.Httpc.MaxIdleConnsPerHost,
|
||||||
WriteBufferSize: 32 * 1024, // 32KB
|
WriteBufferSize: 32 * 1024, // 32KB
|
||||||
ReadBufferSize: 32 * 1024, // 32KB
|
ReadBufferSize: 32 * 1024, // 32KB
|
||||||
Protocols: proTolcols,
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 错误的模式
|
// 错误的模式
|
||||||
|
|
@ -130,14 +118,43 @@ func initGitHTTPClient(cfg *config.Config) {
|
||||||
if cfg.Outbound.Enabled {
|
if cfg.Outbound.Enabled {
|
||||||
initTransport(cfg, gittr)
|
initTransport(cfg, gittr)
|
||||||
}
|
}
|
||||||
if cfg.Server.Debug {
|
if cfg.Server.Debug && cfg.GitClone.ForceH2C {
|
||||||
gitclient = httpc.New(
|
gitclient = httpc.New(
|
||||||
httpc.WithTransport(gittr),
|
httpc.WithTransport(gittr),
|
||||||
httpc.WithDumpLog(),
|
httpc.WithDumpLog(),
|
||||||
|
httpc.WithProtocols(httpc.ProtocolsConfig{
|
||||||
|
Http1: false,
|
||||||
|
Http2: false,
|
||||||
|
Http2_Cleartext: true,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
} else if !cfg.Server.Debug && cfg.GitClone.ForceH2C {
|
||||||
|
gitclient = httpc.New(
|
||||||
|
httpc.WithTransport(gittr),
|
||||||
|
httpc.WithProtocols(httpc.ProtocolsConfig{
|
||||||
|
Http1: false,
|
||||||
|
Http2: false,
|
||||||
|
Http2_Cleartext: true,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
} else if cfg.Server.Debug && !cfg.GitClone.ForceH2C {
|
||||||
|
gitclient = httpc.New(
|
||||||
|
httpc.WithTransport(gittr),
|
||||||
|
httpc.WithDumpLog(),
|
||||||
|
httpc.WithProtocols(httpc.ProtocolsConfig{
|
||||||
|
Http1: true,
|
||||||
|
Http2: true,
|
||||||
|
Http2_Cleartext: true,
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
gitclient = httpc.New(
|
gitclient = httpc.New(
|
||||||
httpc.WithTransport(gittr),
|
httpc.WithTransport(gittr),
|
||||||
|
httpc.WithProtocols(httpc.ProtocolsConfig{
|
||||||
|
Http1: true,
|
||||||
|
Http2: true,
|
||||||
|
Http2_Cleartext: true,
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue