fdd_table[sock].close_line = 0;
fde *F = &fd_table[sock];
- details.peer.NtoA(F->ipaddr,MAX_IPSTRLEN);
- F->remote_port = details.peer.GetPort();
- F->local_addr.SetPort(details.me.GetPort());
- F->sock_family = details.me.IsIPv6()?AF_INET6:AF_INET;
- details.me.FreeAddrInfo(gai);
+ details.remote.NtoA(F->ipaddr,MAX_IPSTRLEN);
+ F->remote_port = details.remote.GetPort();
+ F->local_addr = details.local;
- #if USE_IPV6
- F->sock_family = AF_INET;
- #else
- F->sock_family = details.local.IsIPv4()?AF_INET:AF_INET6;
- #endif
++ F->sock_family = details.local.IsIPv6()?AF_INET6:AF_INET;
+ // set socket flags
+ commSetCloseOnExec(sock);
commSetNonBlocking(sock);
/* IFF the socket is (tproxy) transparent, pass the flag down to allow spoofing */
ftpState->state = SENT_EPSV_2; /* simulate having sent and failed EPSV 2 */
ftpSendPassive(ftpState);
} else if (strcmp(buf, "(2)") == 0) {
- #if USE_IPV6
- /* If server only supports EPSV 2 and we have already tried that. Go straight to EPRT */
- if (ftpState->state == SENT_EPSV_2) {
- ftpSendEPRT(ftpState);
+ if (Ip::EnableIpv6) {
+ /* If server only supports EPSV 2 and we have already tried that. Go straight to EPRT */
+ if (ftpState->state == SENT_EPSV_2) {
+ ftpSendEPRT(ftpState);
+ } else {
+ /* or try the next Passive mode down the chain. */
+ ftpSendPassive(ftpState);
+ }
} else {
- /* or try the next Passive mode down the chain. */
+ /* Server only accept EPSV in IPv6 traffic. */
+ ftpState->state = SENT_EPSV_1; /* simulate having sent and failed EPSV 1 */
ftpSendPassive(ftpState);
}
- #else
- /* We do not support IPv6. Remote server requires it.
- So we must simulate having failed all EPSV methods. */
- ftpState->state = SENT_EPSV_1;
- ftpSendPassive(ftpState);
- #endif
} else {
/* handle broken server (RFC 2428 says MUST specify supported protocols in 522) */
- debugs(9, DBG_IMPORTANT, "WARNING: Server at " << fd_table[ftpState->ctrl.fd].ipaddr << " sent unknown protocol negotiation hint: " << buf);
+ debugs(9, DBG_IMPORTANT, "WARNING: Server at " << ftpState->ctrl.conn->remote << " sent unknown protocol negotiation hint: " << buf);
ftpSendPassive(ftpState);
}
return;
/* block other non-EPSV connections being attempted */
ftpState->flags.epsv_all_sent = true;
} else {
- #if USE_IPV6
- if (addr.IsIPv6()) {
- debugs(9, 5, HERE << "FTP Channel (" << addr << "). Sending default EPSV 2");
- snprintf(cbuf, 1024, "EPSV 2\r\n");
+ if (ftpState->ctrl.conn->local.IsIPv6()) {
+ debugs(9, 5, HERE << "FTP Channel (" << ftpState->ctrl.conn->remote << "). Sending default EPSV 2");
+ snprintf(cbuf, CTRL_BUFLEN, "EPSV 2\r\n");
ftpState->state = SENT_EPSV_2;
}
- #endif
- if (addr.IsIPv4()) {
- debugs(9, 5, HERE << "Channel (" << addr <<"). Sending default EPSV 1");
- snprintf(cbuf, 1024, "EPSV 1\r\n");
+ if (ftpState->ctrl.conn->local.IsIPv4()) {
+ debugs(9, 5, HERE << "Channel (" << ftpState->ctrl.conn->remote <<"). Sending default EPSV 1");
+ snprintf(cbuf, CTRL_BUFLEN, "EPSV 1\r\n");
ftpState->state = SENT_EPSV_1;
}
}
*/
#include "squid.h"
-#include "Store.h"
-#include "comm.h"
-#include "ICP.h"
-#include "HttpRequest.h"
-#include "acl/FilledChecklist.h"
-#include "acl/Acl.h"
#include "AccessLogEntry.h"
-#include "wordlist.h"
-#include "SquidTime.h"
-#include "SwapDir.h"
+#include "acl/Acl.h"
+#include "acl/FilledChecklist.h"
+#include "comm/Connection.h"
+#include "HttpRequest.h"
#include "icmp/net_db.h"
+#include "ICP.h"
#include "ip/Address.h"
+ #include "ip/tools.h"
#include "ipc/StartListening.h"
#include "rfc1738.h"
+#include "Store.h"
+#include "SquidTime.h"
+#include "SwapDir.h"
+#include "wordlist.h"
/// dials icpIncomingConnectionOpened call
class IcpListeningStartedDialer: public CallDialer,