Giter Club home page Giter Club logo

tftp4j's Introduction

tftp4j

A Java TFTP server and protocol handler.

This code originally came from a variety of third party open source projects, and the objective is to give it a complete overhaul into a modern, correct and complete TFTP implementation.

The JavaDoc API is available.

tftp4j's People

Contributors

shevek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tftp4j's Issues

How to upload file to tftp4j?

Hello! I run a tftp4j on centOS 7 and now can download file from it. But everytime I upload file to tftp4j by tftpd64, tftpd64 appears warning 'access violation'. I chmod 777 the directory and file, but the issue is still here. Maybe should I excute some codes to open upload feature of tftp4j?

RFC2347 complience

Clients like u-boot try to use the RFC2347 (https://tools.ietf.org/html/rfc2347) TFTP option extensions to request a blksize larger than 512 so as to improve network utilization. This is an extension to the revised TFTP RFC1350 (https://tools.ietf.org/html/rfc1350).

If the client wants to negotiate options, they can append the desired options to the RRQ packet.

The possible responses and scenarios are then:

When the client appends options to the end of a Read Request packet,
   three possible responses may be returned by the server:

      OACK  - acknowledge of Read Request and the options;

      DATA  - acknowledge of Read Request, but not the options;

      ERROR - the request has been denied.

It is incorrect to respect requested options without sending the appropriate OACK packet. Respecting the blksize option without acknowledging the option is misnegotiation between the server and client.

This leads to transfer issues between the client and server depending on how large the payload is.

The quick fix is to not update the blocksize, until OACK support has been added.

Possible connection leak

A read timeout would prevent possibly leaking a UDP connection when the client does not successfully complete the transfer. If you leak enough you can start to impact other services like DNS when the system runs out of available UDP ports.

protected void initChannel(Channel ch) throws Exception {
// LOG.info("Initialize " + this);
ChannelPipeline pipeline = ch.pipeline();
// pipeline.addLast(sharedHandlers.exceptionHandler);
// if (sharedHandlers.debug) pipeline.addLast(sharedHandlers.wireLogger);
pipeline.addLast(sharedHandlers.codec);
if (sharedHandlers.debug)
pipeline.addLast(sharedHandlers.packetLogger);
pipeline.addLast(handler);

ClosedChannelException using GET command

Hello,

When trying to use the TFTPServer class from the org.anarres.tftp.server.netty package, I got an error when trying to GET a file using the standard MacOs tftp client:

TftpServer server = new TftpServer(new TftpFileChannelDataProvider("/tmp/tftp"), 8889);
server.start();

The client:

ABR:~ abaudoux$ tftp localhost 8889
tftp> get /test.docx
Received 4598694 bytes in 0.3 seconds
tftp> 

The document is not correctly transferred.

Here is the stackTrace:

15:59:53.381 [tftp-server-1-1] WARN  o.a.t.p.e.AbstractTftpReadTransfer - org.anarres.tftp.server.netty.TftpReadTransfer@5e560bad: Retry 1 of packet 8981
15:59:53.382 [tftp-server-1-1] ERROR o.a.t.s.netty.TftpTransferHandler - Error on channel: java.nio.channels.ClosedChannelException
java.nio.channels.ClosedChannelException: null
    at sun.nio.ch.FileChannelImpl.ensureOpen(FileChannelImpl.java:94) ~[na:1.8.0]
    at sun.nio.ch.FileChannelImpl.read(FileChannelImpl.java:673) ~[na:1.8.0]
    at org.anarres.tftp.protocol.resource.TftpFileChannelData.read(TftpFileChannelData.java:33) ~[tftp-protocol-1.0.3.jar:1.0.3]
    at org.anarres.tftp.protocol.engine.AbstractTftpReadTransfer.newPacket(AbstractTftpReadTransfer.java:71) ~[tftp-protocol-1.0.3.jar:1.0.3]
    at org.anarres.tftp.protocol.engine.AbstractTftpReadTransfer.ack(AbstractTftpReadTransfer.java:114) ~[tftp-protocol-1.0.3.jar:1.0.3]
    at org.anarres.tftp.protocol.engine.AbstractTftpReadTransfer.timeout(AbstractTftpReadTransfer.java:149) ~[tftp-protocol-1.0.3.jar:1.0.3]
    at org.anarres.tftp.server.netty.TftpTransferHandler.channelInactive(TftpTransferHandler.java:48) ~[tftp-server-netty-1.0.3.jar:1.0.3]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:233) [netty-all-4.0.23.Final.jar:4.0.23.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:219) [netty-all-4.0.23.Final.jar:4.0.23.Final]
    at io.netty.channel.ChannelInboundHandlerAdapter.channelInactive(ChannelInboundHandlerAdapter.java:75) [netty-all-4.0.23.Final.jar:4.0.23.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:233) [netty-all-4.0.23.Final.jar:4.0.23.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:219) [netty-all-4.0.23.Final.jar:4.0.23.Final]
    at io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:769) [netty-all-4.0.23.Final.jar:4.0.23.Final]
    at io.netty.channel.AbstractChannel$AbstractUnsafe$5.run(AbstractChannel.java:567) [netty-all-4.0.23.Final.jar:4.0.23.Final]
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:380) [netty-all-4.0.23.Final.jar:4.0.23.Final]
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357) [netty-all-4.0.23.Final.jar:4.0.23.Final]
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) [netty-all-4.0.23.Final.jar:4.0.23.Final]
    at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137) [netty-all-4.0.23.Final.jar:4.0.23.Final]
    at java.lang.Thread.run(Thread.java:744) [na:1.8.0]

Any clue on why I got this error?

Thanks,
Antoine

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.