jgoerzen / ftphs

FTP client and server library [Haskell]
http://wiki.github.com/jgoerzen/ftphs/
GNU Lesser General Public License v2.1
16 stars 16 forks source link

nlst in PASV mode fails on prep.ai.mit.edu #14

Open mignon-p opened 8 years ago

mignon-p commented 8 years ago

This program:

import Data.List
import Network.FTP.Client

desiredFile x = ".xz.sig" `isSuffixOf` x

main = do
  enableFTPDebugging
  h1 <- easyConnectFTP "prep.ai.mit.edu"
  let h = setPassive h1 True
  loginAnon h
  cwd h "/gnu/hello"
  files <- nlst h Nothing
  let file = head $ filter desiredFile files
  downloadbinary h file
  quit h

produces this result:

FTP received: 220 GNU FTP server ready.
FTP sent: USER anonymous
FTP received: 230-Due to U.S. Export Regulations, all cryptographic software on this
FTP received: 230-site is subject to the following legal notice:
FTP received: 230-
FTP received: 230-    This site includes publicly available encryption source code
FTP received: 230-    which, together with object code resulting from the compiling of
FTP received: 230-    publicly available source code, may be exported from the United
FTP received: 230-    States under License Exception "TSU" pursuant to 15 C.F.R. Section
FTP received: 230-    740.13(e).
FTP received: 230-
FTP received: 230-This legal notice applies to cryptographic software only. Please see
FTP received: 230-the Bureau of Industry and Security (www.bxa.doc.gov) for more
FTP received: 230-information about current U.S. regulations.
FTP received: 230 Login successful.
FTP sent: CWD /gnu/hello
FTP received: 250 Directory successfully changed.
FTP sent: TYPE A
FTP received: 200 Switching to ASCII mode.
FTP sent: PASV
FTP received: 227 Entering Passive Mode (208,118,235,20,92,41).
FTP sent: NLST
FTP received: 150 Here comes the directory listing.
FTP sent: TYPE I
FTP received: 226 Directory send OK.
FTP sent: PASV
FTP received: 200 Switching to Binary mode.
ftp-example: user error (Not a 227 response: (200,["Switching to Binary mode."]))

setting passive to False gets past the nlst, but fails on the downloadbinary:

FTP received: 220 GNU FTP server ready.
FTP sent: USER anonymous
FTP received: 230-Due to U.S. Export Regulations, all cryptographic software on this
FTP received: 230-site is subject to the following legal notice:
FTP received: 230-
FTP received: 230-    This site includes publicly available encryption source code
FTP received: 230-    which, together with object code resulting from the compiling of
FTP received: 230-    publicly available source code, may be exported from the United
FTP received: 230-    States under License Exception "TSU" pursuant to 15 C.F.R. Section
FTP received: 230-    740.13(e).
FTP received: 230-
FTP received: 230-This legal notice applies to cryptographic software only. Please see
FTP received: 230-the Bureau of Industry and Security (www.bxa.doc.gov) for more
FTP received: 230-information about current U.S. regulations.
FTP received: 230 Login successful.
FTP sent: CWD /gnu/hello
FTP received: 250 Directory successfully changed.
FTP sent: TYPE A
FTP received: 200 Switching to ASCII mode.
FTP sent: PORT 192,168,1,172,254,41
FTP received: 200 PORT command successful. Consider using PASV.
FTP sent: NLST
FTP received: 150 Here comes the directory listing.
FTP sent: TYPE I
FTP received: 226 Directory send OK.
FTP sent: PORT 192,168,1,172,254,42
FTP received: 200 Switching to Binary mode.
FTP sent: RETR hello-2.6.tar.xz.sig
FTP received: 200 PORT command successful. Consider using PASV.
ftp-example: user error (FTP: Expected 100, got (200,["PORT command successful. Consider using PASV."]))

This is with ftphs 1.0.9.1 and ghc 7.8.3, on Mac OS X 10.9.5.

hadronized commented 6 years ago

I have the same issue.