Documentation
¶
Index ¶
- func TLSConfig(caFile string) (*tls.Config, error)
- type Conn
- func (c *Conn) AcceptRawStream(ctx context.Context) (*quic.Stream, error)
- func (c *Conn) AcceptStream(ctx context.Context) (*Stream, error)
- func (c *Conn) Close() error
- func (c *Conn) Context() context.Context
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) OpenStream(ctx context.Context) (*quic.Stream, error)
- func (c *Conn) RemoteAddr() net.Addr
- type PersistentConn
- type Stream
- func (s *Stream) ClaimedAddr() net.Addr
- func (s *Stream) Close() error
- func (s *Stream) LocalAddr() net.Addr
- func (s *Stream) Read(p []byte) (int, error)
- func (s *Stream) RemoteAddr() net.Addr
- func (s *Stream) SetDeadline(t time.Time) error
- func (s *Stream) SetReadDeadline(t time.Time) error
- func (s *Stream) SetWriteDeadline(t time.Time) error
- func (s *Stream) Write(p []byte) (int, error)
- type UDPRelay
- type UDPSession
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn wraps a QUIC connection to the relay server.
func Dial ¶
func Dial(ctx context.Context, addr string, user, device string, signer ssh.Signer, tlsCfg *tls.Config) (*Conn, error)
Dial connects to the relay server and authenticates. The handshake:
- Client opens a control stream
- Client sends: [userLen:1][user][deviceLen:1][device][pubkeyLen:2][pubkey]
- Server sends: [challengeLen:1][challenge]
- Client signs domainSeparator+challenge with relay key, sends: [sigLen:2][sig]
- Server sends: [1] on success, closes stream on failure
func (*Conn) AcceptRawStream ¶
AcceptRawStream accepts a raw QUIC stream without reading any header.
func (*Conn) AcceptStream ¶
AcceptStream accepts an incoming stream from the relay (a routed SSH connection).
func (*Conn) Context ¶ added in v1.0.11
Context returns the QUIC connection's context, which is cancelled when the connection is closed or times out.
func (*Conn) OpenStream ¶ added in v1.0.1
OpenStream opens a new device-initiated QUIC stream to the relay.
func (*Conn) RemoteAddr ¶
RemoteAddr returns the remote address of the QUIC connection.
type PersistentConn ¶
type PersistentConn struct {
// StreamFunc is called for each accepted SSH stream.
StreamFunc func(*Stream)
// UDPFunc is called for each accepted UDP forward stream.
// The stream has the type byte consumed; next bytes are [targetPort:2][ipLen:2][ipString].
UDPFunc func(*quic.Stream)
// ConnectedFunc is called each time a relay connection is established.
ConnectedFunc func()
// contains filtered or unexported fields
}
PersistentConn maintains a persistent relay connection with auto-reconnect.
func NewPersistentConn ¶
func NewPersistentConn(addr, user, device string, signer ssh.Signer, tlsCfg *tls.Config, fn func(*Stream)) *PersistentConn
NewPersistentConn creates a new persistent relay connection.
func (*PersistentConn) OpenStream ¶ added in v1.0.1
OpenStream opens a device-initiated QUIC stream on the current connection. Returns an error if not currently connected.
func (*PersistentConn) PushSessions ¶ added in v1.0.2
func (p *PersistentConn) PushSessions(data []byte) error
PushSessions sends a session metadata update to the relay. Format: [0x04][len:2][json]
func (*PersistentConn) Start ¶
func (p *PersistentConn) Start()
Start begins the connection loop in a goroutine.
func (*PersistentConn) Stop ¶
func (p *PersistentConn) Stop()
Stop closes the connection and stops reconnecting.
type Stream ¶
Stream wraps a QUIC stream as a net.Conn. The relay sends the original client IP at the start of each stream: [ip_len:2][ip_string].
func WrapStream ¶
WrapStream reads the client IP header and returns a net.Conn. quicRemoteAddr is the actual QUIC connection's remote address; the claimed address from the stream header is stored separately.
func (*Stream) ClaimedAddr ¶
func (*Stream) RemoteAddr ¶
type UDPRelay ¶
type UDPRelay struct {
// Timeout is the session idle timeout. Zero means 10 minutes.
Timeout time.Duration
// contains filtered or unexported fields
}
UDPRelay manages UDP relay sessions for mosh. Each session binds a local UDP port and forwards datagrams to a device via a QUIC stream.
func (*UDPRelay) CloseSession ¶
CloseSession closes and removes a session.
func (*UDPRelay) CreateSession ¶
func (r *UDPRelay) CreateSession(id string, stream io.ReadWriteCloser) (*UDPSession, error)
CreateSession creates a new UDP relay session. It binds a local UDP port and starts forwarding datagrams between the UDP port and the QUIC stream.
type UDPSession ¶
UDPSession represents an active mosh UDP relay session.