Comments (6)
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.
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.
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.
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.
Merged #9.
from goftp.
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)
- No error when unable to connect HOT 3
- Folder containing closing bracket ] don't MLSD / LIST content HOT 1
- Go module version tags?
- CWD is not work HOT 2
- error in ReadDir: failed parsing LIST entry: in Microsoft FTP Service
- Error storing files
- Failed parsing MLSD response on some servers HOT 2
- 出错的时候,数据连接没有关闭 HOT 1
- Retrieve a file from offset? HOT 2
- Failing data connection with STARTTLS (Explicit TLS): tls session not reused HOT 13
- proxy support HOT 7
- Microsoft FTP Service
- Future of goftp HOT 5
- unexpected response: 550-SSL/TLS required on the control channel (go lang)(Please help me out ) HOT 4
- How to support SOCKS ?
- ReadDir report linked file name instead of link name
- Trasfer mode MODE C (S=stream, B=block, C=compressed).
- error reading response: unexpected EOF while storing a 0 file size using TLS HOT 3
- ReadDir timeout because of weird port usage HOT 1
- ReadDir() cannot read windows hosted ftp directories
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from goftp.