Giter Club home page Giter Club logo

fbtftp's People

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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fbtftp's Issues

How to reject client request with ERR_FILE_NOT_FOUND?

Hello, first off thanks for the great project!

I'm having trouble figuring out what the best way to respond to a client w/ ERR_FILE_NOT_FIND (error 1) . Would this be done as part of the server's get_handler()? Of the handler's get_response_data()? The handler has a private method _transmit_error() which would seem to be useful, but it appears to only be intended to be called by fbtftp internals?

Any pointers will be helpful. Thanks!

SyntaxError when running the example in readme

Hi,
I'm running into an issue when trying to run the example server that is displayed in the repo's readme.

I have made no changes to the code so is word for word from the repo.

OS: CentOS 7

[root@webnettftp fbtftp]# python3 webnetTFTP.py
File "webnetTFTP.py", line 51
root='/var/tftproot', print_session_stats,
SyntaxError: positional argument follows keyword argument

Thanks,
Cameron

TypeError: object of type 'NoneType' has no len() in fmt = '!HH%ds' % len(self._current_block)

python3.4
Centos6.10

Process StaticHandler-1:
Traceback (most recent call last):
  File "/usr/lib/python3.4/multiprocessing/process.py", line 254, in _bootstrap
    self.run()
  File "/tmp/autotftp/.local/lib/python3.4/site-packages/fbtftp/base_handler.py", line 259, in run
    self.run_once()
  File "/tmp/autotftp/.local/lib/python3.4/site-packages/fbtftp/base_handler.py", line 272, in run_once
    self._handle_timeout()
  File "/tmp/autotftp/.local/lib/python3.4/site-packages/fbtftp/base_handler.py", line 350, in _handle_timeout
    self._transmit_data()
  File "/tmp/autotftp/.local/lib/python3.4/site-packages/fbtftp/base_handler.py", line 396, in _transmit_data
    fmt = '!HH%ds' % len(self._current_block)
TypeError: object of type 'NoneType' has no len()

MacOS support

Problem with MacOS.
OS: 64bit Mac OS X 10.12.6 16G29

self._epoll = select.epoll()
AttributeError: module 'select' has no attribute 'epoll'

Module select doesn't have epoll method. I want to try to fix this with another way.

It's critical or not?

Thanks

Consider removing Python 2 compatibility code

Hello,

README says:

fbtftp is written in python3 [...]

and lists Python 3.x as a requirement at https://github.com/facebook/fbtftp#requirements. setup.py also defines it as a Python 3 only project: https://github.com/facebook/fbtftp/blob/master/setup.py#L41

However, the code base has some code for Python 2 compatibility (__future__ imports, codecs.open, class Spam(object): etc.) and follows some old practices like https://github.com/facebook/fbtftp/blob/master/examples/server.py#L68.

Is there any Python 2 deployment out there (probably not since it will require the backport of ipaddress module) or can they be safely removed now? I can send a pull request if they are not needed now.

Thanks!

Release on PyPI

The project already has everything it needs to get published on PyPI, have you considered doing it?

Install error

The python3 setup.py build did not create build/lib/ folder and file.

So I got an error while I python3 setup.py install

2018-06-07 4 49 42

2018-06-07 4 29 57

thanks.

Only one retransmission after timeout.

In base_handler.py:
In the method "on_new_data" of BaseHandler.

def on_new_data(self):
        try:
            ......
            listener.settimeout(self._timeout)
            data, peer = listener.recvfrom(constants.DEFAULT_BLKSIZE)
            ......
        except socket.timeout:
            self._stats.error = {
                'error_code': constants.ERR_UNDEFINED,
                'error_message': 'timeout occurred on socket.recvfrom()',
            }
            self._should_stop = True     # the extra termination
            return

The extra "self._should_stop = True" will end current tftp session after doing only 1 retransmission.

FreeBSD compatibility

Hi guys,

Would it be on your interest to have BSD compatibility added to the framework?

If it's of interest to you, I will work on making it compatible with both BSD and Linux and send a PR.
I already have it BSD-only in my fork, so I figured it wouldn't be too much work to get both.

Pypi release new version

Hello, great project!

Would you please consider releasing a "0.2" version to pypi? There's been a number of fixes since the 0.1 release last year and it'd be a great help for us to be able to install from pypi directly.

Thanks!

Server is not working with Nvidia DGX

Hello,

I am deploying an Nvidia DGX system. Basically, with exact same configuration, fbtftp server fails while Ubuntu native tftpd-hpa works.

My current server is running Ubuntu 18.04, and I am deploying Ubuntu 20.04 on the DGX target.

While booting in PXE (in EFI), the DGX system gets the ip from dhcp, then tries to download a file from the fbtftp server, but it strangely fails.

Logs on server side with fbtftp server:

Aug 31 22:55:44 mngt01 python3[43123]: INFO:root:Server stats - every 60 seconds
Aug 31 22:55:44 mngt01 python3[43123]: DEBUG:root:Starting the metrics callback in 60s
Aug 31 22:56:20 mngt01 python3[43123]: INFO:root:New connection from peer `('::ffff:172.31.95.1', 1340, 0, 0)` asking for path `efi64/syslinux.efi`
Aug 31 22:56:20 mngt01 python3[43123]: INFO:root:Options requested from peer ('::ffff:172.31.95.1', 1340, 0, 0):  OrderedDict([('mode', 'octet'), ('tsize', '0'), ('blksize', '1468')])
Aug 31 22:56:20 mngt01 python3[43123]: INFO:root:Options to ack for peer ('::ffff:172.31.95.1', 1340, 0, 0):  OrderedDict([('tsize', '199952'), ('blksize', '1468')])
Aug 31 22:56:24 mngt01 python3[43123]: INFO:root:New connection from peer `('::ffff:172.31.95.1', 1340, 0, 0)` asking for path `efi64/syslinux.efi`
Aug 31 22:56:24 mngt01 python3[43123]: INFO:root:Options requested from peer ('::ffff:172.31.95.1', 1340, 0, 0):  OrderedDict([('mode', 'octet'), ('tsize', '0'), ('blksize', '1468')])
Aug 31 22:56:24 mngt01 python3[43123]: INFO:root:Options to ack for peer ('::ffff:172.31.95.1', 1340, 0, 0):  OrderedDict([('tsize', '199952'), ('blksize', '1468')])
Aug 31 22:56:28 mngt01 python3[43123]: INFO:root:New connection from peer `('::ffff:172.31.95.1', 1340, 0, 0)` asking for path `efi64/syslinux.efi`
Aug 31 22:56:28 mngt01 python3[43123]: INFO:root:Options requested from peer ('::ffff:172.31.95.1', 1340, 0, 0):  OrderedDict([('mode', 'octet'), ('tsize', '0'), ('blksize', '1468')])
Aug 31 22:56:28 mngt01 python3[43123]: INFO:root:Options to ack for peer ('::ffff:172.31.95.1', 1340, 0, 0):  OrderedDict([('tsize', '199952'), ('blksize', '1468')])
Aug 31 22:56:32 mngt01 python3[43123]: INFO:root:New connection from peer `('::ffff:172.31.95.1', 1340, 0, 0)` asking for path `efi64/syslinux.efi`
Aug 31 22:56:32 mngt01 python3[43123]: INFO:root:Options requested from peer ('::ffff:172.31.95.1', 1340, 0, 0):  OrderedDict([('mode', 'octet'), ('tsize', '0'), ('blksize', '1468')])
Aug 31 22:56:32 mngt01 python3[43123]: INFO:root:Options to ack for peer ('::ffff:172.31.95.1', 1340, 0, 0):  OrderedDict([('tsize', '199952'), ('blksize', '1468')])
Aug 31 22:56:34 mngt01 python3[43123]: ERROR:root:timeout after 6 retransmits.
Aug 31 22:56:34 mngt01 python3[43123]: INFO:root:Stats: for ('::ffff:172.31.95.1', 1340, 0, 0) requesting 'efi64/syslinux.efi'
Aug 31 22:56:34 mngt01 python3[43123]: INFO:root:Error: {'error_code': 0, 'error_message': 'timeout after 6 retransmits.'}
Aug 31 22:56:34 mngt01 python3[43123]: INFO:root:Time spent: 14021ms
Aug 31 22:56:34 mngt01 python3[43123]: INFO:root:Packets sent: 7
Aug 31 22:56:34 mngt01 python3[43123]: INFO:root:Packets ACKed: 0
Aug 31 22:56:34 mngt01 python3[43123]: INFO:root:Bytes sent: 0
Aug 31 22:56:34 mngt01 python3[43123]: INFO:root:Options: OrderedDict([('tsize', '199952'), ('blksize', '1468')])
Aug 31 22:56:34 mngt01 python3[43123]: INFO:root:Blksize: 1468
Aug 31 22:56:34 mngt01 python3[43123]: INFO:root:Retransmits: 6
Aug 31 22:56:34 mngt01 python3[43123]: INFO:root:Server port: 69
Aug 31 22:56:34 mngt01 python3[43123]: INFO:root:Client port: 1340
Aug 31 22:56:34 mngt01 python3[43123]: DEBUG:root:Closing response data object
Aug 31 22:56:34 mngt01 python3[43123]: DEBUG:root:Closing socket
Aug 31 22:56:34 mngt01 python3[43123]: DEBUG:root:Dying.
Aug 31 22:56:36 mngt01 python3[43123]: INFO:root:New connection from peer `('::ffff:172.31.95.1', 1340, 0, 0)` asking for path `efi64/syslinux.efi`
Aug 31 22:56:36 mngt01 python3[43123]: INFO:root:Options requested from peer ('::ffff:172.31.95.1', 1340, 0, 0):  OrderedDict([('mode', 'octet'), ('tsize', '0'), ('blksize', '1468')])
Aug 31 22:56:36 mngt01 python3[43123]: INFO:root:Options to ack for peer ('::ffff:172.31.95.1', 1340, 0, 0):  OrderedDict([('tsize', '199952'), ('blksize', '1468')])
Aug 31 22:56:38 mngt01 python3[43123]: ERROR:root:timeout after 6 retransmits.
Aug 31 22:56:38 mngt01 python3[43123]: INFO:root:Stats: for ('::ffff:172.31.95.1', 1340, 0, 0) requesting 'efi64/syslinux.efi'
Aug 31 22:56:38 mngt01 python3[43123]: INFO:root:Error: {'error_code': 0, 'error_message': 'timeout after 6 retransmits.'}
Aug 31 22:56:38 mngt01 python3[43123]: INFO:root:Time spent: 14019ms
Aug 31 22:56:38 mngt01 python3[43123]: INFO:root:Packets sent: 7
Aug 31 22:56:38 mngt01 python3[43123]: INFO:root:Packets ACKed: 0
Aug 31 22:56:38 mngt01 python3[43123]: INFO:root:Bytes sent: 0
Aug 31 22:56:38 mngt01 python3[43123]: INFO:root:Options: OrderedDict([('tsize', '199952'), ('blksize', '1468')])
Aug 31 22:56:38 mngt01 python3[43123]: INFO:root:Blksize: 1468
Aug 31 22:56:38 mngt01 python3[43123]: INFO:root:Retransmits: 6
Aug 31 22:56:38 mngt01 python3[43123]: INFO:root:Server port: 69
Aug 31 22:56:38 mngt01 python3[43123]: INFO:root:Client port: 1340
Aug 31 22:56:38 mngt01 python3[43123]: DEBUG:root:Closing response data object
Aug 31 22:56:38 mngt01 python3[43123]: DEBUG:root:Closing socket
Aug 31 22:56:38 mngt01 python3[43123]: DEBUG:root:Dying.
Aug 31 22:56:40 mngt01 python3[43123]: INFO:root:New connection from peer `('::ffff:172.31.95.1', 1340, 0, 0)` asking for path `efi64/syslinux.efi`
Aug 31 22:56:40 mngt01 python3[43123]: INFO:root:Options requested from peer ('::ffff:172.31.95.1', 1340, 0, 0):  OrderedDict([('mode', 'octet'), ('tsize', '0'), ('blksize', '1468')])
Aug 31 22:56:40 mngt01 python3[43123]: INFO:root:Options to ack for peer ('::ffff:172.31.95.1', 1340, 0, 0):  OrderedDict([('tsize', '199952'), ('blksize', '1468')])
Aug 31 22:56:42 mngt01 python3[43123]: ERROR:root:timeout after 6 retransmits.
Aug 31 22:56:42 mngt01 python3[43123]: INFO:root:Stats: for ('::ffff:172.31.95.1', 1340, 0, 0) requesting 'efi64/syslinux.efi'
Aug 31 22:56:42 mngt01 python3[43123]: INFO:root:Error: {'error_code': 0, 'error_message': 'timeout after 6 retransmits.'}
Aug 31 22:56:42 mngt01 python3[43123]: INFO:root:Time spent: 14020ms
Aug 31 22:56:42 mngt01 python3[43123]: INFO:root:Packets sent: 7
Aug 31 22:56:42 mngt01 python3[43123]: INFO:root:Packets ACKed: 0
Aug 31 22:56:42 mngt01 python3[43123]: INFO:root:Bytes sent: 0
Aug 31 22:56:42 mngt01 python3[43123]: INFO:root:Options: OrderedDict([('tsize', '199952'), ('blksize', '1468')])
Aug 31 22:56:42 mngt01 python3[43123]: INFO:root:Blksize: 1468
Aug 31 22:56:42 mngt01 python3[43123]: INFO:root:Retransmits: 6
Aug 31 22:56:42 mngt01 python3[43123]: INFO:root:Server port: 69
Aug 31 22:56:42 mngt01 python3[43123]: INFO:root:Client port: 1340
Aug 31 22:56:42 mngt01 python3[43123]: DEBUG:root:Closing response data object
Aug 31 22:56:42 mngt01 python3[43123]: DEBUG:root:Closing socket
Aug 31 22:56:42 mngt01 python3[43123]: DEBUG:root:Dying.
Aug 31 22:56:44 mngt01 python3[43123]: DEBUG:root:Running the metrics callback
Aug 31 22:56:44 mngt01 python3[43123]: INFO:root:Server stats - every 60 seconds
Aug 31 22:56:44 mngt01 python3[43123]: INFO:root:Number of spawned TFTP workers in stats time frame : 6
Aug 31 22:56:44 mngt01 python3[43123]: DEBUG:root:Starting the metrics callback in 60s
Aug 31 22:56:46 mngt01 python3[43123]: ERROR:root:timeout after 6 retransmits.
Aug 31 22:56:46 mngt01 python3[43123]: INFO:root:Stats: for ('::ffff:172.31.95.1', 1340, 0, 0) requesting 'efi64/syslinux.efi'
Aug 31 22:56:46 mngt01 python3[43123]: INFO:root:Error: {'error_code': 0, 'error_message': 'timeout after 6 retransmits.'}
Aug 31 22:56:46 mngt01 python3[43123]: INFO:root:Time spent: 14020ms
Aug 31 22:56:46 mngt01 python3[43123]: INFO:root:Packets sent: 7
Aug 31 22:56:46 mngt01 python3[43123]: INFO:root:Packets ACKed: 0
Aug 31 22:56:46 mngt01 python3[43123]: INFO:root:Bytes sent: 0
Aug 31 22:56:46 mngt01 python3[43123]: INFO:root:Options: OrderedDict([('tsize', '199952'), ('blksize', '1468')])
Aug 31 22:56:46 mngt01 python3[43123]: INFO:root:Blksize: 1468
Aug 31 22:56:46 mngt01 python3[43123]: INFO:root:Retransmits: 6
Aug 31 22:56:46 mngt01 python3[43123]: INFO:root:Server port: 69
Aug 31 22:56:46 mngt01 python3[43123]: INFO:root:Client port: 1340
Aug 31 22:56:46 mngt01 python3[43123]: DEBUG:root:Closing response data object
Aug 31 22:56:46 mngt01 python3[43123]: DEBUG:root:Closing socket
Aug 31 22:56:46 mngt01 python3[43123]: DEBUG:root:Dying.
Aug 31 22:56:50 mngt01 python3[43123]: ERROR:root:timeout after 6 retransmits.
Aug 31 22:56:50 mngt01 python3[43123]: INFO:root:Stats: for ('::ffff:172.31.95.1', 1340, 0, 0) requesting 'efi64/syslinux.efi'
Aug 31 22:56:50 mngt01 python3[43123]: INFO:root:Error: {'error_code': 0, 'error_message': 'timeout after 6 retransmits.'}
Aug 31 22:56:50 mngt01 python3[43123]: INFO:root:Time spent: 14020ms
Aug 31 22:56:50 mngt01 python3[43123]: INFO:root:Packets sent: 7
Aug 31 22:56:50 mngt01 python3[43123]: INFO:root:Packets ACKed: 0
Aug 31 22:56:50 mngt01 python3[43123]: INFO:root:Bytes sent: 0
Aug 31 22:56:50 mngt01 python3[43123]: INFO:root:Options: OrderedDict([('tsize', '199952'), ('blksize', '1468')])
Aug 31 22:56:50 mngt01 python3[43123]: INFO:root:Blksize: 1468
Aug 31 22:56:50 mngt01 python3[43123]: INFO:root:Retransmits: 6
Aug 31 22:56:50 mngt01 python3[43123]: INFO:root:Server port: 69
Aug 31 22:56:50 mngt01 python3[43123]: INFO:root:Client port: 1340
Aug 31 22:56:50 mngt01 python3[43123]: DEBUG:root:Closing response data object
Aug 31 22:56:50 mngt01 python3[43123]: DEBUG:root:Closing socket
Aug 31 22:56:50 mngt01 python3[43123]: DEBUG:root:Dying.
Aug 31 22:56:54 mngt01 python3[43123]: ERROR:root:timeout after 6 retransmits.
Aug 31 22:56:54 mngt01 python3[43123]: INFO:root:Stats: for ('::ffff:172.31.95.1', 1340, 0, 0) requesting 'efi64/syslinux.efi'
Aug 31 22:56:54 mngt01 python3[43123]: INFO:root:Error: {'error_code': 0, 'error_message': 'timeout after 6 retransmits.'}
Aug 31 22:56:54 mngt01 python3[43123]: INFO:root:Time spent: 14020ms
Aug 31 22:56:54 mngt01 python3[43123]: INFO:root:Packets sent: 7
Aug 31 22:56:54 mngt01 python3[43123]: INFO:root:Packets ACKed: 0
Aug 31 22:56:54 mngt01 python3[43123]: INFO:root:Bytes sent: 0
Aug 31 22:56:54 mngt01 python3[43123]: INFO:root:Options: OrderedDict([('tsize', '199952'), ('blksize', '1468')])
Aug 31 22:56:54 mngt01 python3[43123]: INFO:root:Blksize: 1468
Aug 31 22:56:54 mngt01 python3[43123]: INFO:root:Retransmits: 6
Aug 31 22:56:54 mngt01 python3[43123]: INFO:root:Server port: 69
Aug 31 22:56:54 mngt01 python3[43123]: INFO:root:Client port: 1340
Aug 31 22:56:54 mngt01 python3[43123]: DEBUG:root:Closing response data object
Aug 31 22:56:54 mngt01 python3[43123]: DEBUG:root:Closing socket
Aug 31 22:56:54 mngt01 python3[43123]: DEBUG:root:Dying.
Aug 31 22:57:44 mngt01 python3[43123]: DEBUG:root:Running the metrics callback
Aug 31 22:57:44 mngt01 python3[43123]: INFO:root:Server stats - every 60 seconds
Aug 31 22:57:44 mngt01 python3[43123]: DEBUG:root:Starting the metrics callback in 60s

And logs on client side (PXE boot):

>>Start PXE over IPv4 on MAC: XX-XX-XX-XX-XX-XX.
  Station IP address is 172.31.95.1

  Server IP address is 172.30.0.1
  NBP filename is efi64/syslinux.efi
  NBP filesize is 0 Bytes
  PXE-E18: Server response timeout.

So, to debug, I tried to download the file from the server itself, using atftp client, and it worked perfectly. I was also able to deploy other more "standard" servers using this same fbtftp server.

To investigate, I disabled fbtftp server, and installed Ubuntu's tftpd-hpa server instead, and started it. This time, it worked and the client was able to download the file, but with a warning on server:

Aug 31 23:13:15 mngt01 in.tftpd[43986]: RRQ from 172.31.95.1 filename efi64/syslinux.efi
Aug 31 23:13:15 mngt01 in.tftpd[43986]: tftp: client does not accept options
Aug 31 23:13:15 mngt01 in.tftpd[43987]: RRQ from 172.31.95.1 filename efi64/syslinux.efi

So it seems (not sure, just a guess) that client is requesting something, that fails, and then client or server kind of "adapt" and it works the second time.

Do you have any guess on what is happening with the fbtftp server ? I would prefer to stay with fbtftp server as I am using multiple Linux distributions, and having a single tool for all of them is really nice ๐Ÿ˜Š

Thanks a lot for any help!

Ox

remove setup_requires from setup.py

Hello please consider removing setup_requires=['flake8'] from setup.py

making that work with a simple pip install -r requirements.txt gets very difficult within a corporate intranet.

New version on Pypi ?

Would you consider publishing a new version from the top of the master branch on Pypi? The latest published version 0.2 is quite old.

Secure example code

Example code (server.py) can give false impression that only the "root of the static filesystem" is available

Which is not the case (accessible /home/otheruser/verysensibledata) is accepted by the server even if it's outside the root folder.

Even if it's only a example, implementing a minimal level of security may be useful for users.

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.