Browse Source

Updating code to PuTTY 0.77 new local proxy implementation

Source commit: 2cb1dc43b06ee42ecdc13f21c774ce17328ef253
Martin Prikryl 3 years ago
parent
commit
45ce42b255

+ 10 - 1
source/core/SecureShell.cpp

@@ -448,6 +448,10 @@ void __fastcall TSecureShell::Open()
       PuttyFatalError(InitError);
     }
     FUI->Information(LoadStr(STATUS_CONNECT), true);
+    if (!Active && DebugAlwaysTrue(HasLocalProxy()))
+    {
+      FActive = true;
+    }
     Init();
 
     CheckConnection(CONNECTION_FAILED);
@@ -1614,6 +1618,11 @@ void __fastcall TSecureShell::SocketEventSelect(SOCKET Socket, HANDLE Event, boo
   }
 }
 //---------------------------------------------------------------------------
+bool TSecureShell::HasLocalProxy()
+{
+  return (FSessionData->ProxyMethod == pmCmd);
+}
+//---------------------------------------------------------------------------
 void __fastcall TSecureShell::UpdateSocket(SOCKET value, bool Enable)
 {
   if (!FActive && !Enable)
@@ -1637,7 +1646,7 @@ void __fastcall TSecureShell::UpdateSocket(SOCKET value, bool Enable)
     }
     else
     {
-      DebugAssert(FSessionData->ProxyMethod == pmCmd);
+      DebugAssert(HasLocalProxy());
     }
 
     if (Enable)

+ 1 - 0
source/core/SecureShell.h

@@ -111,6 +111,7 @@ private:
     const UnicodeString & StoredKeys, const UnicodeString & KeyStr, const UnicodeString & FingerprintMD5, const UnicodeString & FingerprintSHA256);
   UnicodeString StoreHostKey(
     const UnicodeString & Host, int Port, const UnicodeString & KeyType, const UnicodeString & KeyStr);
+  bool HasLocalProxy();
 
 protected:
   TCaptureOutputEvent FOnCaptureOutput;

+ 1 - 0
source/putty/windows/handle-io.c

@@ -530,6 +530,7 @@ struct handle *handle_output_new(struct callback_set * callback_set, HANDLE hand
     h->u.o.sentdata = sentdata;
     h->u.o.sentdata_param = h;
     h->u.o.flags = flags;
+    h->u.o.callback_set = callback_set; // WINSCP
 
     ensure_ready_event_setup(callback_set);
     { // WINSCP

+ 5 - 0
source/putty/windows/handle-socket.c

@@ -532,6 +532,11 @@ void setup_handle_socket(Socket *s, HANDLE send_H, HANDLE recv_H,
 
     hs->defer_close = hs->deferred_close = false;
 
+    #ifdef MPEXT
+    // WinSCP core uses do_select as signalization of connection up/down
+    do_select(hs->plug, INVALID_SOCKET, 1);
+    #endif
+
     queue_toplevel_callback(sk_handle_connect_success_callback, hs);
     } // WINSCP
 }