tftp

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2021 License: MIT Imports: 12 Imported by: 0

README

GoDoc

TFTP-Server Implentierung in Go

Gibt zwar schon einige, aber ich wollte mal ein Protokol selbst umsetzen und dabei gleich mal Go ausprobieren.

Die Implentierung konzentriert sich auf den Server und sollte ACLs bereistellen mit denen man eine Client IP einem Verzeichnis zuordnen kann.

Der Server funktioniert soweit. Was noch fehlt ist das Retransmit von nicht geACKten Paketen und eine Implementierung von Timeouts.

Status: Work in Progress

  • WRQ (mode netascii entfernt \r)
  • RRQ ohne Beachtung von mide netascii
  • ACL für RRQ und WRQ

RFCs

  • RFC1350
  • RFC2348
  • RFC2348

Documentation

Overview

Package tftp implents a TFTP server RFC1350 and also RFC2348 and RFC2348 It also has a simple ACL for clients to allow or disallow Read/Write requests and give an own directory for Read/Write request

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(addr, rootdir string) error

ListenAndServe starts UDP socket and waits for client first packet

Types

type ACL

type ACL struct {
	Write    bool
	Read     bool
	ReadDir  string
	WriteDir string
}

ACL ist the ACL for one client

type Client

type Client struct {
	Addr *net.UDPAddr
	Conn *net.UDPConn

	BlockSize   int
	TimeOut     int
	Tsize       uint16
	BlockNumber uint16
	Options     map[string][]byte
	Databuf     []byte
	ReadDir     string
	WriteDir    string
	// contains filtered or unexported fields
}

Client holds info from one client

func (*Client) Close

func (c *Client) Close()

Close closes UDP Connection

func (*Client) NewTransfer

func (c *Client) NewTransfer(filename, mode string) error

NewTransfer starts a new transfer from client WRQ

func (*Client) SendFile

func (c *Client) SendFile(filename, mode string) error

SendFile sends file to client answer to RRQ Request

type TServer

type TServer struct {
	ACLs        map[*net.IPNet]*ACL
	DefWrite    bool
	DefWriteDir string
	DefRead     bool
	DefReadDir  string
	// contains filtered or unexported fields
}

TServer struct holds info from Server

func NewServer

func NewServer(netw, addr, rootdir, defaultreaddir, defaultwritedir string, defread, defwrite bool) (*TServer, error)

NewServer initalize an TServer

func (*TServer) AddACL

func (ts *TServer) AddACL(hostornet string, write, read bool, writedir, readdir string) error

AddACL adds an ACL entry to the server ACL

func (*TServer) AddACLStruct

func (ts *TServer) AddACLStruct(hostornet string, acl *ACL) error

AddACLStruct adds acl struct directly

func (TServer) CheckClient

func (ts TServer) CheckClient(opcode uint16, caddr *net.UDPAddr) (bool, string)

CheckClient checks client address against ACL-map returns true when client is allowed false otherwise

func (*TServer) DelACL

func (ts *TServer) DelACL(hostornet string) error

DelACL deletes a ACL entry

func (*TServer) Serve

func (ts *TServer) Serve() error

Serve opens port and waits for connections

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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