Versions in this module Expand all Collapse all v0 v0.0.7 Oct 27, 2026 v0.0.6 Oct 16, 2026 Changes in this version + const DefaultEnrollTTL + const DefaultRevocationRecheck + const DefaultVHCIRoot — linux/amd64 + const MaxEnrollTTL + const MaxFramePayload + const MinProtocolVersion + const ProtocolVersion + const TokenFileMode + var ErrChannelRefused = errors.New("deviceforward: forwarder refused to open the device") + var ErrCredentialInvalid = errors.New("deviceforward: credential is invalid") + var ErrForwarderNotFound = errors.New("deviceforward: no such forwarder") + var ErrForwarderOffline = errors.New("deviceforward: forwarder is offline") + var ErrInvalidSpec = errors.New("deviceforward: invalid specification") + var ErrProtocol = errors.New("deviceforward: protocol error") + var ErrRevoked = errors.New("deviceforward: credential revoked") + var ErrTokenAlreadyUsed = errors.New("deviceforward: enrollment token already redeemed") + var ErrTokenExpired = errors.New("deviceforward: enrollment token expired") + var ErrTokenInvalid = errors.New("deviceforward: token is invalid") + func Revoke(store Store, id string, now time.Time) (kind string, err error) + func SaveCredential(path string, c Credential) error + type Bundle struct + Device ForwardedDevice + EnrollmentID string + ExpiresAt time.Time + Name string + Pin string + Server string + Token string + func DecodeBundle(s string) (Bundle, error) + func ReadTokenFile(path string) (b Bundle, warning string, err error) + func (b Bundle) Encode() (string, error) + func (b Bundle) Validate() error + type ByePayload struct + Reason string + Reconnect bool + type Credential struct + Credential string + Device ForwardedDevice + ForwarderID string + Name string + Pin string + Server string + func LoadCredential(path string) (Credential, bool, error) + type DeviceKind string + const KindL2 + const KindUSB + func (k DeviceKind) Valid() bool + type DeviceStream struct + Device ForwardedDevice + Exported ExportedDevice + ForwarderID string + type DialFunc func(ctx context.Context, server, token string) (frameConn, error) + type EnrollmentRecord struct + CreatedAt time.Time + CreatedBy string + Device ForwardedDevice + ExpiresAt time.Time + ID string + Name string + Owner string + RedeemedAgentID string + RedeemedAt time.Time + RevokedAt time.Time + SecretHash string + func Mint(store Store, opts MintOptions) (token string, rec EnrollmentRecord, err error) + func MintBundle(store Store, opts MintOptions) (encoded string, rec EnrollmentRecord, err error) + func (r EnrollmentRecord) Expired(now time.Time) bool + func (r EnrollmentRecord) Redeemed() bool + func (r EnrollmentRecord) Revoked() bool + type ErrorPayload struct + Message string + type ExportedDevice struct + BusID string + Interface string + Kind DeviceKind + ProductID string + Speed uint32 + VendorID string + type ForwardedDevice struct + Interface string + Kind DeviceKind + Label string + USB *executor.USBMatch + func (d ForwardedDevice) DefaultLabel() string + func (d ForwardedDevice) Describe() string + func (d ForwardedDevice) Normalize() (ForwardedDevice, error) + func (d ForwardedDevice) Validate() error + type Forwarder struct + func NewForwarder(cfg ForwarderConfig) (*Forwarder, error) + func (f *Forwarder) Run(ctx context.Context) error + func (f *Forwarder) TransportSummary() string + type ForwarderConfig struct + AgentVersion string + Bundle string + CAFile string + CredentialPath string + Dial DialFunc + Insecure bool + Logf func(format string, args ...any) + Pin string + Server string + Source LocalSource + Token string + type ForwarderRecord struct + CreatedAt time.Time + Device ForwardedDevice + EnrollmentID string + ForwarderID string + LastSeen time.Time + Name string + Owner string + RevokedAt time.Time + SecretHash string + func Authenticate(store Store, credential string, now time.Time) (ForwarderRecord, error) + func Redeem(store Store, token string, now time.Time) (credential string, fwd ForwarderRecord, err error) + func (r ForwarderRecord) Revoked() bool + type Frame struct + Channel uint32 + Payload []byte + Type FrameType + func (f Frame) Marshal() ([]byte, error) + type FrameType byte + const TypeBye + const TypeClose + const TypeData + const TypeError + const TypeHello + const TypeOpen + const TypeOpenAck + const TypePing + const TypePong + const TypeWelcome + type HelloPayload struct + AgentVersion string + Available bool + Detail string + Device ForwardedDevice + Resolved *executor.USBDevice + Version int + type Hub struct + func NewHub(opts HubOptions) (*Hub, error) + func (h *Hub) Connected() []string + func (h *Hub) DropSession(forwarderID, reason string) + func (h *Hub) OpenDevice(ctx context.Context, forwarderID, purpose string) (*DeviceStream, error) + func (h *Hub) OpenStream(ctx context.Context, forwarderID, purpose string) (io.ReadWriteCloser, error) + func (h *Hub) Resolved(forwarderID string) *HelloPayload + func (h *Hub) Revoke(forwarderID string) error + func (h *Hub) ServeHTTP(w http.ResponseWriter, r *http.Request) + func (h *Hub) Session(forwarderID string) (*session, bool) + type HubOptions struct + CheckOrigin func(*http.Request) (bool, string) + Logf func(format string, args ...any) + Now func() time.Time + OnConnect func(rec ForwarderRecord, hello HelloPayload) + OnEnroll func(rec ForwarderRecord) + OnStatusChange func(forwarderID, status string, at time.Time) + RevocationRecheck time.Duration + Store Store + type ImportOptions struct + DevRoot string + EnumerateTimeout time.Duration + Ledger *Ledger + Logf func(string, ...any) + SysfsRoot string + VHCI VHCI + type L2Source struct + func NewL2Source(iface string, opts L2SourceOptions) (*L2Source, error) + func (s *L2Source) Close() error + func (s *L2Source) Device() ForwardedDevice + func (s *L2Source) Open(context.Context) (io.ReadWriteCloser, error) + func (s *L2Source) Open(ctx context.Context) (io.ReadWriteCloser, error) + func (s *L2Source) Probe(context.Context) (bool, string, *executor.USBDevice) + func (s *L2Source) Probe(ctx context.Context) (bool, string, *executor.USBDevice) + type L2SourceOptions struct + Logf func(string, ...any) + type Ledger struct + func OpenLedger(dir string, logf func(string, ...any)) (*Ledger, error) + func (l *Ledger) Add(e LedgerEntry) string + func (l *Ledger) Entries() []LedgerEntry + func (l *Ledger) Remove(id string) + type LedgerEntry struct + At time.Time + DevID uint32 + ID string + Kind LedgerKind + TAP string + VHCIPort int + VHCIRoot string + type LedgerKind string + const LedgerTAP + const LedgerVHCI + type LocalSource interface + Close func() error + Device func() ForwardedDevice + Open func(ctx context.Context) (io.ReadWriteCloser, error) + Probe func(ctx context.Context) (ok bool, detail string, resolved *executor.USBDevice) + type MintOptions struct + CreatedBy string + Device ForwardedDevice + Name string + Now func() time.Time + Owner string + Pin string + Server string + TTL time.Duration + type OpenAckPayload struct + Device *ExportedDevice + Error string + OK bool + type OpenPayload struct + Purpose string + type ProbeResult struct + BusID string + Interfaces int + ProductID string + Speed uint32 + VendorID string + func ProbeUSB(ctx context.Context, stream io.ReadWriteCloser) (ProbeResult, error) + type Store interface + GetEnrollment func(id string) (EnrollmentRecord, error) + GetForwarder func(forwarderID string) (ForwarderRecord, error) + ListEnrollments func() ([]EnrollmentRecord, error) + ListForwarders func() ([]ForwarderRecord, error) + PutEnrollment func(rec EnrollmentRecord) error + PutForwarder func(rec ForwarderRecord) error + RedeemEnrollment func(id, forwarderID string, at time.Time) error + RevokeEnrollment func(id string, at time.Time) error + RevokeForwarder func(forwarderID string, at time.Time) error + TouchForwarder func(forwarderID string, at time.Time) error + type SweepReport struct + Detached []string + Errors []string + Removed []string + func SweepLedgers(dir string, logf func(string, ...any)) SweepReport + type TAPBridge struct + func BridgeTAP(stream io.ReadWriteCloser, tapName string) (*TAPBridge, error) + func (b *TAPBridge) Close() error + func (b *TAPBridge) Done() <-chan struct{} + func (b *TAPBridge) Name() string + type USBImport struct + DevID uint32 + Device executor.USBDevice + Port int + Remote usbipDevice + func ImportUSB(ctx context.Context, stream io.ReadWriteCloser, busid string, ...) (*USBImport, error) + func ImportUSB(ctx context.Context, stream io.ReadWriteCloser, busid string, ...) (_ *USBImport, err error) + func (u *USBImport) Close() error + func (u *USBImport) Done() <-chan struct{} + func (u *USBImport) HostDevices(name string) []executor.HostDevice + func (u *USBImport) HostDevices(string) []executor.HostDevice + type USBSource struct + func NewUSBSource(match executor.USBMatch, opts USBSourceOptions) (*USBSource, error) + func (s *USBSource) Close() error + func (s *USBSource) Device() ForwardedDevice + func (s *USBSource) Open(context.Context) (io.ReadWriteCloser, error) + func (s *USBSource) Open(ctx context.Context) (io.ReadWriteCloser, error) + func (s *USBSource) Probe(context.Context) (bool, string, *executor.USBDevice) + func (s *USBSource) Probe(ctx context.Context) (bool, string, *executor.USBDevice) + type USBSourceOptions struct + Logf func(string, ...any) + SysfsRoot string + UsbipBinary string + type VHCI struct + Root string + func (v VHCI) Available() error + type WelcomePayload struct + Credential string + ForwarderID string + Version int