tftp2

package module
v0.0.0-...-190c0eb Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2019 License: BSD-3-Clause Imports: 12 Imported by: 0

README

tftp2

A clean TFTP implementation in Golang using the standard library.

Documentation

Overview

Package tftp2 implements the Trivial File Transfer Protocol as defined in RFC 1350.

Package tftp2 implements the Trivial File Transfer Protocol as defined in RFC 1350.

Package tftp2 implements the Trivial File Transfer Protocol as defined in RFC 1350.

Package tftp2 implements the Trivial File Transfer Protocol as defined in RFC 1350.

Index

Constants

This section is empty.

Variables

View Source
var ErrServerClosed = errors.New("tftp: Server closed")

ErrServerClosed is returned by the Server's serve and ListenAndServe methods after a call to Shutdown or Close.

View Source
var (
	// ServerContextKey is a context key. It can be used in TFTP
	// handlers with context.WithValue to access the server that
	// started the handler. The associated value will be of
	// type *Server. TODO: Design - What is my equivalent of an srv.Handler?
	ServerContextKey = &contextKey{"tftp-server"}
)

Functions

func ListenAndServe

func ListenAndServe(root string) error

ListenAndServe listens on the UDP network at address ":tftp" and then serves requests on incoming connections from the path at root.

ListenAndServe always returns a non-nil error.

Types

type Server

type Server struct {
	Addr string // Addr is the UDP address to listen on, ":tftp" if empty.

	Root string // Root is the path to the directory in the Operating System which holds the files to be served.

	// IdleTimeout is the maximum amount of time to wait for the
	// next packet from a client connection. The connection's
	// deadline is reset after sending a packet to the client.
	// The default value is 5 seconds.
	IdleTimeout time.Duration // Go 1.8

	// ErrorLog specifies an optional logger for errors accepting
	// connections, unexpected behavior from handlers, and
	// underlying FileSystem errors.
	// If nil, logging is done via the log package's standard logger.
	ErrorLog *log.Logger // Go 1.3
	// contains filtered or unexported fields
}

Server defines parameters for running a TFTP server. The zero value for Server is a valid configuration.

func (*Server) Close

func (srv *Server) Close() error

func (*Server) ListenAndServe

func (srv *Server) ListenAndServe() error

ListenAndServe listens on the UDP network address srv.Addr and then calls Serve to handle requests on incoming connections.

If srv.Addr is blank, ":tftp" is used.

ListenAndServe always returns a non-nil error. After Shutdown or Close, the returned error is ErrServerClosed.

Jump to

Keyboard shortcuts

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