Documentation
¶
Index ¶
- func GenerateStreamID(prefix string) (string, error)
- type Service
- func (s *Service) Accept(ctx context.Context, srv socketforward.TTRPCSocketForward_AcceptServer) error
- func (s *Service) Bind(ctx context.Context, req *socketforward.BindRequest) (*emptypb.Empty, error)
- func (s *Service) RegisterTTRPC(server *ttrpc.Server) error
- func (s *Service) Shutdown(_ context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateStreamID ¶
GenerateStreamID creates a pseudo-random stream ID with the given prefix. The format is "{prefix}-{nanosecond}-{random}" to minimize collisions.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service implements the VM-side socket forwarding ttrpc service. The VM creates UNIX listener sockets inside the VM and notifies the host when a container process connects, so the host can open a vsock stream and relay data to the target host-side socket.
func NewService ¶
NewService creates a new socket forwarding service.
func (*Service) Accept ¶
func (s *Service) Accept(ctx context.Context, srv socketforward.TTRPCSocketForward_AcceptServer) error
Accept is a bidirectional streaming RPC used to coordinate forwarded connections. The VM sends a ConnectRequest when a container process connects to a forwarded socket; the host resolves the forward_id, dials the target host socket, opens a vsock stream, and sends back a ConnectResult reporting success or failure. On failure the VM closes the pending container connection immediately.
func (*Service) Bind ¶
func (s *Service) Bind(ctx context.Context, req *socketforward.BindRequest) (*emptypb.Empty, error)
Bind sets up socket forward entries on the VM side. For each entry it creates a UNIX listener socket at the given socket_path. This method returns only after all socket files have been created.
func (*Service) RegisterTTRPC ¶
RegisterTTRPC registers the socket forwarding service with the ttrpc server.