Git Product home page Git Product logo

voda.ftpserver's Introduction

VoDA.FtpServer

nuget

Description

VoDA.FtpServer is a simple FTP server library. This library simplifies interaction with the FTP protocol down to the events level. All requests to the server related to authorization or working with data cause events that you must implement.

Quick start

To start the server, you need to create an FtpServerBuilder object, configure it using functions, as shown in the example below. For more information about each function, see ConfigurationParameters. After configuration, call the Build() function to create a server.

An example of an FTP server for working with the file system is given in the Test project.

Example

var server = new FtpServerBuilder()
    .ListenerSettings((config) =>
    {
        config.Port = 21; // enter the port
        config.ServerIp = System.Net.IPAddress.Any;
    })    
    .Log((config) =>
    {
        config.Level = LogLevel.Information; // enter log level. Default: Information
    })
    .Certificate((config) =>
    {
        config.CertificatePath = ".\\server.crt";
        config.CertificateKey = ".\\server.key";
    })
    .Authorization((config) =>
    {
        config.UseAuthorization = true; // enable or disable authorization
        config.UsernameVerification += (username) => {...}; // username verification
        config.PasswordVerification += (username, password) => {...}; //verification of username and password
    })
    .FileSystem((fs) =>
    {
        fs.OnDeleteFile += (client, path) => {...}; // delete file event
        fs.OnRename += (client, from, to) => {...}; // rename item event
        fs.OnDownload += (client, path) => {...};   // download file event
        fs.OnGetList += (client, path) => {...};    // get items in folder event
        fs.OnExistFile += (client, path) => {...};  // file check event
        fs.OnExistFoulder += (client, path) => {...};   // folder check event
        fs.OnCreate += (client, path) => {...}; // file creation event
        fs.OnAppend += (client, path) => {...}; // append file event
        fs.OnDeleteFolder += (client, path) => {...};  // remove folder event
        fs.OnUpload += (client, path) => {...}; // upload file event
        fs.OnGetFileSize += (client, path) => {...};    // get file size event
        fs.OnGetFileModificationTime += (client, path) => {...};    // returns the last modified date of the file
    })
    .Build();
// Start FTP-serer
server.StartAsync(System.Threading.CancellationToken.None).Wait();

Or you can use your own class that inherits from the context class. An example is below.

In this example, class MyAuthorization inherits from VoDA.FtpServer.Contexts.AuthorizationOptionsContext and class MyFileSystem inherits from VoDA.FtpServer.Contexts.FileSystemOptionsContext

var server = new FtpServerBuilder()
    .ListenerSettings((config) =>
    {
        config.Port = 21; // enter the port
        config.ServerIp = System.Net.IPAddress.Any;
    })    
    .Log((config) =>
    {
        config.Level = LogLevel.Information; // enter log level. Default: Information
    })
    .Certificate((config) =>
    {
        config.CertificatePath = ".\\server.crt";
        config.CertificateKey = ".\\server.key";
    })
    .Authorization<MyAuthorization>()
    .FileSystem<MyFileSystem>()
    .Build();
// Start FTP-serer
server.StartAsync(System.Threading.CancellationToken.None).Wait();

Full example see in Test project.

voda.ftpserver's People

Contributors

thehe avatar vodacode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

voda.ftpserver's Issues

Nothing can connect to the server

So I've implemented the bare bones of the server (basically everything is stubbed except for directory listings) and I can't get any clients to connect to the server.

Instead, I get this from the server when things try to connect:

[22:09:49 INF] [127.0.0.1:58943] [S -> C]: 220 Service Ready.
[22:09:49 INF] [127.0.0.1:58943][] [S <- C]: SSH-2.0-FILEZILLA_3.61.0
[22:09:49 INF] [127.0.0.1:58943][] [S -> C]: 502 Unknown command

For FileZilla, and

[22:11:10 INF] [127.0.0.1:58964] [S -> C]: 220 Service Ready.
[22:11:10 INF] [127.0.0.1:58964][] [S <- C]: SSH-2.0-WINSCP_RELEASE_5.21.3
[22:11:10 INF] [127.0.0.1:58964][] [S -> C]: 502 Unknown command

For WinSCP.

I'm using the version of the library on Nuget.

Am I missing somthing important here?

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.