Giter VIP home page Giter VIP logo

ft-daemon's Introduction

ft-daemon

A cross-platform daemon/service for automatic file transfer from a sender to a receiver computer.


What's this?

ft-daemon is a file transfer daemon tool which facilitates automatic file transfer between two computers.

Some of its key features:

  • It can transfer files between two computers in the same network or the sender can be behind a NAT/firewall and receiver can be on the Internet.

  • It's an uni-directional file transfer tool. It only allows sender to send files to receiver, not the other way.

  • It runs either in client (sender) or server (receiver) mode.

  • It's developed using Python 2.7, so a Python 2.7 installation is necessary in both sender and receiver.

  • As of now, it supports Windows only as a client/sender, not as a server/receiver.


How does it work?

The tool was created to serve a certain use-case where a computer wants to automatically and periodically send any type of file (binary or text) to another computer.

The assumption in the use-case is that the sender is constantly and periodically generating file(s) which it wants to send to receiver for some sort of processing.

It maintains following directory hierarchy in sender and receiver:

client-directory-root           server-directory-root
    |                               |
    |--- new                        |--- incoming
    |                               |
    |--- in-sync                    |--- for-processing
    |                               |
    |--- archived                   |--- processed

Whatever file(s) Sender is generating and wants to send to receiver, it must put the file inside client-directory-root/new. ft-daemon periodically (every 10 sec) checks whether there is any file inside client-directory-root/new and whether the last modified time of the file(s) is more than 30 seconds. If so, it first moves the file to client-directory-root/in-sync. While moving, it appends file modified time (in epoch format) to filename so that even if the new files sender is generating have the same name, it would not lead to any duplicate filenames. ft-daemon transmits the moved file(s) to server immediately to server's server-directory-root/incoming directory. Once successfully sent, the file is then moved from from client-directory-root/in-sync to client-directory-root/archived.

ft-daemon, that is running in server/receiver, periodically (every 10 sec) checks whether there is any new file in server-directory-root/incoming directory and whether the last modified time of the file(s) is more than 30 seconds. If so, it moves the file(s) to server-directory-root/for-processing directory.

Once the file(s) in server-directory-root/for-processing directory are processed, receiver computer should move them out from there to avoid unnecessary confusion. After processing, the file(s) can be moved to server-directory-root/processed directory.

In server machine, instead of using root account or the user account ft-daemon is running under, ft-daemon creates a special account (username and password is configurable) in server for the client computer to connect and send files. This account does not have it's own home directory and has read-write access only to server-directory-root/incoming directory.


How do I use it?

On Server:

To setup the whole system of automatic transfer, you first need to configure and start ft-daemon in the server/receiver computer.

As of now, 'server' mode is only supported in Linux. You need to fill in or update necessary parameters in confg/ft-daemon.conf file. Change 'app_mode' to 'server'. Update 'server_directory_root' - put appropriate value inside <>. Put a strong password for 'server_passwd' which client/sender uses to send files. If you wish, you many change 'server_username' too. Just make sure, do not use any username which already exists in the server computer.

Once config file is ready, execute ft-daemon.sh as follows:

  • To create the user account (need to be executed only once):

    $ ./ft-daemon.sh createuser
    
  • To start the daemon:

    $ ./ft-daemon.sh start
    
  • To stop the daemon:

    $ ./ft-daemon.sh stop
    

It prints out necessary logs and will guide you through. Once the daemon is running, you can check the logs in logs/ sub-directory.

On Client:

Now, move to the sender/client computer and update ft-daemon.conf appropriately. Change 'app_mode' to 'client'. Set 'filename_ext' to appropriate filename extension(s). Update both 'client_directory_root', 'server_directory_root' and 'server_hostname'. Make user the value of 'server_directory_root' matches the value you put for server side ft-daemon. Use the same 'server_username' and 'server_passwd' you used for server side config.

Once config file is ready in client/sender computer, execute ft-daemon.bat or ft-daemon.sh file from command line depending on your OS.

  • To start the daemon:

    ft-daemon.bat start
    
  • To stop the daemon:

    ft-daemon.bat stop
    

It shows necessary logs and will guide you through. Once the daemon is running, you can check the logs in logs/ sub-directory.

Notes: If you are running the client in a Windows machine, you need to run the batch script in administrator mode. Right-click on 'Command Prompt' icon in Start menu and click 'Run as administrator' to open command prompt in administrator mode. You should run the batch script from there.


Special notes

In client/sender, whatever application is generating the file(s), for sending to server, it must create a new file every time. It should not open a file for a very long time and keep updating it. It can either move the file when ready to client-directory-root/new directory or it can directly create and save the file in that directory. If the application is directly creating the file in that directory, it must not keep the file open and edit after long intervals. ft-daemon attempts to move file(s) from that directory whose last modified time is more than 30 seconds. If the file(s) are locked by an application, ft-daemon may simply fail to move them to 'in-sync' sub-directory and the file(s) will not be sent to server until the lock is released.

ft-daemon's People

Contributors

arun6174 avatar arun-glidex 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.