comparison lib/rfc959.c @ 642:b9e8b22bf3b1

2004-12-12 Brian Masney <masneyb@gftp.org> * lib/rfc959.c - added pasv_behind_router option. If this is enabled, then the IP address that is in the PASV response will be ignored. Instead the IP address of the remote host will be used. This is a patch from Jasper van Veghel <vanveghel@home.nl> that I made some changes to (closes #161037)
author masneyb
date Sun, 12 Dec 2004 12:00:29 +0000
parents fa0838b22b14
children 117bcf24add2
comparison
equal deleted inserted replaced
641:efe90b739e98 642:b9e8b22bf3b1
68 68
69 {"passive_transfer", N_("Passive file transfers"), 69 {"passive_transfer", N_("Passive file transfers"),
70 gftp_option_type_checkbox, GINT_TO_POINTER(1), NULL, 70 gftp_option_type_checkbox, GINT_TO_POINTER(1), NULL,
71 GFTP_CVARS_FLAGS_SHOW_BOOKMARK, 71 GFTP_CVARS_FLAGS_SHOW_BOOKMARK,
72 N_("If this is enabled, then the remote FTP server will open up a port for the data connection. If you are behind a firewall, you will need to enable this. Generally, it is a good idea to keep this enabled unless you are connecting to an older FTP server that doesn't support this. If this is disabled, then gFTP will open up a port on the client side and the remote server will attempt to connect to it."), 72 N_("If this is enabled, then the remote FTP server will open up a port for the data connection. If you are behind a firewall, you will need to enable this. Generally, it is a good idea to keep this enabled unless you are connecting to an older FTP server that doesn't support this. If this is disabled, then gFTP will open up a port on the client side and the remote server will attempt to connect to it."),
73 GFTP_PORT_ALL, NULL},
74 {"pasv_behind_router", N_("PASV Host Behind Router"),
75 gftp_option_type_checkbox, GINT_TO_POINTER(0), NULL,
76 GFTP_CVARS_FLAGS_SHOW_BOOKMARK,
77 N_("If this is enabled, then the remote FTP server's PASV IP address field will be ignored and the host's IP address will be used instead. This is often needed for routers giving their internal rather then their external IP address in a PASV reply."),
73 GFTP_PORT_ALL, NULL}, 78 GFTP_PORT_ALL, NULL},
74 {"resolve_symlinks", N_("Resolve Remote Symlinks (LIST -L)"), 79 {"resolve_symlinks", N_("Resolve Remote Symlinks (LIST -L)"),
75 gftp_option_type_checkbox, GINT_TO_POINTER(1), NULL, 80 gftp_option_type_checkbox, GINT_TO_POINTER(1), NULL,
76 GFTP_CVARS_FLAGS_SHOW_BOOKMARK, 81 GFTP_CVARS_FLAGS_SHOW_BOOKMARK,
77 N_("The remote FTP server will attempt to resolve symlinks in the directory listings. Generally, this is a good idea to leave enabled. The only time you will want to disable this is if the remote FTP server doesn't support the -L option to LIST"), 82 N_("The remote FTP server will attempt to resolve symlinks in the directory listings. Generally, this is a good idea to leave enabled. The only time you will want to disable this is if the remote FTP server doesn't support the -L option to LIST"),
621 626
622 static int 627 static int
623 rfc959_ipv4_data_connection_new (gftp_request * request) 628 rfc959_ipv4_data_connection_new (gftp_request * request)
624 { 629 {
625 struct sockaddr_in data_addr; 630 struct sockaddr_in data_addr;
631 intptr_t pasv_behind_router;
626 char *pos, *pos1, *command; 632 char *pos, *pos1, *command;
627 intptr_t passive_transfer; 633 intptr_t passive_transfer;
628 rfc959_parms * parms; 634 rfc959_parms * parms;
629 socklen_t data_addr_len; 635 socklen_t data_addr_len;
630 unsigned int temp[6]; 636 unsigned int temp[6];
692 } 698 }
693 699
694 for (i = 0; i < 6; i++) 700 for (i = 0; i < 6; i++)
695 ad[i] = (unsigned char) (temp[i] & 0xff); 701 ad[i] = (unsigned char) (temp[i] & 0xff);
696 702
697 memcpy (&data_addr.sin_addr, &ad[0], 4);
698 memcpy (&data_addr.sin_port, &ad[4], 2); 703 memcpy (&data_addr.sin_port, &ad[4], 2);
704
705 gftp_lookup_request_option (request, "pasv_behind_router",
706 &pasv_behind_router);
707 if (pasv_behind_router)
708 {
709 #if defined (HAVE_GETADDRINFO)
710 memcpy (&data_addr.sin_addr,
711 &((struct sockaddr_in *) request->current_hostp->ai_addr)->sin_addr,
712 sizeof (data_addr.sin_addr));
713 #else
714 memcpy (&data_addr.sin_addr, request->hostp->h_addr_list[request->curhost],
715 request->hostp->h_length);
716 #endif
717
718 pos = (char *) &data_addr.sin_addr;
719 request->logging_function (gftp_logging_misc, request,
720 _("Ignoring IP address in PASV response, connecting to %d.%d.%d.%d:%d\n"),
721 pos[0] & 0xff, pos[1] & 0xff, pos[2] & 0xff, pos[3] & 0xff,
722 ntohs (data_addr.sin_port));
723 }
724 else
725 memcpy (&data_addr.sin_addr, &ad[0], 4);
726
699 if (connect (parms->data_connection, (struct sockaddr *) &data_addr, 727 if (connect (parms->data_connection, (struct sockaddr *) &data_addr,
700 data_addr_len) == -1) 728 data_addr_len) == -1)
701 { 729 {
702 request->logging_function (gftp_logging_error, request, 730 request->logging_function (gftp_logging_error, request,
703 _("Cannot create a data connection: %s\n"), 731 _("Cannot create a data connection: %s\n"),