npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ctrlfilezillaserver

v1.0.2

Published

CtrlFileZillaServer é um conjunto de funções para gerenciar o FileZilla Server

Downloads

27

Readme

CtrlFileZillaServer

CtrlFileZillaServer é um conjunto de funções para gerenciar o FileZilla Server

Language Platforms License HitCount

FileZilla é um dos melhores servidores FTP gratuitos, fácil de utilizar e muito estável, porem, não possui API. Toda gestão é feita via interface gráfica, o que acaba dificultando um gerenciamento automático do servidor. Para contornar isto, criei um repositório que gerencia as contas de FTP modificando o arquivo XML FileZilla Server.xml localiado na pasta do FileZilla Server.

Você pode baixar o Filezilla server em: https://filezilla-project.org/download.php?type=server


Instalando

npm install ctrlfilezillaserver

Carregando o repositório

var FilezillaCtrl = require('ctrlfilezillaserver');

Iniciando

Antes de executar alguma das funções precisamos definir o diretório onde o Filezilla Server se encontra. Esta é uma função assíncrona e após sua conclusão é feito as chamadas as funções.

FilezillaCtrl.init("C:\\Program Files (x86)\\FileZilla Server\\").then(function(){

	// Aqui você faz a chamada a função desejada

}).catch(function(err){

	console.log(err);

});

Normalmente o Filezila Server fica no diretório abaixo: C:\\Program Files (x86)\\FileZilla Server\\

Listando as Contas Disponíveis

Esta função ira retornar um array com todas as constas, com os dados abaixo:

  • Usuário
  • Diretório
  • Permissões

Chamando

FilezillaCtrl.init("C:\\Program Files (x86)\\FileZilla Server\\").then(function(){

	FilezillaCtrl.contas_listar().then(function(DadRet){

		console.log(JSON.stringify(DadRet));

	}).catch(function(err){

		console.log(err);

	});

}).catch(function(err){

	console.log(err);

});

Retorno

[
  {
    "Nome": "teste1",
    "Diretorio": "C:\\pasta1",
    "Permissoes": {
      "FileRead": true,
      "FileWrite": true,
      "FileDelete": true,
      "DirCreate": true,
      "DirDelete": true,
      "DirList": true,
      "DirSubdirs": true
    }
  }
  }
]

Altera uma conta existe

Chamando

FilezillaCtrl.init("C:\\Program Files (x86)\\FileZilla Server\\").then(function(){

    var InfDad =    {   
                    Senha: "aaabbb", 
                    Diretorio: "C:\\PastaTeste1", 
                    Permissoes: {
                    "FileRead": true,
                    "FileWrite": true,
                    "FileDelete": true,
                    "FileAppend": true,
                    "DirCreate": true,
                    "DirDelete": true,
                    "DirList": true,
                    "DirSubdirs": true,
                    "IsHome": true,
                    "AutoCreate": false
                    } 
                    };

    FilezillaCtrl.contas_alterar("teste1", InfDad).then(function(){

        console.log("OK");
    
    }).catch(function(err){

        console.log(err);

    });

}).catch(function(err){

	console.log(err);

});

Altera a Senha de uma Conta

Chamando

FilezillaCtrl.init("C:\\Program Files (x86)\\FileZilla Server\\").then(function(){

    FilezillaCtrl.contas_alterar_senha("teste1", "aaabbb").then(function(){

        console.log("OK");

    }).catch(function(err){

        console.log(err);

    });

}).catch(function(err){

	console.log(err);

});

Altera o Diretório de uma Conta

Chamando

FilezillaCtrl.init("C:\\Program Files (x86)\\FileZilla Server\\").then(function(){

    FilezillaCtrl.contas_alterar_diretorio("teste1", "C:\\PastaTeste1").then(function(){

        console.log("OK");

    }).catch(function(err){

        console.log(err);

    });

}).catch(function(err){

	console.log(err);

});

Altera as Permissões de uma Conta

Chamando

FilezillaCtrl.init("C:\\Program Files (x86)\\FileZilla Server\\").then(function(){

    var InfDad =    {
                    "FileRead": true,
                    "FileWrite": true,
                    "FileDelete": true,
                    "FileAppend": true,
                    "DirCreate": true,
                    "DirDelete": true,
                    "DirList": true,
                    "DirSubdirs": true,
                    "IsHome": true,
                    "AutoCreate": false
                    } ;

    FilezillaCtrl.contas_alterar_permissoes("teste1", InfDad).then(function(){

        console.log("OK");

    }).catch(function(err){

        console.log(err);

    });

}).catch(function(err){

	console.log(err);

});

Verifica se uma Conta Existe

Chamando

FilezillaCtrl.init("C:\\Program Files (x86)\\FileZilla Server\\").then(function(){

    FilezillaCtrl.contas_existe("teste1").then(function(DadRet){

        console.log(JSON.stringify(DadRet));

    }).catch(function(err){

        console.log(err);

    });

}).catch(function(err){

	console.log(err);

});

Retorno

  • true: Conta existe
  • false: Conta não existe

Deleta uma Conta

Chamando

FilezillaCtrl.init("C:\\Program Files (x86)\\FileZilla Server\\").then(function(){

    FilezillaCtrl.contas_deletar("teste1").then(function(){

        console.log("OK");

    }).catch(function(err){

        console.log(err);

    });

}).catch(function(err){

	console.log(err);

});

Criar uma nova Conta

Chamando

FilezillaCtrl.init("C:\\Program Files (x86)\\FileZilla Server\\").then(function(){

    var InfDad =    {   
                    Senha: "aaabbb", 
                    Diretorio: "C:\\PastaTeste1", 
                    Permissoes: {
                    "FileRead": true,
                    "FileWrite": true,
                    "FileDelete": true,
                    "FileAppend": true,
                    "DirCreate": true,
                    "DirDelete": true,
                    "DirList": true,
                    "DirSubdirs": true,
                    "IsHome": true,
                    "AutoCreate": false
                    } 
                    };

    FilezillaCtrl.contas_criar("teste1", InfDad).then(function(){

        console.log("OK");

    }).catch(function(err){

        console.log(err);

    });

}).catch(function(err){

	console.log(err);

});

Referências

Permissões

O nó de permissões possui as permissões abaixo:

  • FileRead: Ler Arquivos
  • FileWrite: Criar/Editar Arquivos
  • FileDelete: Deletar Arquivos
  • DirCreate: Criar Diretório
  • DirDelete: Deletar Diretório
  • DirList: Listar Diretórios
  • DirSubdirs: Exibir Sub Diretórios

Os valores das variaveis é sempre um boolean, onde:

  • true: Tem permissão
  • false: Não tem permissão

Sucesso/Erro

Em todas funções temos o retorno controlado em then e catch (Padrão para funções Promises). Na função catch esta presente um parâmetro que retorna um objeto Error indiando a causa do erro.

Exemplo de Erro

Chamada

FilezillaCtrl.init("C:\\Program Files (x86)\\FileZilla Server\\").then(function(){

    FilezillaCtrl.contas_deletar("XXXXXXXXXXX").then(function(){

        console.log("OK");

    }).catch(function(err){

        console.log(err);

    });

}).catch(function(err){

    console.log(err);

});

Retorno

Error: Error: Error: Conta nao localizada
    at Promise (C:\index.js:535:19)
    at new Promise (<anonymous>)
    at Object.contas_criar (G:\index.js:362:12)
    at G:\tests.js:7:19

Contato

Paloma Macetko