1
0
mirror of https://github.com/fumiama/terasu-cloudflared.git synced 2026-06-08 20:10:25 +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

@@ -1,13 +1,16 @@
package tunnel
import (
"context"
"encoding/json"
"fmt"
"io"
"net"
"net/http"
"strings"
"time"
"github.com/fumiama/terasu"
"github.com/google/uuid"
"github.com/pkg/errors"
@@ -28,6 +31,17 @@ func RunQuickTunnel(sc *subcommandContext) error {
client := http.Client{
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
},
TLSHandshakeTimeout: httpTimeout,
ResponseHeaderTimeout: httpTimeout,
},