Skip to content

Commit d066756

Browse files
committed
Removed hard coded port 9999
1 parent 141d640 commit d066756

File tree

9 files changed

+71
-23
lines changed

9 files changed

+71
-23
lines changed

BrowserProxy/BrowserProxy.rc

0 Bytes
Binary file not shown.

FlashProxy/FlashProxy.cpp

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ FlashProxyModule::FlashProxyModule():
126126
m_encodeBuffer(),
127127
m_identity(Identity::Unknown),
128128
m_visibilityMask(0),
129+
m_port(9999),
129130
m_url(),
130131
m_userDataFolder(),
131132
m_aboutQuery(),
@@ -703,6 +704,27 @@ HRESULT STDMETHODCALLTYPE FlashProxyModule::put_Movie(BSTR pVal)
703704
if (FAILED(burl.Append(pVal, length)))
704705
return E_FAIL;
705706

707+
WCHAR scheme[10] = {0};
708+
WCHAR host[40] = {0};
709+
WCHAR path[1000] = {0};
710+
URL_COMPONENTS components;
711+
ZeroMemory(&components, sizeof(components));
712+
components.dwStructSize = sizeof(components);
713+
components.lpszScheme = scheme;
714+
components.dwSchemeLength = _countof(scheme);
715+
components.lpszHostName = host;
716+
components.dwHostNameLength = _countof(host);
717+
components.lpszUrlPath = path;
718+
components.dwUrlPathLength = _countof(path);
719+
720+
if (!InternetCrackUrl(burl, 0, ICU_DECODE, &components))
721+
return E_FAIL;
722+
723+
if (_wcsicmp(scheme, L"http") != 0 || components.nPort < 1024)
724+
return E_FAIL;
725+
726+
m_port = components.nPort;
727+
706728
WCHAR *name = wcsrchr(burl, L'/');
707729
if (name != nullptr)
708730
{
@@ -719,16 +741,19 @@ HRESULT STDMETHODCALLTYPE FlashProxyModule::put_Movie(BSTR pVal)
719741
m_identity = Identity::MessageBar;
720742
}
721743

722-
if (_wcsnicmp(burl, L"http://127.0.0.1:9999/", 22) == 0 || _wcsnicmp(burl, L"http://localhost:9999/", 22) == 0)
744+
if (_wcsicmp(host, L"127.0.0.1") == 0 || _wcsicmp(host, L"localhost") == 0)
723745
{
724-
CComBSTR burl2 = burl + 22;
725-
if (FAILED(burl2.Append(L"2.html")))
726-
return E_FAIL;
727-
728-
if (GetFileAttributes(burl2) != INVALID_FILE_ATTRIBUTES)
746+
if (path[0] == L'/')
729747
{
730-
if (FAILED(burl.Append(L"2")))
748+
CComBSTR bpath = path + 1;
749+
if (FAILED(bpath.Append(L"2.html")))
731750
return E_FAIL;
751+
752+
if (GetFileAttributes(bpath) != INVALID_FILE_ATTRIBUTES)
753+
{
754+
if (FAILED(burl.Append(L"2")))
755+
return E_FAIL;
756+
}
732757
}
733758
}
734759

@@ -827,8 +852,11 @@ HRESULT STDMETHODCALLTYPE FlashProxyModule::Invoke(HRESULT errorCode, ICoreWebVi
827852
hostObject.pdispVal = static_cast<IDispatch*>(this);
828853
m_view->AddHostObjectToScript(L"client", &hostObject);
829854

830-
m_view->AddWebResourceRequestedFilter(L"http://127.0.0.1:9999/*", COREWEBVIEW2_WEB_RESOURCE_CONTEXT_ALL);
831-
m_view->AddWebResourceRequestedFilter(L"http://localhost:9999/*", COREWEBVIEW2_WEB_RESOURCE_CONTEXT_ALL);
855+
WCHAR filterHost[40] = {0};
856+
_snwprintf_s(filterHost, _countof(filterHost), L"http://127.0.0.1:%u/*", m_port);
857+
m_view->AddWebResourceRequestedFilter(filterHost, COREWEBVIEW2_WEB_RESOURCE_CONTEXT_ALL);
858+
_snwprintf_s(filterHost, _countof(filterHost), L"http://localhost:%u/*", m_port);
859+
m_view->AddWebResourceRequestedFilter(filterHost, COREWEBVIEW2_WEB_RESOURCE_CONTEXT_ALL);
832860

833861
m_view->add_WebMessageReceived(Callback<ICoreWebView2WebMessageReceivedEventHandler>(
834862
[this](ICoreWebView2 *sender, ICoreWebView2WebMessageReceivedEventArgs *args) -> HRESULT
@@ -955,10 +983,29 @@ HRESULT FlashProxyModule::OnWebResourceRequested(ICoreWebView2 *sender, ICoreWeb
955983
CoTaskMemFree(url);
956984
}
957985

958-
if (_wcsnicmp(burl, L"http://127.0.0.1:9999/", 22) != 0 && _wcsnicmp(burl, L"http://localhost:9999/", 22) != 0)
986+
WCHAR scheme[10] = {0};
987+
WCHAR host[40] = {0};
988+
WCHAR path[1000] = {0};
989+
URL_COMPONENTS components;
990+
ZeroMemory(&components, sizeof(components));
991+
components.dwStructSize = sizeof(components);
992+
components.lpszScheme = scheme;
993+
components.dwSchemeLength = _countof(scheme);
994+
components.lpszHostName = host;
995+
components.dwHostNameLength = _countof(host);
996+
components.lpszUrlPath = path;
997+
components.dwUrlPathLength = _countof(path);
998+
999+
if (!InternetCrackUrl(burl, 0, ICU_DECODE, &components))
1000+
return E_FAIL;
1001+
1002+
if (_wcsicmp(scheme, L"http") != 0 || components.nPort != m_port)
1003+
return S_FALSE;
1004+
1005+
if (_wcsicmp(host, L"127.0.0.1") != 0 && _wcsicmp(host, L"localhost") != 0)
9591006
return S_FALSE;
9601007

961-
if (wcscmp(burl + 22, L"favicon.ico") == 0)
1008+
if (wcscmp(path, L"/favicon.ico") == 0)
9621009
{
9631010
CComPtr<ICoreWebView2WebResourceResponse> response;
9641011
if (FAILED(m_environment->CreateWebResourceResponse(nullptr, 404, L"Not Found", L"", &response)) || response == nullptr)

FlashProxy/FlashProxy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ class FlashProxyModule: public ATL::CAtlDllModuleT<FlashProxyModule>,
240240
WCHAR m_encodeBuffer[10000];
241241
Identity m_identity;
242242
UINT32 m_visibilityMask;
243+
INTERNET_PORT m_port;
243244
CComBSTR m_url;
244245
CComBSTR m_userDataFolder;
245246
CComBSTR m_aboutQuery;

FlashProxy/FlashProxy.rc

0 Bytes
Binary file not shown.

FlashProxy/FlashProxy.vcxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
<SubSystem>Windows</SubSystem>
104104
<ModuleDefinitionFile>.\FlashProxy.def</ModuleDefinitionFile>
105105
<RegisterOutput>false</RegisterOutput>
106-
<AdditionalDependencies>version.lib;%(AdditionalDependencies)</AdditionalDependencies>
106+
<AdditionalDependencies>version.lib;wininet.lib;%(AdditionalDependencies)</AdditionalDependencies>
107107
</Link>
108108
</ItemDefinitionGroup>
109109
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -139,7 +139,7 @@
139139
<EnableCOMDATFolding>true</EnableCOMDATFolding>
140140
<OptimizeReferences>true</OptimizeReferences>
141141
<RegisterOutput>false</RegisterOutput>
142-
<AdditionalDependencies>version.lib;%(AdditionalDependencies)</AdditionalDependencies>
142+
<AdditionalDependencies>version.lib;wininet.lib;%(AdditionalDependencies)</AdditionalDependencies>
143143
</Link>
144144
</ItemDefinitionGroup>
145145
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Develop|Win32'">
@@ -176,7 +176,7 @@
176176
<EnableCOMDATFolding>true</EnableCOMDATFolding>
177177
<OptimizeReferences>true</OptimizeReferences>
178178
<RegisterOutput>false</RegisterOutput>
179-
<AdditionalDependencies>version.lib;%(AdditionalDependencies)</AdditionalDependencies>
179+
<AdditionalDependencies>version.lib;wininet.lib;%(AdditionalDependencies)</AdditionalDependencies>
180180
</Link>
181181
</ItemDefinitionGroup>
182182
<ItemGroup>

Installer/Installer.vdproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2855,15 +2855,15 @@
28552855
{
28562856
"Name" = "8:Microsoft Visual Studio"
28572857
"ProductName" = "8:ThereEdge"
2858-
"ProductCode" = "8:{F61D955D-21C1-4019-A2C2-12769EE4BDBB}"
2859-
"PackageCode" = "8:{C2DD93F1-8D6C-4E16-A716-BC95F4905F7B}"
2858+
"ProductCode" = "8:{CD853BBC-AA41-4EFC-9BCE-9CEE50E59180}"
2859+
"PackageCode" = "8:{3172D96B-34FA-4A03-915A-61760D6A8879}"
28602860
"UpgradeCode" = "8:{887059E3-E645-44A2-AE95-E602E27BD74F}"
28612861
"AspNetVersion" = "8:2.0.50727.0"
28622862
"RestartWWWService" = "11:FALSE"
28632863
"RemovePreviousVersions" = "11:TRUE"
28642864
"DetectNewerInstalledVersion" = "11:TRUE"
28652865
"InstallAllUsers" = "11:TRUE"
2866-
"ProductVersion" = "8:1.0.7"
2866+
"ProductVersion" = "8:1.0.8"
28672867
"Manufacturer" = "8:Hmph!"
28682868
"ARPHELPTELEPHONE" = "8:"
28692869
"ARPHELPLINK" = "8:"

SetupThereEdge/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# -*- coding: utf-8 -*-
22

3-
VERSION = '1.0.7'
3+
VERSION = '1.0.8'

SetupThereEdge/version.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#
33
VSVersionInfo(
44
ffi=FixedFileInfo(
5-
filevers=(1, 0, 7, 0),
6-
prodvers=(1, 0, 7, 0),
5+
filevers=(1, 0, 8, 0),
6+
prodvers=(1, 0, 8, 0),
77
mask=0x3f,
88
flags=0x0,
99
OS=0x40004,
@@ -16,12 +16,12 @@ VSVersionInfo(
1616
StringTable(u'040904b0', [
1717
StringStruct(u'CompanyName', u'Hmph!'),
1818
StringStruct(u'FileDescription', u'Setup helper for There Edge'),
19-
StringStruct(u'FileVersion', u'1.0.7.0'),
19+
StringStruct(u'FileVersion', u'1.0.8.0'),
2020
StringStruct(u'InternalName', u'SetupThereEdge.exe'),
2121
StringStruct(u'LegalCopyright', u'(c) Hmph!'),
2222
StringStruct(u'OriginalFilename', u'SetupThereEdge.exe'),
2323
StringStruct(u'ProductName', u'There Edge Setup Helper'),
24-
StringStruct(u'ProductVersion', u'1.0.7.0')
24+
StringStruct(u'ProductVersion', u'1.0.8.0')
2525
])
2626
]),
2727
VarFileInfo([

0 commit comments

Comments
 (0)