tftp

package module
v0.0.0-...-ffd942c Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

README

tftp-go

TFTP server implementation in Go.

Usage

For an example server implementation, see the example directory.

This server provides read/write access to $PWD.

To run the server (from the example directory):

$ go build main.go
$ echo "Hello world!" > file
$ sudo ./main

To access the server with curl (for example):

$ curl tftp://localhost/file
Hello world!

Notes

A client implementation could easily be built on top since the packet serialization/deserialization is in place and not tied to either the server or the client side. If you're looking to build this feature, let us know through an issue on GitHub, or directly with a pull request for this functionality.

RFCs

Other RFCs are informational or obsoleted by newer versions.

  • 1350: THE TFTP PROTOCOL (REVISION 2)
  • 2347: TFTP Option Extension
  • 2348: TFTP Blocksize Option
  • 2349: TFTP Timeout Interval and Transfer Size Options

License

This project is available under the Apache 2.0 license.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTimeout = errors.New("timeout")

ErrTimeout is returned by the packetReader when it times out reading a packet.

View Source
var ZeroConn = newZeroConn()

ZeroConn can be used as a placeholder if otherwise not known.

Functions

func ListenAndServe

func ListenAndServe(addr string, h Handler) error

func Serve

func Serve(l net.PacketConn, h Handler) error

Types

type Conn

type Conn interface {
	LocalAddr() net.Addr
	RemoteAddr() net.Addr
}

Conn provides context about the current "connection".

type Handler

type Handler interface {
	ReadFile(c Conn, filename string) (ReadCloser, error)
	WriteFile(c Conn, filename string) (WriteCloser, error)
}

Handler is the interface a consumer of this library needs to implement to be able to serve TFTP requests.

type ReadCloser

type ReadCloser interface {
	io.ReadCloser
}

ReadCloser is what the Handler needs to implement to serve TFTP read requests.

type WriteCloser

type WriteCloser interface {
	io.WriteCloser
}

WriteCloser is what the Handler needs to implement to serve TFTP write requests.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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