Documentation ¶
Index ¶
Constants ¶
View Source
const ( RRQ OpcodeClient = 1 WRQ OpcodeClient = 2 OACKFileTooLarge OpcodeClient = 3 ACK OpcodeClient = 4 ClientError OpcodeClient = 5 OACKDeclined OpcodeClient = 8 DATA OpcodeServer = 3 ServerError OpcodeServer = 5 OACK OpcodeServer = 6 )
View Source
const ( FilepathFieldIndex int = 0 ModeFieldIndex int = 1 FirstOptionFieldIndex int = 2 )
View Source
const ( ReadBufferSize = 1024 OpcodeLength = 2 BlocknumLength = 2 MetaInfoSize = OpcodeLength + BlocknumLength DefaultBlocksize = 512 DefaultTransfersize = -1 // modes ModeOctet = "octet" ModeNetAscii = "netascii" Octet = 1 NetAscii = 2 OptionBlksize = "blksize" OptionTsize = "tsize" )
View Source
const ( OK ackValue = iota Retransmit Error Failure )
View Source
const (
OACKBlockNumber = 0
)
Variables ¶
View Source
var ( GitTag = "v0.0.0" GitCommit = "local" BuildTime = "1970-01-01T00:00:00Z" )
View Source
var ( FileErrors = struct { ErrNoHandler error ErrInsecure error ErrReadFile error ErrPermission error ErrNotFound error }{ ErrNoHandler: errors.New("no handler found for file"), ErrInsecure: errors.New("file path was not valid"), ErrReadFile: errors.New("error during read of file"), ErrPermission: errors.New("insufficient permission to read file"), ErrNotFound: errors.New("file not found"), } )
View Source
var NullByte = []byte{0}
View Source
var ( ReceiveError = struct { ErrDeclinedByClient error ErrFileTooLarge error ErrClient error ErrWeirdBlocknum error ErrWeirdOpcode error }{ ErrDeclinedByClient: errors.New("oack was declined by the client"), ErrFileTooLarge: errors.New("file was too large for client"), ErrClient: errors.New("received error from client"), ErrWeirdBlocknum: errors.New("received unexpected blocknum from client"), ErrWeirdOpcode: errors.New("client sent unexpected opcode"), } )
View Source
var ( RequestErrors = struct { ErrUnknownOpcode error ErrUnknownMode error ErrUnknownOption error ErrInvalidBlksize error ErrInvalidTransfersize error ErrMalformed error }{ ErrUnknownOpcode: errors.New("unknown opcode in request"), ErrUnknownMode: errors.New("unknown mode in request"), ErrUnknownOption: errors.New("unknown option in request"), ErrInvalidBlksize: errors.New("invalid blocksize in request"), ErrInvalidTransfersize: errors.New("invalid transfersize in request"), ErrMalformed: errors.New("received malformed request"), } )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { IP string Port int Retransmissions int MaxParallelConnections int FileTransferTimeout time.Duration WriteTimeout time.Duration ReadTimeout time.Duration Metrics metrics.Config }
func (Config) ReadTimeoutOrDefault ¶ added in v2.0.6
func (Config) WriteTimeoutOrDefault ¶ added in v2.0.6
type ErrorCode ¶
type ErrorCode uint16
const ( // Error codes // http://tools.ietf.org/html/rfc1350#page-10 UnknownError ErrorCode = iota // Not defined, see error message (if any). NotFound // File not found. AccessViolation // Access violation. DiskFull // Disk full or allocation exceeded. IllegalOperation // Illegal TFTP operation. UnknownID // Unknown transfer ID. AlreadyExists // File already exists. NoSuchUser // No such user. )
type OpcodeClient ¶
type OpcodeClient uint16
func (OpcodeClient) Is ¶
func (oc OpcodeClient) Is(other OpcodeClient) bool
func (OpcodeClient) String ¶
func (o OpcodeClient) String() string
func (OpcodeClient) Value ¶
func (o OpcodeClient) Value() uint16
type OpcodeServer ¶
type OpcodeServer uint16
func (OpcodeServer) String ¶
func (o OpcodeServer) String() string
func (OpcodeServer) Value ¶
func (o OpcodeServer) Value() uint16
type RRQParseError ¶
type RRQParseError struct {
// contains filtered or unexported fields
}
func (*RRQParseError) Error ¶
func (e *RRQParseError) Error() string
type Request ¶
type Request struct { Opcode OpcodeClient Blocksize int TransferSize int64 Mode int Path string ClientAddress *net.UDPAddr }
func (*Request) SetOptions ¶
type ResponseHandling ¶
type ResponseHandling interface { RegisterHandler(handler Handler) OpenFile(ctx context.Context, file string) (io.ReadCloser, int64, error) }
func NewResponseHandling ¶
func NewResponseHandling(logger logging.Logger) ResponseHandling
Click to show internal directories.
Click to hide internal directories.