Переглянути джерело

sftp: Make sftp works through HTTP proxy

Tatsuhiro Tsujikawa 10 роки тому
батько
коміт
21c328fc11
2 змінених файлів з 28 додано та 7 видалено
  1. 20 7
      src/FtpInitiateConnectionCommand.cc
  2. 8 0
      src/FtpTunnelResponseCommand.cc

+ 20 - 7
src/FtpInitiateConnectionCommand.cc

@@ -132,18 +132,31 @@ std::unique_ptr<Command> FtpInitiateConnectionCommand::createNextCommandProxied
 
   setConnectedAddrInfo(getRequest(), hostname, pooledSocket);
   if(proxyMethod == V_TUNNEL) {
+    if (getRequest()->getProtocol() == "sftp") {
+      return make_unique<SftpNegotiationCommand>
+        (getCuid(),
+         getRequest(),
+         getFileEntry(),
+         getRequestGroup(),
+         getDownloadEngine(),
+         pooledSocket,
+         SftpNegotiationCommand::SEQ_SFTP_OPEN);
+    }
+
     // options contains "baseWorkingDir"
     return make_unique<FtpNegotiationCommand>
       (getCuid(),
-        getRequest(),
-        getFileEntry(),
-        getRequestGroup(),
-        getDownloadEngine(),
-        pooledSocket,
-        FtpNegotiationCommand::SEQ_SEND_CWD_PREP,
-        options);
+       getRequest(),
+       getFileEntry(),
+       getRequestGroup(),
+       getDownloadEngine(),
+       pooledSocket,
+       FtpNegotiationCommand::SEQ_SEND_CWD_PREP,
+       options);
   }
 
+  assert(getRequest()->getProtocol() == "ftp");
+
   if(proxyMethod != V_GET) {
     assert(0);
     return nullptr;

+ 8 - 0
src/FtpTunnelResponseCommand.cc

@@ -40,6 +40,7 @@
 #include "Segment.h"
 #include "SocketCore.h"
 #include "SocketRecvBuffer.h"
+#include "SftpNegotiationCommand.h"
 
 namespace aria2 {
 
@@ -59,6 +60,13 @@ FtpTunnelResponseCommand::~FtpTunnelResponseCommand() {}
 
 std::unique_ptr<Command> FtpTunnelResponseCommand::getNextCommand()
 {
+  if (getRequest()->getProtocol() == "sftp") {
+    return make_unique<SftpNegotiationCommand>
+      (getCuid(), getRequest(), getFileEntry(),
+       getRequestGroup(), getDownloadEngine(),
+       getSocket());
+  }
+
   return make_unique<FtpNegotiationCommand>
     (getCuid(), getRequest(), getFileEntry(),
      getRequestGroup(), getDownloadEngine(),