2005-01-20 23:22:22 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
2004-01-30 22:19:19 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation;
|
|
|
|
// either version 2.1 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This software is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// To view the GNU Lesser General Public License visit
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// or write to the Free Software Foundation, Inc.,
|
|
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2004-01-30 22:19:19 +00:00
|
|
|
|
2005-08-16 20:48:21 +00:00
|
|
|
#include "network.h"
|
|
|
|
|
2006-12-14 20:44:39 +00:00
|
|
|
// FSM states for auto-update
|
|
|
|
|
|
|
|
#define AU_SS_INIT 0
|
|
|
|
// no get_screensaver_mode() yet
|
|
|
|
#define AU_SS_GOT 1
|
|
|
|
// got a get_screensaver_mode()
|
|
|
|
#define AU_SS_QUIT_REQ 2
|
|
|
|
// send a QUIT next time
|
|
|
|
#define AU_SS_QUIT_SENT 3
|
|
|
|
// QUIT sent
|
|
|
|
|
|
|
|
#define AU_MGR_INIT 0
|
|
|
|
#define AU_MGR_GOT 1
|
|
|
|
#define AU_MGR_QUIT_REQ 2
|
|
|
|
#define AU_MGR_QUIT_SENT 3
|
|
|
|
|
2004-01-21 07:07:16 +00:00
|
|
|
class GUI_RPC_CONN {
|
|
|
|
public:
|
|
|
|
int sock;
|
2005-03-07 06:09:04 +00:00
|
|
|
char nonce[256];
|
|
|
|
bool auth_needed;
|
2005-04-09 23:19:38 +00:00
|
|
|
// if true, don't allow operations other than authentication
|
|
|
|
bool is_local;
|
|
|
|
// connection is from local host
|
2006-12-14 20:44:39 +00:00
|
|
|
int au_ss_state;
|
|
|
|
int au_mgr_state;
|
|
|
|
|
2004-01-21 07:07:16 +00:00
|
|
|
GUI_RPC_CONN(int);
|
|
|
|
~GUI_RPC_CONN();
|
|
|
|
int handle_rpc();
|
2005-03-07 06:09:04 +00:00
|
|
|
void handle_auth1(MIOFILE&);
|
|
|
|
void handle_auth2(char*, MIOFILE&);
|
2004-01-21 07:07:16 +00:00
|
|
|
};
|
|
|
|
|
2005-03-07 06:09:04 +00:00
|
|
|
// authentication for GUI RPCs:
|
|
|
|
// 1) if a IPaddr-list file is found, accept only from those addrs
|
|
|
|
// 2) if a password file file is found, ALSO demand password auth
|
|
|
|
|
2004-01-21 07:07:16 +00:00
|
|
|
class GUI_RPC_CONN_SET {
|
2004-07-10 07:27:00 +00:00
|
|
|
std::vector<GUI_RPC_CONN*> gui_rpcs;
|
|
|
|
std::vector<int> allowed_remote_ip_addresses;
|
|
|
|
int get_allowed_hosts();
|
2005-03-07 06:09:04 +00:00
|
|
|
int get_password();
|
2004-07-10 07:27:00 +00:00
|
|
|
int insert(GUI_RPC_CONN*);
|
2004-01-21 07:07:16 +00:00
|
|
|
public:
|
2005-12-02 22:29:35 +00:00
|
|
|
int lsock;
|
2006-09-08 22:28:10 +00:00
|
|
|
double time_of_last_rpc_needing_network;
|
|
|
|
// time of the last RPC that needs network access to handle
|
2005-12-25 04:53:24 +00:00
|
|
|
|
2005-07-23 08:10:39 +00:00
|
|
|
GUI_RPC_CONN_SET();
|
2005-03-07 06:09:04 +00:00
|
|
|
char password[256];
|
2005-08-16 21:31:27 +00:00
|
|
|
void get_fdset(FDSET_GROUP&, FDSET_GROUP&);
|
2005-08-16 20:48:21 +00:00
|
|
|
void got_select(FDSET_GROUP&);
|
2004-05-05 21:15:34 +00:00
|
|
|
int init();
|
2006-07-17 16:38:53 +00:00
|
|
|
void close();
|
2006-09-08 22:28:10 +00:00
|
|
|
bool recent_rpc_needs_network(double interval);
|
2006-12-14 20:44:39 +00:00
|
|
|
void send_quits();
|
|
|
|
bool quits_sent();
|
2004-01-21 07:07:16 +00:00
|
|
|
};
|