diff --git a/Proxydomo.sln b/Proxydomo.sln index 66aee14..4e896df 100644 --- a/Proxydomo.sln +++ b/Proxydomo.sln @@ -1,7 +1,7 @@ ο»Ώ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26228.4 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28803.352 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Proxydomo", "Proxydomo\Proxydomo.vcxproj", "{DDADC3EE-73B1-4DED-9073-F4AF4755B6D4}" ProjectSection(ProjectDependencies) = postProject @@ -68,4 +68,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2026CDD7-49F8-40E4-94ED-155D031FE97A} + EndGlobalSection EndGlobal diff --git a/Proxydomo/AppConst.h b/Proxydomo/AppConst.h index 98ee588..fad2072 100644 --- a/Proxydomo/AppConst.h +++ b/Proxydomo/AppConst.h @@ -39,7 +39,7 @@ #endif /// ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚Μƒo[ƒWƒ‡ƒ“ -#define APP_VERSION _T("1.108") +#define APP_VERSION _T("1.109") diff --git a/Proxydomo/BlockListDatabase.cpp b/Proxydomo/BlockListDatabase.cpp index 84a49fa..ab4d120 100644 --- a/Proxydomo/BlockListDatabase.cpp +++ b/Proxydomo/BlockListDatabase.cpp @@ -374,7 +374,7 @@ bool CBlockListDatabase::ManageBlockListInfoAPI(const CUrl& url, SocketIF* sockB "Connection: close" + CRLF CRLF; sendInBuf += content; - while (sockBrowser->Write(sendInBuf.data(), sendInBuf.length())); + while (sockBrowser->Write(sendInBuf.data(), sendInBuf.length()) > 0); sockBrowser->Close(); return true; @@ -420,7 +420,7 @@ bool CBlockListDatabase::ManageBlockListInfoAPI(const CUrl& url, SocketIF* sockB "Connection: close" + CRLF CRLF; sendInBuf += content; - while (sockBrowser->Write(sendInBuf.data(), sendInBuf.length())); + while (sockBrowser->Write(sendInBuf.data(), sendInBuf.length()) > 0); sockBrowser->Close(); return true; } diff --git a/Proxydomo/FilterOwner.cpp b/Proxydomo/FilterOwner.cpp index 7f2e92b..6872ab3 100644 --- a/Proxydomo/FilterOwner.cpp +++ b/Proxydomo/FilterOwner.cpp @@ -49,7 +49,7 @@ void CFilterOwner::Reset() variables.clear(); contactHost.clear(); - rdirMode = 0; + rdirMode = RedirectMode::kNone; rdirToHost.clear(); outHeaders.clear(); diff --git a/Proxydomo/FilterOwner.h b/Proxydomo/FilterOwner.h index 462ed4c..900832f 100644 --- a/Proxydomo/FilterOwner.h +++ b/Proxydomo/FilterOwner.h @@ -55,7 +55,11 @@ class CFilterOwner std::wstring contactHost; // can be overridden by $SETPROXY std::wstring rdirToHost; // set by $RDIR and $JUMP - int rdirMode; // 0: 302 response, 1: transparent + enum class RedirectMode { + kNone, + kJump, // 302 response + kRdir, // transparent + } rdirMode; bool bypassIn; // tells if we can filter incoming headers bool bypassOut; // tells if we can filter outgoing headers diff --git a/Proxydomo/Nodes_.cpp b/Proxydomo/Nodes_.cpp index 5c79e78..e0be00a 100644 --- a/Proxydomo/Nodes_.cpp +++ b/Proxydomo/Nodes_.cpp @@ -1419,14 +1419,14 @@ const UChar* CNode_Command::match(const UChar* start, const UChar* stop, MatchDa case CMD_JUMP: owner.rdirToHost = CExpander::expand(m_content, filter); CUtil::trim(owner.rdirToHost); - owner.rdirMode = 0; + owner.rdirMode = CFilterOwner::RedirectMode::kJump; CLog::FilterEvent(kLogFilterJump, owner.requestNumber, UTF8fromUTF16(filter.title), UTF8fromUTF16(owner.rdirToHost)); break; case CMD_RDIR: owner.rdirToHost = CExpander::expand(m_content, filter); CUtil::trim(owner.rdirToHost); - owner.rdirMode = 1; + owner.rdirMode = CFilterOwner::RedirectMode::kRdir; CLog::FilterEvent(kLogFilterRdir, owner.requestNumber, UTF8fromUTF16(filter.title), UTF8fromUTF16(owner.rdirToHost)); break; diff --git a/Proxydomo/RequestManager.cpp b/Proxydomo/RequestManager.cpp index 204880d..e1efa3b 100644 --- a/Proxydomo/RequestManager.cpp +++ b/Proxydomo/RequestManager.cpp @@ -438,7 +438,7 @@ void CRequestManager::_ProcessOutHeaderFilter() if (changeHost) m_filterOwner.contactHost = m_filterOwner.url.getHostPort(); } } - if (m_filterOwner.rdirToHost.size() > 0 && m_filterOwner.rdirMode == 1) { + if (m_filterOwner.rdirToHost.size() > 0 && m_filterOwner.rdirMode == CFilterOwner::RedirectMode::kRdir) { if (CUrl(m_filterOwner.rdirToHost).getBypassOut()) break; } @@ -612,9 +612,10 @@ void CRequestManager::_ProcessOut() // CONNECTƒŠƒNƒGƒXƒg‚ΝƒŠƒ_ƒCƒŒƒNƒg‚΅‚Θ‚’‚ζ‚€‚Ι‚·‚ι if (m_requestLine.method == "CONNECT" && m_filterOwner.killed == false && m_filterOwner.rdirToHost.size() > 0) { WARN_LOG << L"CONNECT redirect clear, src : " << m_filterOwner.url.getHost() - << L" rdirToHost : " << m_filterOwner.rdirToHost << L" rdirMode : " << m_filterOwner.rdirMode; + << L" rdirToHost : " << m_filterOwner.rdirToHost + << L" rdirMode : " << static_cast(m_filterOwner.rdirMode); m_filterOwner.rdirToHost.clear(); - m_filterOwner.rdirMode = 0; + m_filterOwner.rdirMode = CFilterOwner::RedirectMode::kNone; } // If we haven't connected to ths host yet, we do it now. @@ -983,15 +984,23 @@ void CRequestManager::_ConnectWebsite() bool CRequestManager::_HandleLocalPtron() { + // $JUMP( local.ptron/... )‚Ν–³Ž‹‚·‚ι + if (m_filterOwner.rdirMode == CFilterOwner::RedirectMode::kJump && + CUtil::noCaseBeginsWith(L"http://local.ptron", m_filterOwner.rdirToHost)) { + return false; + } + if (m_filterOwner.url.getHost() == L"local.ptron") { + if (m_filterOwner.rdirMode != CFilterOwner::RedirectMode::kNone) { + WARN_LOG << L"_HandleLocalPtron override rdirToHost : " << m_filterOwner.rdirToHost + << L" rdirMode : " << static_cast(m_filterOwner.rdirMode); + } m_filterOwner.rdirToHost = m_filterOwner.url.getUrl(); } if (CUtil::noCaseBeginsWith(L"http://local.ptron", m_filterOwner.rdirToHost)) { - WARN_LOG << L"rdirToHost is local.ptron : " << m_filterOwner.rdirToHost; - //m_filterOwner.rdirToHost = L"http://file//./html" + CUrl(m_filterOwner.rdirToHost).getPath(); + m_filterOwner.rdirToHost = L"http://file//./html" + CUrl(m_filterOwner.rdirToHost).getPath(); } - // https://local.ptron/ ‚ւ̐ڑ± if (CSettings::s_SSLFilter && CUtil::noCaseBeginsWith(L"https://local.ptron", m_filterOwner.rdirToHost)) { wstring subpath; @@ -1080,7 +1089,7 @@ bool CRequestManager::_HandleLocalPtron() // ƒtƒHƒ‹ƒ_‚ͺ‘Άέ‚·‚ι‚©‚Β URL‚Μ––”φ‚ͺ '/' ‚ŏI‚ν‚Α‚Δ‚’‚Θ‚―‚κ‚Ξ ƒtƒHƒ‹ƒ_–Ό + L'/' ‚ΦƒŠƒ_ƒCƒŒƒNƒg‚³‚Ή‚ι if (filepath.native().back() != L'\\') { m_filterOwner.rdirToHost = L"http://local.ptron/" + filepath.native().substr(7) + L'/'; - m_filterOwner.rdirMode = 0; + m_filterOwner.rdirMode = CFilterOwner::RedirectMode::kJump; return false; } @@ -1119,7 +1128,7 @@ bool CRequestManager::_HandleLocalPtron() bool CRequestManager::_HandleRedirectToHost() { // Test for non-transparent redirection ($JUMP) - if (m_filterOwner.rdirToHost.size() > 0 && m_filterOwner.rdirMode == 0) { + if (m_filterOwner.rdirToHost.size() > 0 && m_filterOwner.rdirMode == CFilterOwner::RedirectMode::kJump) { // We'll keep browser's socket, for persistent connections, and // continue processing outgoing data (which will not be moved to // send buffer). @@ -1139,7 +1148,7 @@ bool CRequestManager::_HandleRedirectToHost() // Test for transparent redirection to URL ($RDIR) // Note: new URL will not go through URL* OUT filters - if (m_filterOwner.rdirToHost.size() > 0 && m_filterOwner.rdirMode == 1) { + if (m_filterOwner.rdirToHost.size() > 0 && m_filterOwner.rdirMode == CFilterOwner::RedirectMode::kRdir) { // Change URL m_filterOwner.url.parseUrl(m_filterOwner.rdirToHost); @@ -1251,7 +1260,7 @@ void CRequestManager::_ProcessInHeaderFilter() m_filterOwner.rdirToHost = L"http://file//./html/killed.gif"; else m_filterOwner.rdirToHost = L"http://file//./html/killed.html"; - m_filterOwner.rdirMode = 0; // (to use non-transp code below) + m_filterOwner.rdirMode = CFilterOwner::RedirectMode::kJump; // (to use non-transp code below) break; } } diff --git a/Proxydomo/proximodo/expander.cpp b/Proxydomo/proximodo/expander.cpp index a1e54c0..fb92c6e 100644 --- a/Proxydomo/proximodo/expander.cpp +++ b/Proxydomo/proximodo/expander.cpp @@ -294,14 +294,14 @@ std::wstring CExpander::expand(const std::wstring& pattern, CFilter& filter) { filter.owner.rdirToHost = expand(content, filter); CUtil::trim(filter.owner.rdirToHost); - filter.owner.rdirMode = 0; + filter.owner.rdirMode = CFilterOwner::RedirectMode::kJump; CLog::FilterEvent(kLogFilterJump, filter.owner.requestNumber, UTF8fromUTF16(filter.title), UTF8fromUTF16(filter.owner.rdirToHost)); } else if (command == L"RDIR") { filter.owner.rdirToHost = expand(content, filter); CUtil::trim(filter.owner.rdirToHost); - filter.owner.rdirMode = 1; + filter.owner.rdirMode = CFilterOwner::RedirectMode::kRdir; CLog::FilterEvent(kLogFilterRdir, filter.owner.requestNumber, UTF8fromUTF16(filter.title), UTF8fromUTF16(filter.owner.rdirToHost)); } else if (command == L"FILTER") {