mirror of
https://github.com/Gouryella/drip.git
synced 2026-02-27 23:00:55 +00:00
- 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
51 lines
927 B
Go
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")
|
|
}
|