How does WinSCP determine whether to issue PASV or EPSV?

Advertisement

Guest

How does WinSCP determine whether to issue PASV or EPSV?

I recently had a WinSCP script that issues a "Synchronize Remote" command fail. (The script had been working for months.) The log shows the server responding to an MLSD command with "Could not retrieve directory listing". This had worked until a couple weeks ago. The only difference that I could see between the succeeding and failing flows was that WinSCP issued an EPSV command just prior to the MLSD command. In the past it issued a PASV command.

After reading that Extended PASV supports IPv6 while PASV supports only IPv4 so I disabled IPv6 on the FTP server and the script runs again. The server has supported IPv6 since before I created the script but recent maintenance changed something (obviously). I can see nothing in the logged exchange that would tell WinSCP to use EPSV. I can't confirm this right (since the Synchronize is running now and will continue for several hours) but I'm pretty sure the original control connection was IPv4. What tells WinSCP that a server supports IPv6 connections?

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,440
Location:
Prague, Czechia

Re: How does WinSCP determine whether to issue PASV or EPSV?

WinSCP uses EPSV, if it is connected to IPv6 address.
WinSCP connects to IPv6 address, if DNS returned IPv6 address for hostname you have specified and IPv6 is enabled in session settings.
https://winscp.net/eng/docs/ui_login_connection
(Or of course, when you specify IPv6 address explicitly in session settings)

Reply with quote

Patrick O'Keefe
Donor
Joined:
Posts:
4
Location:
Seattle, WA USA

Re: How does WinSCP determine whether to issue PASV or EPSV?

martin wrote:

WinSCP uses EPSV, if it is connected to IPv6 address.
WinSCP connects to IPv6 address, if DNS returned IPv6 address for hostname you have specified and IPv6 is enabled in session settings.
https://winscp.net/eng/docs/ui_login_connection
(Or of course, when you specify IPv6 address explicitly in session settings)
Interesting. I've complained to the support people for my router because it does not return an IPv6 address for an NSLOOKUP -query=AAAA command issued for a local device from Windows. And a NETSTAT issues when I have a connection between WinSCP and the server shows an IPv4 connection, not IPv6. that is when I manually start the connection. Maybe something very different happens when I run my Synchronize script.

I think I need to run some packer traces and see what is going on.

Reply with quote

Patrick O'Keefe
Donor
Joined:
Posts:
4
Location:
Seattle, WA USA

I'm glad I ran a trace because I never would have guessed this. When given a DSN name of a server (and when WinSCP is configured to support both IPv4 and IPv6) WinSCP issues MDNS and LLMNR queries (neither of which I knew anything about). Neither of these depend on DNS servers. If an IPv6 response is returned WinSCP will use the IPv6 address.

In addition, there is apparently some case sensitivity in (at least) one of the queries. My FTP server's name has upper case letters. If I give WinSCP the server's name in upper case I get an IPv6 connection. If I use lower case letters I get an IPv4 connection. That seems pretty strange.

Reply with quote

martin
Site Admin
martin avatar

Just wanted to mention that WinSCP does not really do any queries. WinSCP just calls inet_addr and getaddrinfo APIs. The queries are done by an operating system.

Reply with quote

Advertisement

You can post new topics in this forum