1
0
mirror of https://github.com/fumiama/terasu-cloudflared.git synced 2026-06-12 14:10:31 +08:00

feat: embed terasu inside

This commit is contained in:
源文雨
2025-12-21 16:51:38 +08:00
parent 0d2a7a0385
commit f99b9330df
23 changed files with 1195 additions and 18 deletions

View File

@@ -11,6 +11,7 @@ import (
"net/url"
"time"
"github.com/fumiama/terasu"
"github.com/miekg/dns"
"github.com/pkg/errors"
"github.com/rs/zerolog"
@@ -130,6 +131,17 @@ func configureClient(hostname string, maxUpstreamConnections int) *http.Client {
// Update TLS and HTTP client configuration
tlsConfig := &tls.Config{ServerName: hostname}
transport := &http.Transport{
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
dialer := &net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}
conn, err := dialer.DialContext(ctx, network, addr)
if err != nil {
return nil, err
}
return terasu.NewConn(conn), nil
},
TLSClientConfig: tlsConfig,
DisableCompression: true,
MaxIdleConns: 1,