Files
drip/internal/client/tcp/connector.go
Gouryella 0c19c3300c feat(tunnel): switch to yamux stream proxying and connection pooling
- Introduce pooled tunnel sessions (TunnelID/DataConnect) on client/server
- Proxy HTTP/HTTPS via raw HTTP over yamux streams; pipe TCP streams directly
- Move UI/stats into internal/shared; refactor CLI tunnel helpers; drop msgpack/hpack legacy
2025-12-13 18:03:44 +08:00

51 lines
927 B
Go

package tcp
import (
"strings"
"time"
"drip/internal/shared/protocol"
"drip/internal/shared/stats"
"go.uber.org/zap"
)
type LatencyCallback func(latency time.Duration)
type ConnectorConfig struct {
ServerAddr string
Token string
TunnelType protocol.TunnelType
LocalHost string
LocalPort int
Subdomain string
Insecure bool
PoolSize int
PoolMin int
PoolMax int
}
type TunnelClient interface {
Connect() error
Close() error
Wait()
GetURL() string
GetSubdomain() string
SetLatencyCallback(cb LatencyCallback)
GetLatency() time.Duration
GetStats() *stats.TrafficStats
IsClosed() bool
}
func NewTunnelClient(cfg *ConnectorConfig, logger *zap.Logger) TunnelClient {
return NewPoolClient(cfg, logger)
}
func isExpectedCloseError(err error) bool {
s := err.Error()
return strings.Contains(s, "EOF") ||
strings.Contains(s, "use of closed") ||
strings.Contains(s, "connection reset")
}