Giter Site home page Giter Site logo

mojo-tftpd's Introduction

NAME

Mojo::TFTPd - Trivial File Transfer Protocol daemon

VERSION

0.01

SYNOPSIS

use Mojo::TFTPd;
my $tftpd = Mojo::TFTPd->new;

$tftpd->on(error => sub {
    warn "TFTPd: $_[1]\n";
});

$tftpd->on(rrq => sub {
    my($tftpd, $c) = @_;
    open my $FH, '<', $c->file;
    $c->filehandle($FH);
});

$tftpd->on(wrq => sub {
    my($tftpd, $c) = @_;
    open my $FH, '>', '/dev/null';
    $c->filehandle($FH);
});

$self->on(finish => sub {
    my($tftpd, $c, $error) = @_;
    warn "Connection: $error\n" if $error;
});

$tftpd->start;
$tftpd->ioloop->start unless $tftpd->ioloop->is_running;

DESCRIPTION

This module implement a server for the Trivial File Transfer Protocol.

From Wikipedia:

Trivial File Transfer Protocol (TFTP) is a file transfer protocol notable
for its simplicity. It is generally used for automated transfer of
configuration or boot files between machines in a local environment.

The connection ($c) which is referred to in this document is an instance of Mojo::TFTPd::Connection.

EVENTS

error

$self->on(error => sub {
    my($self, $str) = @_;
});

This event is emitted when something goes wrong: Fail to "listen" to socket, read from socket or other internal errors.

finish

$self->on(finish => sub {
    my($self, $c, $error) = @_;
});

This event is emitted when the client finish, either successfully or due to an error. $error will be an empty string on success.

rrq

$self->on(rrq => sub {
    my($self, $c) = @_;
});

This event is emitted when a new read request arrives from a client. The callback should set "filehandle" in Mojo::TFTPd::Connection or the connection will be dropped.

wrq

$self->on(wrq => sub {
    my($self, $c) = @_;
});

This event is emitted when a new write request arrives from a client. The callback should set "filehandle" in Mojo::TFTPd::Connection or the connection will be dropped.

ATTRIBUTES

ioloop

Holds an instance of Mojo::IOLoop.

listen

$str = $self->server;
$self->server("127.0.0.1:69");
$self->server("tftp://*:69"); # any interface

The bind address for this server.

max_connections

How many concurrent connections this server can handle. Default to 1000.

retries

How many times the server should try to send ACK or DATA to the client before dropping the connection.

inactive_timeout

How long a connection can stay idle before

METHODS

start

Starts listening to the address and port set in "Listen". The "error" event wille be emitted if the server fail to start.

AUTHOR

Jan Henning Thorsen - [email protected]

mojo-tftpd's People

Contributors

zltyfsh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.