GithubHelp home page GithubHelp logo

Comments (6)

muirmanders avatar muirmanders commented on July 19, 2024

I'd prefer not to expose that since you could mess up the internal state of the connection depending what commands you run. It's also dangerous since each raw command could go to a different connection in the connection pool, leading to unexpected results.

Can you give some more details on your use case (like the particular command you need to run)? If we can't come up with something safe that solves the use case, I would rather directly expose the persistentConn as a separate lower-level connection you create independent of the Client. It would only be a single connection, and not interact with other connections at all.

from goftp.

duke-4 avatar duke-4 commented on July 19, 2024

I need that functionality as well, in my private fork (that contains some more customizations) i added a simple RawCommand function. My use cases at the moment are the commands:

  • SITE VERS - to show the server software
  • SITE SEARCH - search for directories

This commands may not be official supported in a standard, but some FTP server allow you to add custom commands that trigger scripts.

from goftp.

stancarney avatar stancarney commented on July 19, 2024

My usage is also limited to SITE commands.

i.e.

  • SITE standard=none
  • SITE parm=blah

The underlying server technology is a product from OpenText (formerly known as GXS) and it is very common in the banking industry for file exchanges. Typical usage over FTPs has the client running several SITE commands before performing a transfer or a directory listing. The SITE commands are used to pass additional details about the files in question.

I guess a RunSiteCmd would also work if you are worried that somebody trying to run a PASV or other command would screw the connection up. To my knowledge SITE commands only have string inputs and outputs.

Maybe something like this?

func (c *Client) SiteCmd(cmd string) (int, string, error) {
    pconn, err := c.getIdleConn()
    if err != nil {
        return 0, "", err
    }

    defer c.returnConn(pconn)

    return pconn.sendCommand(fmt.Sprintf("SITE %s", cmd))
}

An attempt to run PASV or another command would just result in a 500 being returned instead of messing up the connection.

from goftp.

muirmanders avatar muirmanders commented on July 19, 2024

Please look at #9. I added an "OpenRawConn" method that returns a separate RawConn you can use to run control or data commands. Let me know if you think that interface looks good.

from goftp.

muirmanders avatar muirmanders commented on July 19, 2024

Merged #9.

from goftp.

stancarney avatar stancarney commented on July 19, 2024

That looks great! I will give it a test out later tonight. (sorry I thought I posted this message yesterday, but here it sits)

from goftp.

Related Issues (20)

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.