adapter

package
v0.0.0-...-0d07254 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2025 License: Apache-2.0, MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAX_MESSAGE_LENGTH = 5 * 1024 * 1024 // 5Mb
	MAX_TEXT_LENGTH    = 5 * 1024 * 1024 // 5Mb
)

TODO: fine tune all of the buffer sizes

View Source
const FILE_CHUNK_SIZE = 512 * 1024 // 512 KB

Variables

View Source
var (
	ErrConnWasEndedByClient = errors.New("connection was ended by client")
	ErrNotServiceMessage    = errors.New("message is not service message")
	ErrInvalidMessageLength = errors.New("invalid message length")
	ErrMessageTooLong       = errors.New("message to long")
	ErrOffsetMismatch       = errors.New("new chunk offset not expected")
	ErrFetchFullMessage     = errors.New("cannot fetch full message")
)
View Source
var (
	ErrInvalidSignatureScheme  = errors.New("got unsupported signature scheme")
	ErrInvalidIV               = errors.New("got invalid iv in header")
	ErrInvalidEncryptionScheme = errors.New("got unsupported encryption scheme")
)
View Source
var (
	ErrInvalidMessage      = errors.New("got invalid message")
	ErrInvalidOfflineFrame = errors.New("offline frame is invalid")
	ErrInvalidSharingFrame = errors.New("sharing frame is invalid")
)

Functions

func CraftEndpointInfo

func CraftEndpointInfo(r rand.Random, hostname string, device qshare.DeviceType) []byte

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

func New

func New(
	conn net.Conn,
	logger qshare.Logger,
	isServer bool,
	fileChunkCallback FileChunkCallback,
	textTransferCallback TextTransferCallback,
	r rand.Random,
) Adapter

func (*Adapter) Disconnect

func (a *Adapter) Disconnect()

func (*Adapter) EnableEncryption

func (a *Adapter) EnableEncryption() error

func (*Adapter) EnableTransferHandler

func (a *Adapter) EnableTransferHandler()

func (*Adapter) Pin

func (a *Adapter) Pin() uint16

func (*Adapter) ProcessServiceMessage

func (a *Adapter) ProcessServiceMessage(msg []byte) error

func (*Adapter) Reader

func (a *Adapter) Reader(ctx context.Context) func() ([]byte, error)

TODO: SECURITY: - implement timeouts between messages

func (*Adapter) SendBadMessageError

func (a *Adapter) SendBadMessageError()

func (*Adapter) SendClientInitWithClientFinished

func (a *Adapter) SendClientInitWithClientFinished() error

func (*Adapter) SendConnRequest

func (a *Adapter) SendConnRequest(endpointID, hostname string, device qshare.DeviceType) error

func (*Adapter) SendConnResponse

func (a *Adapter) SendConnResponse(isAccepted bool) error

func (*Adapter) SendDataInChunks

func (a *Adapter) SendDataInChunks(payloadID int64, data []byte) error

func (*Adapter) SendFileInChunks

func (a *Adapter) SendFileInChunks(payloadID int64, file qshare.FilePayload) error

func (*Adapter) SendIntroduction

func (a *Adapter) SendIntroduction(frame IntroductionFrame) error

func (*Adapter) SendPairedKeyEncryption

func (a *Adapter) SendPairedKeyEncryption() error

func (*Adapter) SendPairedKeyResult

func (a *Adapter) SendPairedKeyResult() error

func (*Adapter) SendServerInit

func (a *Adapter) SendServerInit() error

func (*Adapter) SendTransferRequest

func (a *Adapter) SendTransferRequest() error

func (*Adapter) SendTransferResponse

func (a *Adapter) SendTransferResponse(isAccepted bool) error

func (*Adapter) UnmarshalConnRequest

func (a *Adapter) UnmarshalConnRequest(msg []byte) (ConnRequest, error)

func (*Adapter) UnmarshalConnResponse

func (a *Adapter) UnmarshalConnResponse(msg []byte) (ConnResponse, error)

func (*Adapter) UnmarshalIntroduction

func (a *Adapter) UnmarshalIntroduction(msg []byte) (IntroductionFrame, error)

TODO: SECURITY: - sanitize all strings

func (*Adapter) UnmarshalTransferResponse

func (a *Adapter) UnmarshalTransferResponse(msg []byte) (bool, error)

func (*Adapter) ValidateClientFinished

func (a *Adapter) ValidateClientFinished(msg []byte) error

func (*Adapter) ValidateClientInit

func (a *Adapter) ValidateClientInit(msg []byte) error

func (*Adapter) ValidatePairedKeyEncryption

func (a *Adapter) ValidatePairedKeyEncryption(msg []byte) error

func (*Adapter) ValidatePairedKeyResult

func (a *Adapter) ValidatePairedKeyResult(msg []byte) error

func (*Adapter) ValidateServerInit

func (a *Adapter) ValidateServerInit(msg []byte) error

func (*Adapter) ValidateTransferRequest

func (a *Adapter) ValidateTransferRequest(msg []byte) error

type ConnRequest

type ConnRequest struct {
	EndpointInfo []byte
}

type ConnResponse

type ConnResponse struct {
	IsConnAccepted bool
}

type FileChunk

type FileChunk struct {
	FileID       int64
	IsFinalChunk bool
	Body         []byte
}

type FileChunkCallback

type FileChunkCallback func(chunk FileChunk) error

type IntroductionFrame

type IntroductionFrame struct {
	Text  *TextMeta
	Files map[int64]*qshare.FilePayload
}

func (IntroductionFrame) HasFiles

func (f IntroductionFrame) HasFiles() bool

func (IntroductionFrame) HasText

func (f IntroductionFrame) HasText() bool

type TextMeta

type TextMeta struct {
	qshare.TextMeta
	ID int64
}

func NewTextMeta

func NewTextMeta(ID int64, t qshare.TextType, title string, size int64) *TextMeta

func (*TextMeta) GetQShareTextMeta

func (meta *TextMeta) GetQShareTextMeta() *qshare.TextMeta

type TextTransferCallback

type TextTransferCallback func(text string) error

Jump to

Keyboard shortcuts

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