goftp / server Goto Github PK
View Code? Open in Web Editor NEWA FTP server framework written by Golang, moved to https://gitea.com/goftp/server
Home Page: https://goftp.io
License: MIT License
A FTP server framework written by Golang, moved to https://gitea.com/goftp/server
Home Page: https://goftp.io
License: MIT License
不知道怎么重现
示例程序exampleftpd,在宿主机上没问题,可以正常运行。但是在docker中,会报: 用户只读权限,有遇到过吗?
we want limit spend at the server. How can I do it?
when the ftp client auto select Character encoding
it is not UTF8
but when i use pure-ftp , the ftp client is uft8
can you fix the bug?
`func(conn *Conn) passiveListenIP() string {
if len(conn.PublicIp()) > 0 {
return conn.PublicIp()
}
return conn.conn.LocalAddr().String()
}`
If I do not set "PublicIp" for conn config, the "passiveListenIP" will get a bad IP string likes "ip:port".
I think the correct code is: conn.conn.LocalAddr().(*net.TCPAddr).IP.String().
This is my first golang project so I may be mistaken but I don't think the server is correctly handling dropped connections from the client.
To reproduce
The server tries to keep reading from the connection leading to 100% CPU usage.
I will try and fix the issue and submit a PR but don't hold your breath :)
Since goftp doesn't support APPE
command, some clients, namely libcurl and programs which use it, cannot perform the upload.
Can you please implement APPE instead of returning 202 Obsolete
?
Thanks
Hi :)
This is my first project with golang. I'm using your ftp server to provide a way to upload CSV files with user data to be synced with data in Postgres. I've written a driver that receives such data and it works well. Thing is, where these data end up depends on who logged on to the FTP server.
AFAICT, the only place this information is stored is in conn.user
after a successful logon. I don't see how I would be able to get at that information from my driver without for example modifying server/cmd.go
to send it along as an extra argument to PutFile
, but then I'd be destroying the interface contract. Of course, this wouldn't matter in my particular example, but if at all possible, I'd like to avoid forking your project just to accomplish this.
Since I'm so new to golang, I'm wondering if I'm missing something obvious here, so I'm just putting this question out there to see what you think :)
Thanks for your time!
Daniel
looks good. DO you know if it supports sftp ?
Hello!
In cmd.go listed all supported FTP command but "XMKD" used by default Windows-cmd ftp client.
Cmd.go has all commands from here but "XMKD"
Can you add it, please?
When a client (properly) closes the connection, the server will take 100% CPU spinning in an endless loop. That's because in this case EOF is read which should cause the server to stop listening (break
) but instead it goes back to listening (continue
) and does that in a tight loop.
I believe https://github.com/goftp/server/blob/master/conn.go#L67 should be break
instead of continue
Hi, I just implemented a server with this framework. I love the clear API by the way.
I couldnt really make it work with any FTP client I had at hand; the one I tried most is NcFTP. When I log in and try to send a file, I get the following output from NcFTP:
[matti@babylon tmp] 20:52:45 % ncftp -P 8021 -u asd -p asd localhost
NcFTP 3.2.6 (Dec 04, 2016) by Mike Gleason (http://www.NcFTP.com/contact/).
Connecting to 127.0.0.1...
Welcome msg
Logging in...
Password ok, continue
Invalid reply: " EPSV"
Logged in to localhost.
Invalid reply: " EPRT"
ncftp / > put foo.bin
Protocol violation by server: blank line on control.
Passive mode refused.
foo.bin: ETA: 0:00 9.54/ 9.54 MB 278.26 kB/s =
So there are some errors (Invalid reply: .. ).. from my logs on the server I can tell the file was received, but NcFTP never sees any progress and the PUT command gets stuck .. ?
Server logs the following for the same session (login + PUT foo.bin):
2017/05/25 20:52:49 53969ae8352a3308d6cb Connection Established
2017/05/25 20:52:49 53969ae8352a3308d6cb < 220 Welcome msg
2017/05/25 20:52:49 53969ae8352a3308d6cb > USER asd
2017/05/25 20:52:49 53969ae8352a3308d6cb < 331 User name ok, password required
2017/05/25 20:52:49 53969ae8352a3308d6cb > PASS ****
2017/05/25 20:52:49 53969ae8352a3308d6cb < 230 Password ok, continue
2017/05/25 20:52:49 53969ae8352a3308d6cb > PWD
2017/05/25 20:52:49 53969ae8352a3308d6cb < 257 "/" is the current directory
2017/05/25 20:52:49 53969ae8352a3308d6cb > FEAT
2017/05/25 20:52:49 53969ae8352a3308d6cb < 211 211-Extensions supported:
EPSV
EPRT
211 END
2017/05/25 20:52:49 53969ae8352a3308d6cb > HELP SITE
2017/05/25 20:52:49 53969ae8352a3308d6cb < 500 Command not found
2017/05/25 20:52:49 53969ae8352a3308d6cb > CLNT NcFTP 3.2.6 macosx10.12.2
2017/05/25 20:52:49 53969ae8352a3308d6cb < 500 Command not found
2017/05/25 20:52:58 53969ae8352a3308d6cb > TYPE I
2017/05/25 20:52:58 53969ae8352a3308d6cb < 200 Type set to binary
2017/05/25 20:52:58 53969ae8352a3308d6cb > REST 1
2017/05/25 20:52:58 53969ae8352a3308d6cb < 350 Start transfer from 1
2017/05/25 20:52:58 53969ae8352a3308d6cb > MLST foo.bin
2017/05/25 20:52:58 53969ae8352a3308d6cb < 500 Command not found
2017/05/25 20:52:58 53969ae8352a3308d6cb > SIZE foo.bin
2017/05/25 20:52:58 53969ae8352a3308d6cb < 213 0
2017/05/25 20:52:58 53969ae8352a3308d6cb > MDTM foo.bin
2017/05/25 20:52:58 53969ae8352a3308d6cb < 213 20170101000000
2017/05/25 20:52:58 53969ae8352a3308d6cb > PASV
2017/05/25 20:52:58 53969ae8352a3308d6cb < 227 Entering Passive Mode (127,0,0,1:8021,31,86)
2017/05/25 20:52:58 53969ae8352a3308d6cb > PORT 127,0,0,1,219,236
2017/05/25 20:52:58 53969ae8352a3308d6cb Opening active data connection to 127.0.0.1:56300
2017/05/25 20:52:58 53969ae8352a3308d6cb < 200 Connection established (56300)
2017/05/25 20:52:58 53969ae8352a3308d6cb > STOR foo.bin
2017/05/25 20:52:58 53969ae8352a3308d6cb < 150 Data transfer starting
2017/05/25 20:52:58 53969ae8352a3308d6cb < 226 OK, received 10006420 bytes
Looks to me like the passive mode connection is not being set up properly? Instead it seems to be using active mode and opening a socket towards the client?
I am running it on a 64-bit OSX PC (Macbook Pro) with Go 1.8.1. This is how I create my server:
opts := &ftpd.ServerOpts{
Factory: &MyDriverFactory{},
Auth: &MyAuth{server: s},
Port: port,
PublicIp: "127.0.0.1",
PassivePorts: "8022-8023",
WelcomeMessage: "Welcome msg",
}
server := ftpd.NewServer(opts)
.. could just be my FTP skills are incredibly rusty.
Command LIST -al
I've noticed that when I return an errors.New("XX")
error in a Driver implementation for some reason I then get 500 command not found
errors almost always within the same session.
When I change to passive mode, I get passive address scan failure
I have built a simple mainTest.go that runs a server, and duplicates the problem.
I've built a new FileInfo and DriverFactory, maybe my implementation is wrong somewhere?
To replicate:
$ go run mainTest.go
2018/09/06 14:26:39 Go FTP Server listening on 2022
in the test I do a rename, the Rename() method isn't implemented so it just returns an error that is printed out as expected. However any subsequent calls (like ls
) all fail.
Then FTP:
$ ftp localhost 2022
ftp: connect to address ::1: Connection refused
ftp: Trying 127.0.0.1 ...
Connected to localhost.
220 Welcome to the Go FTP Server
Name (localhost:root): root
331 User name ok, password required
Password:
230 Password ok, continue
ftp> ls
200 Connection established (57726)
150 Opening ASCII mode data connection for file list
226 Closing data connection, sent 0 bytes
ftp> ren old.txt new.txt
350 Requested file action pending further information.
550 Action not taken Rename not implemented
ftp> ls
200 Connection established (57729)
500 Command not found
The library exposes Logger
but all logger
fields are private and there is no setLogger
or similar method.
How can I assign my own logging struct?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.