client (Win): add config option to not do proxy autodetect

This commit is contained in:
David Anderson 2016-07-25 15:41:43 -07:00
parent cea0709881
commit 51257b9f61
3 changed files with 43 additions and 24 deletions

View File

@ -179,7 +179,7 @@ static LRESULT CALLBACK WindowsMonitorSystemPowerWndProc(
// PBT_APMBATTERYLOW
// PBT_APMPOWERSTATUSCHANGE
// PBT_APMOEMEVENT
// PBT_APMRESUMEAUTOMATIC
// PBT_APMRESUMEAUTOMATIC
case WM_POWERBROADCAST:
switch(wParam) {
// System is preparing to suspend. This is valid on
@ -277,6 +277,7 @@ static DWORD WINAPI WindowsMonitorSystemPowerThread( LPVOID ) {
}
// Detect any proxy configuration settings automatically.
//
static void windows_detect_autoproxy_settings() {
if (log_flags.proxy_debug) {
post_sysmon_msg("[proxy] automatic proxy check in progress");
@ -332,7 +333,7 @@ static void windows_detect_autoproxy_settings() {
// Trim string if more than one proxy is defined
// proxy list is defined as:
// ([<scheme>=][<scheme>"://"]<server>[":"<port>])
// Find and erase first delimeter type.
pos = proxy.find(';');
if (pos != -1 ) {
@ -424,14 +425,16 @@ int initialize_system_monitor(int /*argc*/, char** /*argv*/) {
}
}
// Create a window to receive system power events.
// Create a thread to receive system power events.
//
g_hWindowsMonitorSystemPowerThread = CreateThread(
NULL,
0,
WindowsMonitorSystemPowerThread,
NULL,
0,
NULL);
NULL
);
if (!g_hWindowsMonitorSystemPowerThread) {
g_hWindowsMonitorSystemPowerThread = NULL;
@ -439,16 +442,20 @@ int initialize_system_monitor(int /*argc*/, char** /*argv*/) {
}
// Create a thread to handle proxy auto-detection.
g_hWindowsMonitorSystemProxyThread = CreateThread(
NULL,
0,
WindowsMonitorSystemProxyThread,
NULL,
0,
NULL);
//
if (!cc_config.no_autodetect) {
g_hWindowsMonitorSystemProxyThread = CreateThread(
NULL,
0,
WindowsMonitorSystemProxyThread,
NULL,
0,
NULL
);
if (!g_hWindowsMonitorSystemProxyThread) {
g_hWindowsMonitorSystemProxyThread = NULL;
if (!g_hWindowsMonitorSystemProxyThread) {
g_hWindowsMonitorSystemProxyThread = NULL;
}
}
return 0;
@ -525,14 +532,17 @@ void WINAPI BOINCServiceMain(DWORD /*dwArgc*/, LPTSTR * /*lpszArgv*/) {
// register our service control handler:
//
sshStatusHandle = RegisterServiceCtrlHandler( TEXT(SZSERVICENAME), BOINCServiceCtrl);
if (!sshStatusHandle)
if (!sshStatusHandle) {
goto cleanup;
}
if (!ReportStatus(
SERVICE_RUNNING, // service state
ERROR_SUCCESS, // exit code
0)) // wait hint
0) // wait hint
){
goto cleanup;
}
dwErr = boinc_main_loop();
@ -638,10 +648,11 @@ BOOL ReportStatus(
static DWORD dwCheckPoint = 1;
BOOL fResult = TRUE;
if (dwCurrentState == SERVICE_START_PENDING)
if (dwCurrentState == SERVICE_START_PENDING) {
ssStatus.dwControlsAccepted = 0;
else
} else {
ssStatus.dwControlsAccepted = SERVICE_ACCEPTED_ACTIONS;
}
ssStatus.dwCurrentState = dwCurrentState;
ssStatus.dwWin32ExitCode = dwWin32ExitCode;
@ -745,7 +756,8 @@ VOID LogEventWarningMessage(LPTSTR lpszMsg) {
2, // strings in lpszStrings
0, // no bytes of raw data
(LPCSTR*)lpszStrings, // array of error strings
NULL); // no raw data
NULL // no raw data
);
(VOID) DeregisterEventSource(hEventSource);
}
@ -785,9 +797,9 @@ VOID LogEventInfoMessage(LPTSTR lpszMsg) {
2, // strings in lpszStrings
0, // no bytes of raw data
(LPCSTR*)lpszStrings, // array of error strings
NULL); // no raw data
NULL // no raw data
);
(VOID) DeregisterEventSource(hEventSource);
}
}

View File

@ -42,6 +42,7 @@ int PROXY_INFO::parse(XML_PARSER& xp) {
if (xp.parse_str("http_user_name", http_user_name,sizeof(http_user_name))) continue;
if (xp.parse_str("http_user_passwd", http_user_passwd,sizeof(http_user_passwd))) continue;
if (xp.parse_str("no_proxy", noproxy_hosts, sizeof(noproxy_hosts))) continue;
if (xp.parse_bool("no_autodetect", no_autodetect)) continue;
}
return ERR_XML_PARSE;
}
@ -74,7 +75,8 @@ int PROXY_INFO::write(MIOFILE& out) {
" <socks5_user_passwd>%s</socks5_user_passwd>\n"
" <http_user_name>%s</http_user_name>\n"
" <http_user_passwd>%s</http_user_passwd>\n"
" <no_proxy>%s</no_proxy>\n",
" <no_proxy>%s</no_proxy>\n"
" <no_autodetect>%d</no_autodetect>\n",
use_http_proxy?" <use_http_proxy/>\n":"",
use_socks_proxy?" <use_socks_proxy/>\n":"",
use_http_auth?" <use_http_auth/>\n":"",
@ -86,7 +88,8 @@ int PROXY_INFO::write(MIOFILE& out) {
s5up,
hun,
hup,
noproxy_hosts
noproxy_hosts,
no_autodetect?1:0
);
if (strlen(autodetect_server_name)) {
out.printf(
@ -119,6 +122,7 @@ void PROXY_INFO::clear() {
safe_strcpy(http_user_name, "");
safe_strcpy(http_user_passwd, "");
safe_strcpy(noproxy_hosts, "");
no_autodetect = false;
safe_strcpy(autodetect_server_name, "");
autodetect_proxy_supported = false;
need_autodetect_proxy_settings = false;
@ -126,4 +130,3 @@ void PROXY_INFO::clear() {
autodetect_port = 80;
autodetect_protocol = 0;
}

View File

@ -50,12 +50,16 @@ struct PROXY_INFO {
//
char noproxy_hosts[256];
// don't autodetect proxy (Win)
//
bool no_autodetect;
// On Windows, if neither HTTP nor SOCKS proxy is specified,
// we try the "autodetect" mechanism.
// If it gets anything, the info is filled in below
//
bool autodetect_proxy_supported;
// if true, some mechinism for detecting proxy servers is
// if true, some mechanism for detecting proxy servers is
// supported by the client.
int autodetect_protocol;
// URL_PROTOCOL_SOCKS, URL_PROTOCOL_HTTP, or URL_PROTOCOL_HTTPS