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 }})

orowith2os

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.

@rustbot

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 rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-libs

Relevant to the library team, which will review and decide on the PR/issue.

labels

Jan 6, 2025

@rust-log-analyzer

This comment has been minimized.

compiler-errors

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@orowith2os

forgive all the updates, I was having troubles updating my branch properly. Figured it out.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

ChrisDenton

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.

@valaphee

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

Feb 2, 2025

@joboet

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

Feb 2, 2025

@joboet

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

Feb 5, 2025

@jieyouxu

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

Feb 5, 2025

@jieyouxu

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

Feb 5, 2025

@jieyouxu

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

Feb 6, 2025

@rust-timer

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.

@bors

@ChrisDenton

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

Feb 20, 2025

@joboet

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

Feb 20, 2025

@joboet

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

Feb 20, 2025

@joboet

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

Feb 20, 2025

@joboet

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

Feb 21, 2025

@joboet

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

Feb 21, 2025

@joboet

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

Feb 22, 2025

@joboet

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

Feb 22, 2025

@joboet

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

Feb 22, 2025

@joboet

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

Feb 22, 2025

@joboet

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

Mar 3, 2025

@joboet

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

Mar 4, 2025

@joboet

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

Mar 4, 2025

@joboet

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

Mar 4, 2025

@joboet

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

Mar 6, 2025

@joboet

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

Mar 6, 2025

@joboet

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

Mar 11, 2025

@joboet

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

Mar 11, 2025

@jieyouxu

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

A-meta

Area: Issues & PRs about the rust-lang/rust repository itself

A-run-make

Area: port run-make Makefiles to rmake.rs

O-unix

Operating system: Unix-like

O-windows

Operating system: Windows

S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-libs

Relevant to the library team, which will review and decide on the PR/issue.