Compare commits

..

No commits in common. "afa13bf920dd17867e5fb6c1c050094876d92c0b" and "663ce420166a96493ee4abc2a5c06e2fab4498ee" have entirely different histories.

5 changed files with 33 additions and 61 deletions

60
Cargo.lock generated
View file

@ -290,27 +290,6 @@ version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8"
[[package]]
name = "directories-next"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "339ee130d97a610ea5a5872d2bbb130fdf68884ff09d3028b81bec8a1ac23bbc"
dependencies = [
"cfg-if",
"dirs-sys-next",
]
[[package]]
name = "dirs-sys-next"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
dependencies = [
"libc",
"redox_users",
"winapi",
]
[[package]]
name = "dlib"
version = "0.5.2"
@ -392,8 +371,8 @@ dependencies = [
"bytes",
"copypasta",
"crossterm",
"directories-next",
"env_logger",
"home",
"indoc",
"libc",
"log",
@ -407,6 +386,7 @@ dependencies = [
"tokio",
"tokio-stream",
"toml",
"xdg",
]
[[package]]
@ -470,6 +450,15 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
name = "home"
version = "0.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5"
dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "iana-time-zone"
version = "0.1.60"
@ -572,16 +561,6 @@ dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "libredox"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
dependencies = [
"bitflags 2.6.0",
"libc",
]
[[package]]
name = "linux-raw-sys"
version = "0.1.4"
@ -911,17 +890,6 @@ dependencies = [
"bitflags 2.6.0",
]
[[package]]
name = "redox_users"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891"
dependencies = [
"getrandom",
"libredox",
"thiserror",
]
[[package]]
name = "rustc-demangle"
version = "0.1.24"
@ -1711,6 +1679,12 @@ version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ef33da6b1660b4ddbfb3aef0ade110c8b8a781a3b6382fa5f2b5b040fd55f61"
[[package]]
name = "xdg"
version = "2.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546"
[[package]]
name = "xkeysym"
version = "0.2.1"

View file

@ -18,8 +18,8 @@ anyhow = "1.0"
bytes = "1"
copypasta = "0.10.1"
crossterm = { version = "0.28.1", features = ["event-stream"] }
directories-next = "2"
env_logger = { version = "0.11.5", default-features = false }
home = "0.5.4"
indoc = "1"
log = { version = "0.4", features = ["std"] }
open = "3"
@ -29,7 +29,7 @@ thiserror = "1.0"
tokio = { version = "1", features = ["io-std", "io-util", "macros", "net", "process", "rt", "rt-multi-thread", "fs"] }
tokio-stream = "0.1"
toml = "0.5"
xdg = "2"
[dev-dependencies]
assert_matches = "1"

View file

@ -62,15 +62,13 @@ impl Config {
pub fn load_config() -> Result<Config> {
use std::io::ErrorKind;
let Some(directories) = directories_next::ProjectDirs::from("", "", "fwd")
else {
return Ok(default());
let mut home = match home::home_dir() {
Some(h) => h,
None => return Ok(default()),
};
home.push(".fwd");
let mut config_path = directories.config_dir().to_path_buf();
config_path.push("config.toml");
let contents = match std::fs::read_to_string(config_path) {
let contents = match std::fs::read_to_string(home) {
Ok(contents) => contents,
Err(e) => match e.kind() {
ErrorKind::NotFound => return Ok(default()),

View file

@ -19,10 +19,10 @@ to send the the contents of `file`.
Options:
--version Print the version of fwd and exit
--sudo, -s Run the server side of fwd with `sudo`. This allows the
client to identify the ports that are open by processes
being run under other accounts (e.g., docker containers
being run as root), but requires sudo access on the server
and *might* end up forwarding ports that you do not want
client to forward ports that are open by processes being
run under other accounts (e.g., docker containers being
run as root), but requires sudo access on the server and
*might* end up forwarding ports that you do not want
forwarded (e.g., port 22 for sshd, or port 53 for systemd.)
--log-filter FILTER
Set remote server's log level. Default is `warn`. Supports

View file

@ -49,11 +49,11 @@ pub fn socket_path() -> Result<PathBuf> {
}
fn socket_directory() -> Result<std::path::PathBuf> {
match directories_next::ProjectDirs::from("", "", "fwd")
.and_then(|p| p.runtime_dir().map(|p| p.to_path_buf()))
{
Some(p) => Ok(p),
None => {
let base_directories = xdg::BaseDirectories::new()
.context("Error creating BaseDirectories")?;
match base_directories.place_runtime_file("fwd") {
Ok(path) => Ok(path),
Err(_) => {
let mut path = std::env::temp_dir();
let uid = unsafe { libc::getuid() };
path.push(format!("fwd{}", uid));