diff --git a/checkin_notes b/checkin_notes index 63705e6a01..b5e03cbbd2 100644 --- a/checkin_notes +++ b/checkin_notes @@ -1165,3 +1165,15 @@ David Feb 5 2008 sched/ Makefile.am trickle_handler.C + +David Feb 5 2008 + - Manager/client: add the ability to specify a port + in the manager's "select host" dialog. + Lets you connect over an SSH tunnel. + From Der Meister. + + clientgui/ + AdvancedFrame.cpp + MainDocument.cpp,h + lib/ + gui_rpc_client.C,h diff --git a/clientgui/AdvancedFrame.cpp b/clientgui/AdvancedFrame.cpp index ec0610ed6e..9383009816 100644 --- a/clientgui/AdvancedFrame.cpp +++ b/clientgui/AdvancedFrame.cpp @@ -1170,14 +1170,24 @@ void CAdvancedFrame::OnSelectComputer(wxCommandEvent& WXUNUSED(event)) { if (wxEmptyString == dlg.m_ComputerNameCtrl->GetValue()) { lRetVal = pDoc->Connect( wxT("localhost"), + GUI_RPC_PORT, wxEmptyString, TRUE, TRUE ); } else { - // Connect up to the remote machine + // Connect to the remote machine + wxString sHost = dlg.m_ComputerNameCtrl->GetValue(); + long lPort = GUI_RPC_PORT; + int iPos = sHost.find(_(":")); + if (iPos != -1) { + wxString sPort = sHost.substr(iPos + 1); + if (!sPort.ToLong(&lPort)) lPort = GUI_RPC_PORT; + sHost.erase(iPos); + } lRetVal = pDoc->Connect( - dlg.m_ComputerNameCtrl->GetValue(), + sHost, + (int)lPort, dlg.m_ComputerPasswordCtrl->GetValue(), TRUE, FALSE diff --git a/clientgui/MainDocument.cpp b/clientgui/MainDocument.cpp index 53b4541291..0707f200c4 100644 --- a/clientgui/MainDocument.cpp +++ b/clientgui/MainDocument.cpp @@ -59,6 +59,7 @@ CNetworkConnection::CNetworkConnection(CMainDocument* pDocument) : m_bReconnectOnError = false; m_bNewConnection = false; m_bUsedDefaultPassword = false; + m_iPort = GUI_RPC_PORT, m_iReadGUIRPCAuthFailure = 0; } @@ -157,9 +158,9 @@ void CNetworkConnection::Poll() { // timeout event right after boot-up. // if (IsComputerNameLocal(strComputer)) { - retval = m_pDocument->rpc.init_asynch(NULL, 60.0, true); + retval = m_pDocument->rpc.init_asynch(NULL, 60.0, true, m_iPort); } else { - retval = m_pDocument->rpc.init_asynch(strComputer.mb_str(), 60.0, false); + retval = m_pDocument->rpc.init_asynch(strComputer.mb_str(), 60.0, false, m_iPort); } if (!retval) { @@ -212,13 +213,17 @@ bool CNetworkConnection::IsComputerNameLocal(const wxString& strMachine) { } -int CNetworkConnection::SetComputer(const wxChar* szComputer, const wxChar* szPassword, const bool bUseDefaultPassword) { +int CNetworkConnection::SetComputer( + const wxChar* szComputer, const int iPort, const wxChar* szPassword, + const bool bUseDefaultPassword +) { m_strNewComputerName.Empty(); m_strNewComputerPassword.Empty(); m_bUseDefaultPassword = FALSE; m_bNewConnection = true; m_strNewComputerName = szComputer; + m_iPort = iPort; m_strNewComputerPassword = szPassword; m_bUseDefaultPassword = bUseDefaultPassword; return 0; @@ -478,12 +483,12 @@ int CMainDocument::ResetState() { } -int CMainDocument::Connect(const wxChar* szComputer, const wxChar* szComputerPassword, const bool bDisconnect, const bool bUseDefaultPassword) { +int CMainDocument::Connect(const wxChar* szComputer, int iPort, const wxChar* szComputerPassword, const bool bDisconnect, const bool bUseDefaultPassword) { if (bDisconnect) { m_pNetworkConnection->ForceReconnect(); } - m_pNetworkConnection->SetComputer(szComputer, szComputerPassword, bUseDefaultPassword); + m_pNetworkConnection->SetComputer(szComputer, iPort, szComputerPassword, bUseDefaultPassword); m_pNetworkConnection->FireReconnectEvent(); return 0; } diff --git a/clientgui/MainDocument.h b/clientgui/MainDocument.h index 7af7c6f7a6..02bcf67ede 100644 --- a/clientgui/MainDocument.h +++ b/clientgui/MainDocument.h @@ -60,7 +60,10 @@ public: int GetConnectingComputerName(wxString& strMachine); bool IsComputerNameLocal(const wxString& strMachine); int GetLocalPassword(wxString& strPassword); - int SetComputer(const wxChar* szComputer, const wxChar* szPassword, const bool bUseDefaultPassword); + int SetComputer( + const wxChar* szComputer, const int iPort, const wxChar* szPassword, + const bool bUseDefaultPassword + ); void SetStateError(); void SetStateErrorAuthentication(); void SetStateReconnecting(); @@ -87,6 +90,7 @@ private: wxString m_strConnectedComputerName; wxString m_strConnectedComputerPassword; wxString m_strConnectedComputerVersion; + int m_iPort; }; @@ -117,6 +121,7 @@ public: int Connect( const wxChar* szComputer, + const int iPort, const wxChar* szComputerPassword = wxEmptyString, const bool bDisconnect = FALSE, const bool bUseDefaultPassword = FALSE diff --git a/lib/gui_rpc_client.C b/lib/gui_rpc_client.C index 199751fc91..904d9ac14c 100644 --- a/lib/gui_rpc_client.C +++ b/lib/gui_rpc_client.C @@ -109,11 +109,13 @@ int RPC_CLIENT::init(const char* host, int port) { return 0; } -int RPC_CLIENT::init_asynch(const char* host, double _timeout, bool _retry) { +int RPC_CLIENT::init_asynch( + const char* host, double _timeout, bool _retry, int port +) { int retval; memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; - addr.sin_port = htons(GUI_RPC_PORT); + addr.sin_port = htons(port); retry = _retry; timeout = _timeout; diff --git a/lib/gui_rpc_client.h b/lib/gui_rpc_client.h index 28bc03cbb8..452ab22500 100644 --- a/lib/gui_rpc_client.h +++ b/lib/gui_rpc_client.h @@ -537,7 +537,9 @@ public: RPC_CLIENT(); ~RPC_CLIENT(); int init(const char* host, int port=0); - int init_asynch(const char* host, double timeout, bool retry); + int init_asynch( + const char* host, double timeout, bool retry, int port=GUI_RPC_PORT + ); // timeout == how long to wait until give up // If the caller (i.e. BOINC Manager) just launched the core client, // this should be large enough to allow the process to