{"id":17306525,"url":"https://github.com/jhthorsen/poe-component-tftpd","last_synced_at":"2025-07-31T13:32:50.375Z","repository":{"id":488250,"uuid":"114375","full_name":"jhthorsen/poe-component-tftpd","owner":"jhthorsen","description":"A tftp-server, implemented as a POE component","archived":false,"fork":false,"pushed_at":"2013-11-20T06:30:43.000Z","size":157,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-16T11:58:42.714Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://search.cpan.org/dist/POE-Component-TFTPd/","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jhthorsen.png","metadata":{"files":{"readme":"README","changelog":"Changes","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-01-25T15:08:10.000Z","updated_at":"2019-08-13T13:56:04.000Z","dependencies_parsed_at":"2022-07-17T00:16:11.038Z","dependency_job_id":null,"html_url":"https://github.com/jhthorsen/poe-component-tftpd","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhthorsen%2Fpoe-component-tftpd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhthorsen%2Fpoe-component-tftpd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhthorsen%2Fpoe-component-tftpd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhthorsen%2Fpoe-component-tftpd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jhthorsen","download_url":"https://codeload.github.com/jhthorsen/poe-component-tftpd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228250848,"owners_count":17891701,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T11:58:41.101Z","updated_at":"2024-12-05T07:21:32.038Z","avatar_url":"https://github.com/jhthorsen.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"NAME\n    POE::Component::TFTPd - A tftp-server, implemented through POE\n\nVERSION\n    0.0301\n\nSYNOPSIS\n     POE::Session-\u003ecreate(\n         inline_states =\u003e {\n             _start        =\u003e sub {\n                 POE::Component::TFTPd-\u003ecreate;\n                 $_[KERNEL]-\u003epost($alias =\u003e 'start');\n             },\n             tftpd_init    =\u003e sub {\n                 my($client, $fh) = ($_[ARG0], undef);\n                 open($fh, \"\u003c\", $client-\u003efilename) if($client-\u003errq);\n                 open($fh, \"\u003e\", $client-\u003efilename) if($client-\u003ewrq);\n                 $client-\u003e{'fh'} = $fh;\n             },\n             tftpd_done    =\u003e sub {\n                 my $client = $_[ARG0];\n                 close $client-\u003e{'fh'};\n             },\n             tftpd_send    =\u003e sub {\n                 my $client = $_[ARG0];\n                 read $client-\u003e{'fh'}, my $data, $client-\u003eblock_size;\n                 $_[KERNEL]-\u003epost($alias =\u003e send_data =\u003e $client, $data);\n             },\n             tftpd_receive =\u003e sub {\n                 my($client, $data) = @_[ARG0,ARG1];\n                 print { $client-\u003e{'fh'} } $data;\n                 $_[KERNEL]-\u003epost($alias =\u003e send_ack =\u003e $client);\n             },\n             tftpd_log     =\u003e sub {\n                 my($level, $client, $msg) = @_[ARG0..ARG2];\n                 warn(sprintf \"%s - %s:%i - %s\\n\",\n                     $level, $client-\u003eaddress, $client-\u003eport, $msg,\n                 );\n             },\n         },\n     );\n\nMETHODS\n  create(%args)\n    Component constructor.\n\n    Args:\n\n     Name        =\u003e default   # Comment\n     --------------------------------------------------------------------\n     alias       =\u003e TFTPd     # Alias for the POE session\n     address     =\u003e 127.0.0.1 # Address to listen to\n     port        =\u003e 69        # Port to listen to\n     timeout     =\u003e 10        # Seconds between block sent and ACK\n     retries     =\u003e 3         # How many retries before giving up on host\n     max_clients =\u003e undef     # Maximum concurrent connections\n\n  clients\n    Returns a hash-ref, containing all the clients:\n\n     $client_id =\u003e $client_obj\n\n    See \"POE::Component::TFTPd::Client\" for details\n\n  max_clients\n    Pointer to max number of concurrent clients:\n\n     print $self-\u003emax_clients;\n     $self-\u003emax_clients = 4;\n\n  retries\n    Pointer to the number of retries:\n\n     print $self-\u003eretries;\n     $self-\u003eretries = 4;\n\n  timeout\n    Pointer to the timeout in seconds:\n\n     print $self-\u003etimeout;\n     $self-\u003etimeout = 4;\n\n  address\n    Returns the address the server listens to.\n\n  alias\n    The alias for the POE session.\n\n  kernel\n    Method alias for $_[KERNEL].\n\n  port\n    Returns the local port\n\n  sender\n    Returns the sender session.\n\n  server\n    Returns the server: \"POE::Wheel::UDP\".\n\n  session\n    Returns this session.\n\n  cleanup\n     1. Logs that the server is done with the client\n     2. deletes the client from C\u003c$self-E\u003cgt\u003eclients\u003e\n     3. Calls C\u003ctftpd_done\u003e event in sender session\n\n  log\n    Calls SENDER with event name 'tftpd_log' and these arguments:\n\n      $_[ARG0] = $level\n      $_[ARG1] = $client\n      $_[ARG2] = $msg\n\n    $level is the same as \"Log::Log4perl\" use.\n\nSTATES\n  start\n    Starts the server, by setting up \"POE::Wheel::UDP\".\n\n  stop\n    Stops the TFTPd server, by deleting the UDP wheel.\n\n  check_connections\n    Checks for connections that have timed out, and destroys them. This is\n    done periodically, every second.\n\n  input\n    Takes some input, figure out the opcode and pass the request on to the\n    next stage.\n\n     opcode | event    | method\n     -------|----------|-------------\n     rrq    | init_rrq | init_request\n     wrq    | init_wrq | init_request\n     ack    | get_ack  | get_data\n     data   | get_data | get_data\n\n  send_data =\u003e $client, $data\n    Sends data to the client. Used for both ACK and DATA. It resends data\n    automatically on failure, and decreases \"$client-\u003eretries\".\n\n  get_data =\u003e $client, $data\n    Handles both ACK and DATA packets.\n\n    If correct packet-number:\n\n     1. Logs the packet number\n     2. Calls C\u003ctftpd_receive\u003e / C\u003ctftpd_send\u003e in sender session\n\n    On failure:\n\n     1. Logs failure\n     2. Resends the last packet\n\n  init_request =\u003e $args, $opcode, $data\n     1. Checks if max_clients limit is reached. If not, sets up\n\n      $client-\u003efilename  = $file;    # the filename to read/write\n      $client-\u003emode      = uc $mode; # only OCTET is valid\n      $client-\u003erfc       = [ ... ];\n      $client-\u003etimestamp = time;\n\n     2. Calls C\u003ctftpd_init\u003e in sender session.\n\n     3. Calls C\u003ctftpd_send\u003e in sender session, if read-request from client\n\n  send_error =\u003e $client, $error_key [, $args]\n    Sends an error to the client.\n\n     $error_key referes to C\u003c%TFTP_ERROR\u003e\n     $args is an array ref that can be used to replace %x in the error string\n\nFUNCTIONS\n  TFTP_MIN_BLKSIZE\n  TFTP_MAX_BLKSIZE\n  TFTP_MIN_TIMEOUT\n  TFTP_MAX_TIMEOUT\n  TFTP_DEFAULT_PORT\n  TFTP_OPCODE_RRQ\n  TFTP_OPCODE_WRQ\n  TFTP_OPCODE_DATA\n  TFTP_OPCODE_ACK\n  TFTP_OPCODE_ERROR\n  TFTP_OPCODE_OACK\nAUTHOR\n    Jan Henning Thorsen, \"\u003cjhthorsen-at-cpan-org\u003e\"\n\nCOPYRIGHT \u0026 LICENSE\n    Copyright 2007 Jan Henning Thorsen, all rights reserved.\n\n    This program is free software; you can redistribute it and/or modify it\n    under the same terms as Perl itself.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjhthorsen%2Fpoe-component-tftpd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjhthorsen%2Fpoe-component-tftpd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjhthorsen%2Fpoe-component-tftpd/lists"}