Documentation
¶
Index ¶
- func ParseWebSocketURL(rawURL string) (scheme, host, port, path string, err error)
- type CompressionConfig
- type Config
- type Manager
- type Transport
- type VirtualConn
- func (v *VirtualConn) Close() error
- func (v *VirtualConn) LocalAddr() net.Addr
- func (v *VirtualConn) Read(b []byte) (n int, err error)
- func (v *VirtualConn) RemoteAddr() net.Addr
- func (v *VirtualConn) SetDeadline(t time.Time) error
- func (v *VirtualConn) SetReadDeadline(t time.Time) error
- func (v *VirtualConn) SetWriteDeadline(t time.Time) error
- func (v *VirtualConn) SwapConnection(newConn net.Conn)
- func (v *VirtualConn) SwapConnectionSeamless(newConn net.Conn) error
- func (v *VirtualConn) Write(b []byte) (n int, err error)
- type WebSocketConfig
- type WebSocketTransport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseWebSocketURL ¶ added in v0.3.5
ParseWebSocketURL parses a WebSocket URL and returns components
Types ¶
type CompressionConfig ¶ added in v0.3.5
CompressionConfig holds compression settings
type Config ¶ added in v0.3.5
type Config struct {
// Secret is the authentication secret/key
Secret string
// DNS is the DNS server address for resolution
DNS string
// Compression holds optional compression settings
Compression *CompressionConfig
}
Config holds common configuration for all transports
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles the lifecycle of underlying network connections and seamless switching between them using Yamux session resumption. Uses MTP (Mimic Transport Protocol) over UDP for anti-DPI transport.
func NewManager ¶
NewManager creates a new transport manager
func (*Manager) GetMTPConn ¶
GetMTPConn returns the current MTP connection (for stats)
func (*Manager) RotateTransport ¶
RotateTransport switches the underlying transport to a new domain while keeping the Yamux session alive via MTP session migration. Uses protected dialer for Android VpnService compatibility.
type Transport ¶ added in v0.3.5
type Transport interface {
// Dial connects to the remote address and returns a net.Conn
Dial(ctx context.Context, address string) (net.Conn, error)
// Listen starts listening for incoming connections on the given address
Listen(address string) (net.Listener, error)
// Name returns the transport protocol name (e.g., "mtp", "ws", "quic")
Name() string
// Close closes the transport and releases resources
Close() error
}
Transport is the interface that all transport protocols must implement. It provides a unified API for different transport mechanisms (MTP, WebSocket, QUIC, etc.)
type VirtualConn ¶
type VirtualConn struct {
// contains filtered or unexported fields
}
VirtualConn is a persistent connection wrapper that can switch its underlying physical connection. This allows upper layers (like Yamux) to think they have a stable connection. It supports buffered seamless swap to prevent data loss during transport rotation.
func NewVirtualConn ¶
func NewVirtualConn(conn net.Conn) *VirtualConn
func (*VirtualConn) Close ¶
func (v *VirtualConn) Close() error
func (*VirtualConn) LocalAddr ¶
func (v *VirtualConn) LocalAddr() net.Addr
func (*VirtualConn) RemoteAddr ¶
func (v *VirtualConn) RemoteAddr() net.Addr
func (*VirtualConn) SetDeadline ¶
func (v *VirtualConn) SetDeadline(t time.Time) error
func (*VirtualConn) SetReadDeadline ¶
func (v *VirtualConn) SetReadDeadline(t time.Time) error
func (*VirtualConn) SetWriteDeadline ¶
func (v *VirtualConn) SetWriteDeadline(t time.Time) error
func (*VirtualConn) SwapConnection ¶
func (v *VirtualConn) SwapConnection(newConn net.Conn)
SwapConnection replaces the underlying connection with a new one. The old connection is NOT closed here, caller handles it.
func (*VirtualConn) SwapConnectionSeamless ¶
func (v *VirtualConn) SwapConnectionSeamless(newConn net.Conn) error
SwapConnectionSeamless replaces the underlying connection with buffered transition. Writes during the swap are captured and replayed on the new connection.
type WebSocketConfig ¶ added in v0.3.5
type WebSocketConfig struct {
// Path is the URL path for WebSocket endpoint (e.g., "/ws")
Path string
// Host is the Host header value for masquerading
Host string
// TLS enables WSS (WebSocket over TLS)
TLS bool
// TLSConfig allows custom TLS configuration
TLSConfig *tls.Config
// Headers are additional HTTP headers to send during handshake
Headers http.Header
// HandshakeTimeout is the timeout for WebSocket handshake
HandshakeTimeout time.Duration
// ReadBufferSize is the size of the read buffer
ReadBufferSize int
// WriteBufferSize is the size of the write buffer
WriteBufferSize int
}
WebSocketConfig holds WebSocket-specific configuration
func DefaultWebSocketConfig ¶ added in v0.3.5
func DefaultWebSocketConfig() *WebSocketConfig
DefaultWebSocketConfig returns default WebSocket configuration
type WebSocketTransport ¶ added in v0.3.5
type WebSocketTransport struct {
// contains filtered or unexported fields
}
WebSocketTransport implements Transport interface for WebSocket connections
func NewWebSocketTransport ¶ added in v0.3.5
func NewWebSocketTransport(config *WebSocketConfig) *WebSocketTransport
NewWebSocketTransport creates a new WebSocket transport
func (*WebSocketTransport) Close ¶ added in v0.3.5
func (t *WebSocketTransport) Close() error
Close closes the WebSocket transport
func (*WebSocketTransport) Listen ¶ added in v0.3.5
func (t *WebSocketTransport) Listen(address string) (net.Listener, error)
Listen starts a WebSocket server
func (*WebSocketTransport) Name ¶ added in v0.3.5
func (t *WebSocketTransport) Name() string
Name returns the transport name