std: net: Add function to return the system hostname by orowith2os · Pull Request #135141 · rust-lang/rust (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation
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
[ Show hidden characters]({{ revealButtonHref }})
Resolves rust-lang/libs-team#330
Tracking issue: #135142
Now you can retrieve the system hostname, without relying on anything other than std
!
This is my first pull request to the Rust standard library (or anything inside rust-lang/rust, period, quite possible rust-lang itself), so there are bound to be issues. I'll try my best to resolve them.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @joboet (or someone else) some time within the next two weeks.
Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review
and S-waiting-on-author
) stays updated, invoking these commands when appropriate:
@rustbot author
: the review is finished, PR author should check the comments and take action accordingly@rustbot review
: the author is ready for a review, this PR will be queued again in the reviewer's queue
rustbot added S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
Relevant to the library team, which will review and decide on the PR/issue.
labels
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
forgive all the updates, I was having troubles updating my branch properly. Figured it out.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks fine. Note though that Windows 7 doesn't have GetHostNameW
so it'd need. a fallback, However, it's also tier 3 so can be left to a follow up by the target maintainer.
// always enough. |
---|
let mut buffer = [0; 256]; |
// SAFETY: these parameters specify a valid, writable region of memory. |
let ret = unsafe { c::GetHostNameW(buffer.as_mut_ptr(), buffer.len() as i32) }; |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess my one nitpick is that maybe the max buffer len could be a constant instead of using as i32
, which is often a code smell but in this case it's narrowly scoped enough that I don't feel strongly about it.
Didn't know that there is a dedicated GetHostName function in WSA, would have expected GetComputerNameExW. Implemented since Windows 2000, and doesn't require WS2 init.
joboet added a commit to joboet/rust that referenced this pull request
As per rust-lang#117276, this PR moves sys_common::net
and the sys::pal::net
into the newly created sys::net
module. In order to support rust-lang#135141, I've moved all the current network code into a separate connection
module, future functions like hostname
can live in separate modules.
I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
joboet added a commit to joboet/rust that referenced this pull request
As per rust-lang#117276, this PR moves sys_common::net
and the sys::pal::net
into the newly created sys::net
module. In order to support rust-lang#135141, I've moved all the current network code into a separate connection
module, future functions like hostname
can live in separate modules.
I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
jieyouxu added a commit to jieyouxu/rust that referenced this pull request
std: move network code into sys
As per rust-lang#117276, this PR moves sys_common::net
and the sys::pal::net
into the newly created sys::net
module. In order to support rust-lang#135141, I've moved all the current network code into a separate connection
module, future functions like hostname
can live in separate modules.
I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
jieyouxu added a commit to jieyouxu/rust that referenced this pull request
std: move network code into sys
As per rust-lang#117276, this PR moves sys_common::net
and the sys::pal::net
into the newly created sys::net
module. In order to support rust-lang#135141, I've moved all the current network code into a separate connection
module, future functions like hostname
can live in separate modules.
I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
jieyouxu added a commit to jieyouxu/rust that referenced this pull request
std: move network code into sys
As per rust-lang#117276, this PR moves sys_common::net
and the sys::pal::net
into the newly created sys::net
module. In order to support rust-lang#135141, I've moved all the current network code into a separate connection
module, future functions like hostname
can live in separate modules.
I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request
Rollup merge of rust-lang#136449 - joboet:move_pal_net, r=ChrisDenton
std: move network code into sys
As per rust-lang#117276, this PR moves sys_common::net
and the sys::pal::net
into the newly created sys::net
module. In order to support rust-lang#135141, I've moved all the current network code into a separate connection
module, future functions like hostname
can live in separate modules.
I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
This needs to be rebased but then I think it'll be good to be merged.
github-actions bot pushed a commit to tautschnig/verify-rust-std that referenced this pull request
As per rust-lang#117276, this PR moves sys_common::net
and the sys::pal::net
into the newly created sys::net
module. In order to support rust-lang#135141, I've moved all the current network code into a separate connection
module, future functions like hostname
can live in separate modules.
I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
github-actions bot pushed a commit to tautschnig/verify-rust-std that referenced this pull request
As per rust-lang#117276, this PR moves sys_common::net
and the sys::pal::net
into the newly created sys::net
module. In order to support rust-lang#135141, I've moved all the current network code into a separate connection
module, future functions like hostname
can live in separate modules.
I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
github-actions bot pushed a commit to carolynzech/rust that referenced this pull request
As per rust-lang#117276, this PR moves sys_common::net
and the sys::pal::net
into the newly created sys::net
module. In order to support rust-lang#135141, I've moved all the current network code into a separate connection
module, future functions like hostname
can live in separate modules.
I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request
As per rust-lang#117276, this PR moves sys_common::net
and the sys::pal::net
into the newly created sys::net
module. In order to support rust-lang#135141, I've moved all the current network code into a separate connection
module, future functions like hostname
can live in separate modules.
I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
github-actions bot pushed a commit to thanhnguyen-aws/verify-rust-std that referenced this pull request
As per rust-lang#117276, this PR moves sys_common::net
and the sys::pal::net
into the newly created sys::net
module. In order to support rust-lang#135141, I've moved all the current network code into a separate connection
module, future functions like hostname
can live in separate modules.
I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
github-actions bot pushed a commit to thanhnguyen-aws/verify-rust-std that referenced this pull request
As per rust-lang#117276, this PR moves sys_common::net
and the sys::pal::net
into the newly created sys::net
module. In order to support rust-lang#135141, I've moved all the current network code into a separate connection
module, future functions like hostname
can live in separate modules.
I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request
As per rust-lang#117276, this PR moves sys_common::net
and the sys::pal::net
into the newly created sys::net
module. In order to support rust-lang#135141, I've moved all the current network code into a separate connection
module, future functions like hostname
can live in separate modules.
I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
github-actions bot pushed a commit to carolynzech/rust that referenced this pull request
As per rust-lang#117276, this PR moves sys_common::net
and the sys::pal::net
into the newly created sys::net
module. In order to support rust-lang#135141, I've moved all the current network code into a separate connection
module, future functions like hostname
can live in separate modules.
I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
github-actions bot pushed a commit to tautschnig/verify-rust-std that referenced this pull request
As per rust-lang#117276, this PR moves sys_common::net
and the sys::pal::net
into the newly created sys::net
module. In order to support rust-lang#135141, I've moved all the current network code into a separate connection
module, future functions like hostname
can live in separate modules.
I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
github-actions bot pushed a commit to thanhnguyen-aws/verify-rust-std that referenced this pull request
As per rust-lang#117276, this PR moves sys_common::net
and the sys::pal::net
into the newly created sys::net
module. In order to support rust-lang#135141, I've moved all the current network code into a separate connection
module, future functions like hostname
can live in separate modules.
I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
github-actions bot pushed a commit to thanhnguyen-aws/verify-rust-std that referenced this pull request
As per rust-lang#117276, this PR moves sys_common::net
and the sys::pal::net
into the newly created sys::net
module. In order to support rust-lang#135141, I've moved all the current network code into a separate connection
module, future functions like hostname
can live in separate modules.
I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
github-actions bot pushed a commit to carolynzech/rust that referenced this pull request
As per rust-lang#117276, this PR moves sys_common::net
and the sys::pal::net
into the newly created sys::net
module. In order to support rust-lang#135141, I've moved all the current network code into a separate connection
module, future functions like hostname
can live in separate modules.
I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
github-actions bot pushed a commit to carolynzech/rust that referenced this pull request
As per rust-lang#117276, this PR moves sys_common::net
and the sys::pal::net
into the newly created sys::net
module. In order to support rust-lang#135141, I've moved all the current network code into a separate connection
module, future functions like hostname
can live in separate modules.
I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
github-actions bot pushed a commit to thanhnguyen-aws/verify-rust-std that referenced this pull request
As per rust-lang#117276, this PR moves sys_common::net
and the sys::pal::net
into the newly created sys::net
module. In order to support rust-lang#135141, I've moved all the current network code into a separate connection
module, future functions like hostname
can live in separate modules.
I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
github-actions bot pushed a commit to tautschnig/verify-rust-std that referenced this pull request
As per rust-lang#117276, this PR moves sys_common::net
and the sys::pal::net
into the newly created sys::net
module. In order to support rust-lang#135141, I've moved all the current network code into a separate connection
module, future functions like hostname
can live in separate modules.
I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
github-actions bot pushed a commit to thanhnguyen-aws/verify-rust-std that referenced this pull request
As per rust-lang#117276, this PR moves sys_common::net
and the sys::pal::net
into the newly created sys::net
module. In order to support rust-lang#135141, I've moved all the current network code into a separate connection
module, future functions like hostname
can live in separate modules.
I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
github-actions bot pushed a commit to tautschnig/verify-rust-std that referenced this pull request
As per rust-lang#117276, this PR moves sys_common::net
and the sys::pal::net
into the newly created sys::net
module. In order to support rust-lang#135141, I've moved all the current network code into a separate connection
module, future functions like hostname
can live in separate modules.
I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
github-actions bot pushed a commit to tautschnig/verify-rust-std that referenced this pull request
std: move network code into sys
As per rust-lang#117276, this PR moves sys_common::net
and the sys::pal::net
into the newly created sys::net
module. In order to support rust-lang#135141, I've moved all the current network code into a separate connection
module, future functions like hostname
can live in separate modules.
I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
Labels
Area: Issues & PRs about the rust-lang/rust repository itself
Area: port run-make Makefiles to rmake.rs
Operating system: Unix-like
Operating system: Windows
Status: Awaiting review from the assignee but also interested parties.
Relevant to the library team, which will review and decide on the PR/issue.