示例#1
0
文件: log.cpp 项目: JGRennison/retcon
void Update_currentlogflags() {
	LOGT old_currentlogflags = currentlogflags;
	LOGT t_currentlogflags = LOGT::ZERO;
	for (auto &it : logfunclist) {
		t_currentlogflags |= it->lo_flags;
	}
	currentlogflags = t_currentlogflags;
	if ((old_currentlogflags ^ currentlogflags) & LOGT::CURLVERB) {
		for (auto &it : sm.connlist) {
			SetCurlHandleVerboseState(it.ch, currentlogflags & LOGT::CURLVERB);
		}
	}
	if (currentlogflags & LOGT::WXVERBOSE) {
		wxLog::SetLogLevel(wxLOG_Info);
	} else if (currentlogflags & LOGT::WXLOG) {
		wxLog::SetLogLevel(wxLOG_Message);
	} else {
		wxLog::SetLogLevel(wxLOG_FatalError);
	}
}
示例#2
0
bool socketmanager::AddConn(CURL* ch, std::unique_ptr<mcurlconn> cs) {
	if (asyncdns) {
		// This can conditionally steal cs, if it does it returns true and we stop here
		if (asyncdns->CheckAsync(ch, std::move(cs))) {
			return true;
		}
	}

	SetCurlHandleVerboseState(ch, currentlogflags & LOGT::CURLVERB);
	curl_easy_setopt(ch, CURLOPT_TIMEOUT, (cs->mcflags & mcurlconn::MCF::NOTIMEOUT) ? 0 : cs->timeout);
	curl_easy_setopt(ch, CURLOPT_PRIVATE, cs.get());
	curl_easy_setopt(ch, CURLOPT_ACCEPT_ENCODING, ""); //accept all enabled encodings
	if (currentlogflags & LOGT::SOCKTRACE) {
		curl_easy_setopt(ch, CURLOPT_SOCKOPTFUNCTION, &pre_connect_func);
		curl_easy_setopt(ch, CURLOPT_SOCKOPTDATA, cs.get());
	}
	if (gc.setproxy) {
		curl_easy_setopt(ch, CURLOPT_PROXY, gc.proxyurl.c_str());
		curl_easy_setopt(ch, CURLOPT_NOPROXY, gc.noproxylist.c_str());
		curl_easy_setopt(ch, CURLOPT_HTTPPROXYTUNNEL, gc.proxyhttptunnel ? 1 : 0);
	} else {
		curl_easy_setopt(ch, CURLOPT_PROXY, nullptr);
		curl_easy_setopt(ch, CURLOPT_NOPROXY, nullptr);
		curl_easy_setopt(ch, CURLOPT_HTTPPROXYTUNNEL, 0);
	}
	if (!gc.netiface.empty()) {
		curl_easy_setopt(ch, CURLOPT_INTERFACE, gc.netiface.c_str());
	} else {
		curl_easy_setopt(ch, CURLOPT_INTERFACE, nullptr);
	}

	connlist.push_back({ ch, std::move(cs) });

	bool ret = (CURLM_OK == curl_multi_add_handle(curlmulti, ch));
	curl_multi_socket_action(curlmulti, 0, 0, &curnumsocks);
	check_multi_info(&sm);
	return ret;
}