GithubHelp home page GithubHelp logo

biztalkfusion / ftp2azure Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zigszigsdk/ftp2azure

0.0 1.0 0.0 10.25 MB

FTP worker role for Azure

License: Apache License 2.0

R 11.48% C# 88.52%

ftp2azure's Introduction

FTP2Azure

FTP for Azure worker. Stores FTP files on the blob store. Works with .NET 4.5+

Quickguide

Requires:

  Microsoft.WindowsAzure.ServiceRuntime 2.2.0.0
  Microsoft.WindowsAzure.Storage 2.1.0.0

Azure Worker

Make an azure worker, and add the content of the source folder. The following boilerplate should help you get started:

    public class WorkerRole : RoleEntryPoint
    {
        private FtpServer _server;

        public override bool OnStart()
        {
            if (_server == null)
                _server = new FtpServer();

            _server.NewConnection += ServerNewConnection;
            _server.UserLogoutEvent += ServerLogoutEvent;
            _server.errorHandler += ErrorHandle;

            return base.OnStart();
        }

        public override void Run()
        {
            while (true)
            {
                if (_server.Started)
                {
                    Thread.Sleep(10000);
                    Trace.WriteLine("Server is alive.", "Information");
                }
                else
                {
                    _server.Start();
                    Trace.WriteLine("Server starting.", "Control");
                }
            }
        }

        void ServerNewConnection(int nId)
        {
            Trace.WriteLine(String.Format("Connection {0} accepted", nId), "Connection");
        }

        void ServerLogoutEvent(string username)
        {
            Trace.WriteLine(String.Format("user {0} logged out", username), "Connection");
        }

        void ErrorHandle(Exception e) 
        {
            Trace.WriteLine("Error in FTP: " + e.Message);
            throw e;
        }
    }

Implementation own an Account Manager

For use own an Account Manager you should implement interface IAccountManager and pass him into FtpServer constructor as a parameter.

    class AcccountManager : IAccountManager
    {
        public int UserNum { get; }
        public int LoadConfigration()
        {
            // Implement your own logic of loading accounts from another source, e.g. database, Web API, external config file.
        }

        public bool CheckAccount(string username, string password)
        {
            // Implement your own logic of checking  account and password
        }

        public string GetPassword(string username)
        {
            // Implement your own logic of getting password by username
        }
    }

Service Config:

      <Setting name="FTP2Azure.Mode" value="Debug" /> <!--Debug or Live-->
      <Setting name="FTP2Azure.FtpAccount" value="(testuser:testpassword)(user2:pass)" /> <!-- config your users here-->
      <Setting name="FTP2Azure.FtpServerHost" value="localhost" /> <!-- [yourapp].cloudapp.net in cloud -->
      <Setting name="FTP2Azure.MaxIdleSeconds" value="120" />
      <Setting name="FTP2Azure.QueueNotification" value="false" />
      <Setting name="FTP2Azure.ConnectionEncoding" value="UTF8" />
      <Setting name="FTP2Azure.MaxClients" value="5" />
      <Setting name="FTP2Azure.StorageAccount" value="UseDevelopmentStorage=true" />

Note that the username will be the name of the blob storage container.

Endpoints

      <InputEndpoint name="FTP2Azure.Command" protocol="tcp" port="21" localPort="9003" /> 
      <InputEndpoint name="FTP2Azure.Passive" protocol="tcp" port="9001" localPort="9002" />

Known issues

  • Passive mode does not currently work (the client will have to forward ports in order to connect and stay in active)
  • usernames and passwords set in the service cofig file cannot contain the following characters: (, ) and :

Improvement ideas

  • keep the decoding logic solely inside of FtpSocketHandler and only pass FtpConnectionObject the full string message once an end-of-line is reached.

Credits

ftp2azure's People

Contributors

zigszigsdk avatar the-tatarinov-av avatar ryandle avatar basjem avatar

Watchers

James Cloos 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.