Load env variables from .env file

This commit is contained in:
Dreaded_X 2025-04-05 02:44:58 +02:00
parent c32c18ffc0
commit 72819faa8f
Signed by: Dreaded_X
GPG Key ID: FA5F485356B0D2D4
4 changed files with 12 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
/target
key.pem
.env

7
Cargo.lock generated
View File

@ -393,6 +393,12 @@ dependencies = [
"subtle",
]
[[package]]
name = "dotenvy"
version = "0.15.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b"
[[package]]
name = "ecdsa"
version = "0.16.9"
@ -1898,6 +1904,7 @@ name = "tunnel_rs"
version = "0.1.0"
dependencies = [
"bytes",
"dotenvy",
"http-body-util",
"hyper",
"hyper-util",

View File

@ -6,6 +6,7 @@ default-run = "tunnel_rs"
[dependencies]
bytes = "1.10.1"
dotenvy = "0.15.7"
http-body-util = { version = "0.1.3", features = ["full"] }
hyper = { version = "1.6.0", features = ["full"] }
hyper-util = { version = "0.1.11", features = ["full"] }

View File

@ -1,5 +1,6 @@
use std::{net::SocketAddr, path::Path};
use dotenvy::dotenv;
use hyper::server::conn::http1::{self};
use hyper_util::rt::TokioIo;
use rand::rngs::OsRng;
@ -10,6 +11,8 @@ use tunnel_rs::ssh::Server;
#[tokio::main]
async fn main() {
dotenv().ok();
let env_filter = EnvFilter::try_from_default_env()
.or_else(|_| EnvFilter::try_new("info"))
.expect("Fallback should be valid");