session

package
v0.18.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2026 License: BSD-3-Clause Imports: 54 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultParallelStripes     = 8
	DefaultParallelInitial     = DefaultParallelStripes
	MaxParallelStripes         = 16
	AutoParallelSamplePeriod   = 500 * time.Millisecond
	AutoParallelGrowthStep     = 2
	AutoParallelTargetFloor    = DefaultParallelStripes
	AutoParallelHoldSamples    = 4
	AutoParallelMinGainMbps    = 50
	AutoParallelMinGainPercent = 10
)

Variables

View Source
var ErrPeerAborted = errors.New("peer aborted transfer")
View Source
var ErrPeerDisconnected = errors.New("peer disconnected")
View Source
var ErrSessionClaimed = errors.New("session already claimed")
View Source
var ErrUnknownSession = errors.New("unknown session")

Functions

func DerptunAppDial added in v0.15.2

func DerptunAppDial(ctx context.Context, cfg DerptunAppDialConfig) (*derptun.Mux, func(), error)

DerptunAppDial claims a derptun app session and returns a connected mux. The returned cleanup function closes the mux and releases the underlying transport resources; callers should call cleanup once they are done with the mux.

func DerptunAppDialStream added in v0.15.2

func DerptunAppDialStream(ctx context.Context, cfg DerptunAppDialConfig) (net.Conn, func(), error)

DerptunAppDialStream claims a derptun app session and opens one stream on the returned mux. The returned cleanup function closes the mux and transport; the caller still owns the returned stream and may close it independently.

func DerptunAppServe added in v0.15.2

func DerptunAppServe(ctx context.Context, cfg DerptunAppServeConfig) error

DerptunAppServe serves one derptun app mux at a time and passes each claimed mux to cfg.OnMux. The helper owns the mux and closes it when OnMux returns or the session shuts down; cfg.OnMux should keep running until it is done serving the peer.

func DerptunConnect added in v0.8.0

func DerptunConnect(ctx context.Context, cfg DerptunConnectConfig) error

func DerptunOpen added in v0.8.0

func DerptunOpen(ctx context.Context, cfg DerptunOpenConfig) error

func DerptunServe added in v0.8.0

func DerptunServe(ctx context.Context, cfg DerptunServeConfig) error

func DialAttach

func DialAttach(ctx context.Context, cfg AttachDialConfig) (net.Conn, error)

func Listen

func Listen(ctx context.Context, cfg ListenConfig) (string, error)

func Offer

func Offer(ctx context.Context, cfg OfferConfig) (string, error)

func Open

func Open(ctx context.Context, cfg OpenConfig) error

func Receive

func Receive(ctx context.Context, cfg ReceiveConfig) error

func Send

func Send(ctx context.Context, cfg SendConfig) error

func Share

func Share(ctx context.Context, cfg ShareConfig) (string, error)

Types

type AttachDialConfig

type AttachDialConfig struct {
	Token          string
	Emitter        *telemetry.Emitter
	ForceRelay     bool
	UsePublicDERP  bool
	ParallelPolicy ParallelPolicy
}

type AttachListenConfig

type AttachListenConfig struct {
	Emitter       *telemetry.Emitter
	ForceRelay    bool
	UsePublicDERP bool
}

type AttachListener

type AttachListener struct {
	Token string
	// contains filtered or unexported fields
}

func ListenAttach

func ListenAttach(ctx context.Context, cfg AttachListenConfig) (*AttachListener, error)

func (*AttachListener) Accept

func (l *AttachListener) Accept(ctx context.Context) (net.Conn, error)

func (*AttachListener) Close

func (l *AttachListener) Close() error

type BlockReceiveRequest added in v0.16.0

type BlockReceiveRequest struct {
	Header      []byte
	PayloadSize int64
	ChunkSize   int
}

type BlockReceiveSink added in v0.16.0

type BlockReceiveSink interface {
	io.WriterAt
	Close() error
}

type BlockReceiver added in v0.16.0

type BlockSource added in v0.16.0

type BlockSource struct {
	Header      []byte
	HeaderFunc  func() []byte
	Payload     io.ReaderAt
	PayloadSize int64
	ChunkSize   int
	OpenStream  func() (io.ReadCloser, error)
}

type ConcurrentBlockReceiveSink added in v0.17.0

type ConcurrentBlockReceiveSink interface {
	BlockReceiveSink
	ConcurrentWriteAtSafe() bool
}

ConcurrentBlockReceiveSink is an optional capability for sinks whose WriteAt implementation permits calls from multiple goroutines. Block sinks without this capability remain serialized.

type DerptunAppDialConfig added in v0.15.2

type DerptunAppDialConfig struct {
	ClientToken string
	Emitter     *telemetry.Emitter
	ForceRelay  bool
}

type DerptunAppServeConfig added in v0.15.2

type DerptunAppServeConfig struct {
	ServerToken string
	Emitter     *telemetry.Emitter
	ForceRelay  bool
	OnMux       func(context.Context, *derptun.Mux) error
}

type DerptunConnectConfig added in v0.8.0

type DerptunConnectConfig struct {
	ClientToken string
	StdioIn     io.Reader
	StdioOut    io.Writer
	Emitter     *telemetry.Emitter
	ForceRelay  bool
}

type DerptunOpenConfig added in v0.8.0

type DerptunOpenConfig struct {
	ClientToken  string
	ListenAddr   string
	BindAddrSink chan<- string
	Emitter      *telemetry.Emitter
	ForceRelay   bool
}

type DerptunServeConfig added in v0.8.0

type DerptunServeConfig struct {
	ServerToken string
	TargetAddr  string
	Emitter     *telemetry.Emitter
	ForceRelay  bool
}

type DirectBlockReceiveSink added in v0.17.0

type DirectBlockReceiveSink interface {
	BlockReceiveSink
	DirectWriteBuffer() []byte
	CommitDirectWrite(bytes int, highestEnd int64) error
}

DirectBlockReceiveSink is an optional capability for file-backed sinks that expose the destination's page-cache mapping. Bulk packet receivers copy only authenticated payload into the buffer and report committed bytes in batches.

type ListenConfig

type ListenConfig struct {
	Emitter       *telemetry.Emitter
	TokenSink     chan<- string
	StdioOut      io.Writer
	BlockReceiver BlockReceiver
	ForceRelay    bool
	UsePublicDERP bool
	Trace         *transfertrace.Recorder
	DirectTCPPort int
}

type OfferConfig

type OfferConfig struct {
	Emitter            *telemetry.Emitter
	TokenSink          chan<- string
	StdioIn            io.Reader
	StdioExpectedBytes int64
	BlockSource        *BlockSource
	ForceRelay         bool
	UsePublicDERP      bool
	ParallelPolicy     ParallelPolicy
	Trace              *transfertrace.Recorder
	Progress           func(bytesReceived int64, transferElapsedMS int64)
	DirectTCPPort      int
}

type OpenConfig

type OpenConfig struct {
	Token          string
	BindAddr       string
	BindAddrSink   chan<- string
	Emitter        *telemetry.Emitter
	ForceRelay     bool
	UsePublicDERP  bool
	ParallelPolicy ParallelPolicy
}

type ParallelMode

type ParallelMode string
const (
	ParallelModeFixed ParallelMode = "fixed"
	ParallelModeAuto  ParallelMode = "auto"
)

type ParallelPolicy

type ParallelPolicy struct {
	Mode    ParallelMode
	Initial int
	Cap     int
}

func AutoParallelPolicy

func AutoParallelPolicy() ParallelPolicy

func DefaultParallelPolicy

func DefaultParallelPolicy() ParallelPolicy

func FixedParallelPolicy

func FixedParallelPolicy(n int) ParallelPolicy

func ParseParallelPolicy

func ParseParallelPolicy(raw string) (ParallelPolicy, error)

type ReceiveConfig

type ReceiveConfig struct {
	Token         string
	Emitter       *telemetry.Emitter
	StdioOut      io.Writer
	BlockReceiver BlockReceiver
	ForceRelay    bool
	UsePublicDERP bool
	Trace         *transfertrace.Recorder
	DirectTCPPort int
}

type SendConfig

type SendConfig struct {
	Token              string
	Emitter            *telemetry.Emitter
	StdioIn            io.Reader
	StdioExpectedBytes int64
	BlockSource        *BlockSource
	ForceRelay         bool
	UsePublicDERP      bool
	ParallelPolicy     ParallelPolicy
	Trace              *transfertrace.Recorder
	Progress           func(bytesReceived int64, transferElapsedMS int64)
	DirectTCPPort      int
}

type ShareConfig

type ShareConfig struct {
	Emitter       *telemetry.Emitter
	TokenSink     chan<- string
	TargetAddr    string
	ForceRelay    bool
	UsePublicDERP bool
}

type State

type State string
const (
	StateWaiting             State = "waiting-for-claim"
	StateClaimed             State = "claimed"
	StateProbing             State = "probing-direct"
	StateDirect              State = "connected-direct"
	StateTryingDirect        State = "trying-direct"
	StateDirectFallbackRelay State = "direct-fallback-relay"
	StateRelay               State = "connected-relay"
	StateComplete            State = "stream-complete"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL