Skip to content

Commit

Permalink
Update to gethostname 0.5
Browse files Browse the repository at this point in the history
With version 0.5, gethostname now uses rustic on unix to determine the
host name. In fact, the code is exactly to identical to what we've been
doing ourselves. As such, I am dropping the unix-specific implementation
of this and let this just always use gethostname.

Signed-off-by: Uli Schlachter <[email protected]>
  • Loading branch information
psychon committed Aug 10, 2024
1 parent 3e6b5ea commit 1f5dd3c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 19 deletions.
6 changes: 2 additions & 4 deletions x11rb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ once_cell = { version = "1.19", optional = true }
as-raw-xcb-connection = { version = "1.0", optional = true }
tracing = { version = "0.1", optional = true, default-features = false }
rustix = { version = "0.38", default-features = false, features = ["std", "event", "fs", "net", "system"] }

[target.'cfg(not(unix))'.dependencies]
gethostname = "0.4"
gethostname = "0.5"

[dev-dependencies]
gethostname = "0.4"
gethostname = "0.5"
polling = "3.4"
tracing-subscriber = "0.3"

Expand Down
13 changes: 0 additions & 13 deletions x11rb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ mod test;

use errors::ConnectError;
use protocol::xproto::{Keysym, Timestamp};
use std::ffi::OsString;

/// Establish a new connection to an X11 server.
///
Expand Down Expand Up @@ -214,15 +213,3 @@ pub const CURRENT_TIME: Timestamp = 0;

/// This constant can be used to fill unused entries in `Keysym` tables
pub const NO_SYMBOL: Keysym = 0;

#[cfg(not(unix))]
fn hostname() -> OsString {
gethostname::gethostname()
}

#[cfg(unix)]
fn hostname() -> OsString {
use std::os::unix::ffi::OsStringExt;

OsString::from_vec(rustix::system::uname().nodename().to_bytes().to_vec())
}
2 changes: 1 addition & 1 deletion x11rb/src/resource_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ pub fn new_from_resource_manager(conn: &impl Connection) -> Result<Option<Databa
pub fn new_from_default(conn: &impl Connection) -> Result<Database, ReplyError> {
Ok(Database::new_from_default(
&send_request(conn)?,
crate::hostname(),
gethostname::gethostname(),
))
}
2 changes: 1 addition & 1 deletion x11rb/src/rust_connection/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ mod peer_addr {

// Get xauth information representing a local connection
pub(super) fn local() -> PeerAddr {
let hostname = crate::hostname()
let hostname = gethostname::gethostname()

Check warning on line 552 in x11rb/src/rust_connection/stream.rs

View check run for this annotation

Codecov / codecov/patch

x11rb/src/rust_connection/stream.rs#L552

Added line #L552 was not covered by tests
.to_str()
.map_or_else(Vec::new, |s| s.as_bytes().to_vec());
(Family::LOCAL, hostname)
Expand Down

0 comments on commit 1f5dd3c

Please sign in to comment.