Skip to content
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

Correct hostname retrieval from Source::getHostname #38309

Merged
merged 4 commits into from
Jul 16, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Utilities/XrdAdaptor/src/XrdSource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,12 @@ Source::Source(timespec now, std::unique_ptr<XrdCl::File> fh, const std::string
}

bool Source::getHostname(const std::string &id, std::string &hostname) {
size_t pos = id.find(':');
size_t pos = id.find_last_of(':');
hostname = id;
if ((pos != std::string::npos) && (pos > 0)) {
hostname = id.substr(0, pos);
hostname.erase(remove(hostname.begin(), hostname.end(), ']'), hostname.end());
hostname.erase(remove(hostname.begin(), hostname.end(), '['), hostname.end());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So your intent is to change something like [2001:760:4205:128::128:232]:1094 to be 2001:760:4205:128::128:232 ?

Would it make sense to restrict the '[' to be at the beginning of the string and ']' to be at the end in order to remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the commit slipped in the PR. You can skip those changes. Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@4quarks Could you drop the commit then? (that is pretty much the only way for us to "skip changes")

}

bool retval = true;
Expand Down