- 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.

svn path=/trunk/boinc/; revision=14681
This commit is contained in:
David Anderson 2008-02-06 00:10:31 +00:00
parent dcb2c614a4
commit 6b74075469
6 changed files with 47 additions and 11 deletions

View File

@ -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

View File

@ -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

View File

@ -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;
}

View File

@ -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

View File

@ -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;

View File

@ -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