summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2008-03-03 11:53:23 +0000
committerBenjamin Otte <otte@src.gnome.org>2008-03-03 11:53:23 +0000
commitd93592a56873145720de5818778cb0fb5eb42d80 (patch)
tree83e33ea03b870c8836d8ac3ee672460dfa4ac8d6 /daemon
parentd59da16233fbbd8d70740aff23541087b15a5d38 (diff)
downloadgvfs-d93592a56873145720de5818778cb0fb5eb42d80.tar.gz
implement EPSV. This should make IPv6 work.
2008-03-03 Benjamin Otte <otte@gnome.org> * daemon/gvfsbackendftp.c: (ftp_connection_parse_features), (ftp_connection_use), (ftp_connection_ensure_data_connection): implement EPSV. This should make IPv6 work. svn path=/trunk/; revision=1501
Diffstat (limited to 'daemon')
-rw-r--r--daemon/gvfsbackendftp.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/daemon/gvfsbackendftp.c b/daemon/gvfsbackendftp.c
index df859d45..01909601 100644
--- a/daemon/gvfsbackendftp.c
+++ b/daemon/gvfsbackendftp.c
@@ -72,8 +72,10 @@
typedef enum {
FTP_FEATURE_MDTM = (1 << 0),
FTP_FEATURE_SIZE = (1 << 1),
- FTP_FEATURE_TVFS = (1 << 2)
+ FTP_FEATURE_TVFS = (1 << 2),
+ FTP_FEATURE_EPSV = (1 << 3)
} FtpFeatures;
+#define FTP_FEATURES_DEFAULT (FTP_FEATURE_EPSV)
struct _GVfsBackendFtp
{
@@ -505,7 +507,8 @@ ftp_connection_parse_features (FtpConnection *conn)
} features[] = {
{ "MDTM", FTP_FEATURE_MDTM },
{ "SIZE", FTP_FEATURE_SIZE },
- { "TVFS", FTP_FEATURE_TVFS }
+ { "TVFS", FTP_FEATURE_TVFS },
+ { "EPSV", FTP_FEATURE_EPSV }
};
char **supported;
guint i, j;
@@ -588,6 +591,12 @@ ftp_connection_use (FtpConnection *conn)
/* check supported features */
if (ftp_connection_send (conn, 0, "FEAT") != 0)
ftp_connection_parse_features (conn);
+ else
+ conn->features = FTP_FEATURES_DEFAULT;
+
+ /* RFC 2428 suggests to send this to make NAT routers happy */
+ if (conn->features & FTP_FEATURE_EPSV)
+ ftp_connection_send (conn, 0, "EPSV ALL");
g_clear_error (&conn->error);
return TRUE;
@@ -627,6 +636,27 @@ ftp_connection_ensure_data_connection (FtpConnection *conn)
char *ip;
guint status;
+ if (conn->features & FTP_FEATURE_EPSV)
+ {
+ status = ftp_connection_send (conn, RESPONSE_PASS_500, "EPSV");
+ if (STATUS_GROUP (status) == 2)
+ {
+ s = strrchr (conn->read_buffer, '(');
+ if (s)
+ {
+ guint port;
+ s += 4;
+ port = strtoul (s, NULL, 10);
+ if (port != 0)
+ {
+ addr = soup_address_new (
+ soup_address_get_name (soup_socket_get_remote_address (conn->commands)),
+ port);
+ goto have_address;
+ }
+ }
+ }
+ }
/* only binary transfers please */
status = ftp_connection_send (conn, 0, "PASV");
if (status == 0)
@@ -652,6 +682,7 @@ ftp_connection_ensure_data_connection (FtpConnection *conn)
addr = soup_address_new (ip, port1 << 8 | port2);
g_free (ip);
+have_address:
conn->data = soup_socket_new ("non-blocking", FALSE,
"remote-address", addr,
NULL);