secure

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeterminePacketSize

func DeterminePacketSize(data []byte) uint16

func Handshake

func Handshake(conn *net.TCPConn) *[32]byte

Types

type OperationTypeEnum

type OperationTypeEnum byte
const (
	OperationTypeSend OperationTypeEnum = iota
	OperationTypeList
	OperationTypeReceive
)

type PacketListData

type PacketListData struct {
	Id        uint32
	Filename  string
	FileSize  uint32
	Timestamp time.Time
	Kind      string
}

type PacketReceiveDataNext

type PacketReceiveDataNext struct {
	Size uint16
	Data []byte
	Last bool
}

type PacketReceiveDataStartRequest

type PacketReceiveDataStartRequest struct {
	Id uint32
}

PacketReceiveDataStart is sent from the server to the client when the client asks for a file to be sent to them.

type PacketReceiveDataStartResponse

type PacketReceiveDataStartResponse struct {
	Status    PacketReceiveDataStartResponseEnum
	Filename  string
	Kind      string
	TotalSize uint32
}

PacketReceiveDataStartResponse is the response to the above packet.

type PacketReceiveDataStartResponseEnum

type PacketReceiveDataStartResponseEnum byte
const (
	// File transfer can begin
	ReceiveDataStartResponseOK PacketReceiveDataStartResponseEnum = iota
	// No such file by index
	ReceiveDataStartResponseNotFound
)

type PacketSendDataNext

type PacketSendDataNext struct {
	Size uint16
	Data []byte
}

type PacketSendDataStart

type PacketSendDataStart struct {
	Filename  string
	TotalSize uint32
}

type PacketStartRequest

type PacketStartRequest struct {
	OperationType   OperationTypeEnum
	ClientName      string
	ProtocolVersion string
	AuthToken       string
}

PacketStartRequest is sent from the client to the server at the beginning to authenticate and annonce the requested particular operation

type PacketStartResponse

type PacketStartResponse struct {
	Response PacketStartResponseEnum
}

type PacketStartResponseEnum

type PacketStartResponseEnum byte
const (
	// Client can connect
	PacketStartResponseEnumOK PacketStartResponseEnum = iota
	// Client using wrong protocol version
	PacketStartResponseEnumWrongProtocol
	// Client supplied bad auth token
	PacketStartResponseEnumBadAuthToken
)

type SecureConnection

type SecureConnection struct {
	// Conn      *net.TCPConn
	Conn      io.ReadWriteCloser
	SharedKey *[32]byte
	Buffer    *bytes.Buffer
}

func (*SecureConnection) Read

func (s *SecureConnection) Read(p []byte) (int, error)

func (*SecureConnection) Write

func (s *SecureConnection) Write(p []byte) (int, error)

type SecureMessage

type SecureMessage struct {
	Msg   []byte
	Size  uint16
	Nonce [24]byte
}

func ConstructSecureMessage

func ConstructSecureMessage(sm []byte) SecureMessage

Jump to

Keyboard shortcuts

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