00001 // This file is part of BOINC. 00002 // http://boinc.berkeley.edu 00003 // Copyright (C) 2008 University of California 00004 // 00005 // BOINC is free software; you can redistribute it and/or modify it 00006 // under the terms of the GNU Lesser General Public License 00007 // as published by the Free Software Foundation, 00008 // either version 3 of the License, or (at your option) any later version. 00009 // 00010 // BOINC is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00013 // See the GNU Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with BOINC. If not, see <http://www.gnu.org/licenses/>. 00017 00018 #include "network.h" 00019 #include "acct_setup.h" 00020 00021 // FSM states for auto-update 00022 00023 #define AU_SS_INIT 0 00024 // no get_screensaver_mode() yet 00025 #define AU_SS_GOT 1 00026 // got a get_screensaver_mode() 00027 #define AU_SS_QUIT_REQ 2 00028 // send a QUIT next time 00029 #define AU_SS_QUIT_SENT 3 00030 // QUIT sent 00031 00032 #define AU_MGR_INIT 0 00033 #define AU_MGR_GOT 1 00034 #define AU_MGR_QUIT_REQ 2 00035 #define AU_MGR_QUIT_SENT 3 00036 00037 class GUI_RPC_CONN { 00038 public: 00039 int sock; 00040 char nonce[256]; 00042 bool auth_needed; 00043 bool got_auth1; 00046 bool got_auth2; 00049 bool sent_unauthorized; 00051 bool is_local; 00052 int au_ss_state; 00053 int au_mgr_state; 00054 GUI_HTTP gui_http; 00055 GET_PROJECT_CONFIG_OP get_project_config_op; 00056 LOOKUP_ACCOUNT_OP lookup_account_op; 00057 CREATE_ACCOUNT_OP create_account_op; 00058 00059 GUI_RPC_CONN(int); 00060 ~GUI_RPC_CONN(); 00061 int handle_rpc(); 00062 void handle_auth1(MIOFILE&); 00063 int handle_auth2(char*, MIOFILE&); 00064 void handle_get_project_config(char* buf, MIOFILE& fout); 00065 void handle_get_project_config_poll(char*, MIOFILE& fout); 00066 void handle_lookup_account(char* buf, MIOFILE& fout); 00067 void handle_lookup_account_poll(char*, MIOFILE& fout); 00068 void handle_create_account(char* buf, MIOFILE& fout); 00069 void handle_create_account_poll(char*, MIOFILE& fout); 00070 }; 00071 00072 // authentication for GUI RPCs: 00073 // 1) if a IPaddr-list file is found, accept only from those addrs 00074 // 2) if a password file file is found, ALSO demand password auth 00075 00076 class GUI_RPC_CONN_SET { 00077 std::vector<GUI_RPC_CONN*> gui_rpcs; 00078 std::vector<int> allowed_remote_ip_addresses; 00079 int get_allowed_hosts(); 00080 int get_password(); 00081 int insert(GUI_RPC_CONN*); 00082 bool check_allowed_list(int ip_addr); 00083 bool remote_hosts_file_exists; 00084 public: 00085 int lsock; 00087 double time_of_last_rpc_needing_network; 00088 00089 GUI_RPC_CONN_SET(); 00090 char password[256]; 00091 void get_fdset(FDSET_GROUP&, FDSET_GROUP&); 00092 void got_select(FDSET_GROUP&); 00093 int init(bool last_time); 00094 void close(); 00095 bool recent_rpc_needs_network(double interval); 00096 void send_quits(); 00097 bool quits_sent(); 00098 bool poll(); 00099 };
1.5.6