forked from BOINC/boinc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcs_proxy.cpp
90 lines (83 loc) · 2.95 KB
/
cs_proxy.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2009 University of California
//
// BOINC 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 3 of the License, or (at your option) any later version.
//
// BOINC 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.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
#include "cpp.h"
#ifdef _WIN32
#include "boinc_win.h"
#else
#include "config.h"
#endif
#include "common_defs.h"
#include "client_msgs.h"
#include "cs_proxy.h"
PROXY_INFO gui_proxy_info;
PROXY_INFO env_var_proxy_info;
PROXY_INFO config_proxy_info;
PROXY_INFO working_proxy_info;
static void show_proxy_info(PROXY_INFO& p) {
if (p.use_http_proxy) {
if (p.http_server_port) {
msg_printf(NULL, MSG_INFO, "Using HTTP proxy %s:%d",
p.http_server_name, p.http_server_port
);
} else {
msg_printf(NULL, MSG_INFO, "Using HTTP proxy %s",
p.http_server_name
);
}
}
if (p.use_socks_proxy) {
if (p.socks_server_port) {
msg_printf(NULL, MSG_INFO, "Using SOCKS proxy %s:%d",
p.socks_server_name, p.socks_server_port
);
} else {
msg_printf(NULL, MSG_INFO, "Using SOCKS proxy %s",
p.socks_server_name
);
}
}
if (!p.use_http_proxy && !p.use_socks_proxy) {
msg_printf(NULL, MSG_INFO, "Not using a proxy");
}
}
void select_proxy_info() {
if (gui_proxy_info.present) {
working_proxy_info = gui_proxy_info;
msg_printf(0, MSG_INFO, "Using proxy info from GUI");
if (env_var_proxy_info.present) {
msg_printf(0, MSG_INFO, "Proxy info env vars overridden by GUI");
}
if (config_proxy_info.present) {
msg_printf(0, MSG_INFO, "Config file proxy info overridden by GUI");
}
} else if (config_proxy_info.present) {
working_proxy_info = config_proxy_info;
msg_printf(0, MSG_INFO, "Using proxy info from cc_config.xml");
if (env_var_proxy_info.present) {
msg_printf(0, MSG_INFO, "Proxy info env vars overridden by GUI");
}
} else if (env_var_proxy_info.present) {
working_proxy_info = env_var_proxy_info;
msg_printf(0, MSG_INFO, "Using proxy info from environment variables");
}
show_proxy_info(working_proxy_info);
}
void proxy_info_startup() {
select_proxy_info();
working_proxy_info.need_autodetect_proxy_settings = true;
working_proxy_info.have_autodetect_proxy_settings = false;
}