func (s *Server) SetBlockSize(i int) {
	if i > 512 && i < 65465 {
		s.maxBlockLen = i
	}
}
SetBlockSize sets the maximum size of an individual data block.
This must be a value between 512 (the default block size for TFTP)
and 65456 (the max size a UDP packet payload can be).

This is an advisory value -- it will be clamped to the smaller of
the block size the client wants and the MTU of the interface being
communicated over munis overhead.
package tftp
import (
	"fmt"
	"io"
	"net"
	"sync"
	"time"
	"golang.org/x/net/ipv4"
	"golang.org/x/net/ipv6"
)
func NewServer(readHandler func(filename string, rf io.ReaderFrom) error,
	writeHandler func(filename string, wt io.WriterTo) error) *Server {
	s := &Server{
		timeout:           defaultTimeout,
		retries:           defaultRetries,
		runGC:             make(chan []string),
		gcThreshold:       100,
		packetReadTimeout: 100 * time.Millisecond,
		readHandler:       readHandler,
		writeHandler:      writeHandler,
	}
	return s
}
type RequestPacketInfo interface {
	LocalIP() net.IP
}
type Server struct {
	readHandler  func(filename string, rf io.ReaderFrom) error
	writeHandler func(filename string, wt io.WriterTo) error
	hook         Hook
	backoff      backoffFunc
	conn         net.PacketConn
	conn6        *ipv6.PacketConn
	conn4        *ipv4.PacketConn
	quit         chan chan struct{}
	wg           sync.WaitGroup
	timeout      time.Duration
	retries      int
	maxBlockLen  int
	sendAEnable  bool  
	sendAWinSz   uint
	singlePort        bool
	bufPool           sync.Pool
	handlers          map[string]chan []byte
	runGC             chan []string
	gcCollect         chan string
	gcThreshold       int
	packetReadTimeout time.Duration
}
type TransferStats struct {
	RemoteAddr              net.IP
	Filename                string
	Tid                     int
	SenderAnticipateEnabled bool
	Mode                    string
	Opts                    options
	Duration                time.Duration
	DatagramsSent           int
	DatagramsAcked          int
}
type Hook interface {
	OnSuccess(stats TransferStats)
	OnFailure(stats TransferStats, err error)
}
func (s *Server) SetAnticipate(winsz uint) {
	if winsz > 1 {
		s.sendAEnable = true
		s.sendAWinSz = winsz
	} else {
		s.sendAEnable = false
		s.sendAWinSz = 1
	}
}
func (s *Server) SetHook(hook Hook) {
	s.hook = hook
}
func (s *Server) EnableSinglePort() {
	s.singlePort = true
	s.handlers = make(map[string]chan []byte)
	s.gcCollect = make(chan string)
	if s.maxBlockLen == 0 {
		s.maxBlockLen = blockLength
	}
	s.bufPool = sync.Pool{
		New: func() interface{} {
			return make([]byte, s.maxBlockLen+4)
		},
	}
	go s.internalGC()
}
func (s *Server) SetTimeout(t time.Duration) {
	if t <= 0 {
		s.timeout = defaultTimeout
	} else {
		s.timeout = t
	}
}