Versions in this module Expand all Collapse all v1 v1.0.0 Mar 6, 2017 Changes in this version + const ErrCodeAccessViolation + const ErrCodeDiskFull + const ErrCodeFileAlreadyExists + const ErrCodeFileNotFound + const ErrCodeIllegalOperation + const ErrCodeNoSuchUser + const ErrCodeNotDefined + const ErrCodeUnknownTransferID + const ModeNetASCII + const ModeOctet + var ErrAddressNotAvailable = errors.New("address not available until server has been started") + var ErrInvalidBlocksize = errors.New("invalid blocksize: must be between 8 and 65464") + var ErrInvalidFile = errors.New("invalid file") + var ErrInvalidHostIP = errors.New("invalid host/IP") + var ErrInvalidMode = errors.New("invalid transfer mode: must be ModeNetASCII or ModeOctet") + var ErrInvalidNetwork = errors.New("invalid network: must be udp, udp4, or udp6") + var ErrInvalidRetransmit = errors.New("invalid retransmit: cannot be negative") + var ErrInvalidTimeout = errors.New("invalid timeout: must be between 1 and 255") + var ErrInvalidURL = errors.New("invalid URL") + var ErrInvalidWindowsize = errors.New("invalid windowsize: must be between 1 and 65535") + var ErrMaxRetries = errors.New("max retries reached") + var ErrNoRegisteredHandlers = errors.New("no handlers registered") + var ErrSizeNotReceived = errors.New("size not received") + func ErrorCause(err error) error + func IsOptionParsingError(err error) bool + func IsRemoteError(err error) bool + func IsUnexpectedDatagram(err error) bool + type Client struct + func NewClient(opts ...ClientOpt) (*Client, error) + func (c *Client) Get(url string) (*Response, error) + func (c *Client) Put(url string, r io.Reader, size int64) (err error) + type ClientOpt func(*Client) error + func ClientBlocksize(size int) ClientOpt + func ClientMode(mode TransferMode) ClientOpt + func ClientRetransmit(i int) ClientOpt + func ClientTimeout(seconds int) ClientOpt + func ClientTransferSize(enable bool) ClientOpt + func ClientWindowsize(window int) ClientOpt + type ErrorCode uint16 + func (e ErrorCode) String() string + type ReadHandler interface + ServeTFTP func(ReadRequest) + type ReadHandlerFunc func(ReadRequest) + func (h ReadHandlerFunc) ServeTFTP(w ReadRequest) + type ReadRequest interface + Addr func() *net.UDPAddr + Name func() string + TransferMode func() TransferMode + Write func([]byte) (int, error) + WriteError func(ErrorCode, string) + WriteSize func(int64) + type ReadWriteHandler interface + func FileServer(dir string) ReadWriteHandler + type Response struct + func (r *Response) Read(p []byte) (int, error) + func (r *Response) Size() (int64, error) + type Server struct + func NewServer(addr string, opts ...ServerOpt) (*Server, error) + func (s *Server) Addr() (*net.UDPAddr, error) + func (s *Server) Close() error + func (s *Server) Connected() bool + func (s *Server) ListenAndServe() error + func (s *Server) ReadHandler(rh ReadHandler) + func (s *Server) Serve(conn *net.UDPConn) error + func (s *Server) WriteHandler(wh WriteHandler) + type ServerOpt func(*Server) error + func ServerNet(net string) ServerOpt + func ServerRetransmit(i int) ServerOpt + func ServerSinglePort(enable bool) ServerOpt + type TransferMode string + type WriteHandler interface + ReceiveTFTP func(WriteRequest) + type WriteHandlerFunc func(WriteRequest) + func (h WriteHandlerFunc) ReceiveTFTP(w WriteRequest) + type WriteRequest interface + Addr func() *net.UDPAddr + Name func() string + Read func([]byte) (int, error) + Size func() (int64, error) + TransferMode func() TransferMode + WriteError func(ErrorCode, string)