-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Add IServerAddressesFeature support #4685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c5999ad
Add IServerAddresses feature support
pakrym 2ba86d2
progress
pakrym a83611e
Fixup a file
pakrym 9fad785
Feedback
pakrym 4f451fc
More feedback
pakrym 7c14b28
Leftover tests
pakrym b7b83c2
More tests
pakrym 8026698
Merge branch 'master' into pakrym/iis-bindings
pakrym 0c1a6a8
Cleanup
pakrym 5792542
Update src/Servers/IIS/src/Microsoft.AspNetCore.Server.IIS/WebHostBui…
pakrym 5ec72f5
Leftover path
pakrym 773b196
Feedback
pakrym b5231c1
Merge remote-tracking branch 'origin/master' into pakrym/iis-bindings
pakrym fa9b7cb
Merge
pakrym ba5fd19
fix tests
pakrym File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
src/IISIntegration/src/AspNetCoreModuleV2/CommonLib/BindingInformation.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
#include "ConfigurationSource.h" | ||
#include "StringHelpers.h" | ||
#include "WebConfigConfigurationSource.h" | ||
|
||
class BindingInformation | ||
{ | ||
public: | ||
BindingInformation(std::wstring protocol, std::wstring host, std::wstring port) | ||
{ | ||
m_protocol = protocol; | ||
m_host = host; | ||
m_port = port; | ||
} | ||
|
||
std::wstring& QueryProtocol() | ||
{ | ||
return m_protocol; | ||
} | ||
|
||
std::wstring& QueryPort() | ||
{ | ||
return m_port; | ||
} | ||
|
||
std::wstring& QueryHost() | ||
{ | ||
return m_host; | ||
} | ||
|
||
static | ||
std::vector<BindingInformation> | ||
Load(const ConfigurationSource &configurationSource, const IHttpSite& pSite) | ||
{ | ||
std::vector<BindingInformation> items; | ||
|
||
const std::wstring runningSiteName = pSite.GetSiteName(); | ||
|
||
auto const siteSection = configurationSource.GetRequiredSection(CS_SITE_SECTION); | ||
auto sites = siteSection->GetCollection(); | ||
for (const auto& site: sites) | ||
{ | ||
auto siteName = site->GetRequiredString(L"name"); | ||
if (equals_ignore_case(runningSiteName, siteName)) | ||
{ | ||
auto bindings = site->GetRequiredSection(L"bindings")->GetCollection(); | ||
for (const auto& binding : bindings) | ||
{ | ||
const auto information = binding->GetRequiredString(L"bindingInformation"); | ||
pakrym marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const auto firstColon = information.find(L':') + 1; | ||
const auto lastColon = information.find_last_of(L':'); | ||
|
||
std::wstring host; | ||
// Check that : is not the last character | ||
if (lastColon != information.length() + 1) | ||
{ | ||
auto const afterLastColon = lastColon + 1; | ||
host = information.substr(afterLastColon, information.length() - afterLastColon); | ||
} | ||
if (host.length() == 0) | ||
{ | ||
host = L"*"; | ||
} | ||
|
||
items.emplace_back( | ||
binding->GetRequiredString(L"protocol"), | ||
host, | ||
information.substr(firstColon, lastColon - firstColon) | ||
); | ||
} | ||
} | ||
} | ||
|
||
return items; | ||
} | ||
|
||
static | ||
std::wstring Format(const std::vector<BindingInformation> bindings) | ||
{ | ||
std::wstring result; | ||
|
||
for (auto binding : bindings) | ||
{ | ||
result += binding.QueryProtocol() + L"://" + binding.QueryHost() + L":" + binding.QueryPort() + L";"; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
private: | ||
std::wstring m_protocol; | ||
std::wstring m_port; | ||
std::wstring m_host; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.