bump dependencies

This commit is contained in:
Robin Appelman 2024-01-14 17:13:29 +01:00
commit b4bb43820b
5 changed files with 524 additions and 349 deletions

862
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -7,17 +7,17 @@ license = "MIT OR Apache-2.0"
repository = "https://github.com/icewind1991/tasproxy" repository = "https://github.com/icewind1991/tasproxy"
[dependencies] [dependencies]
rumqttc = "0.10" rumqttc = "0.23.0"
tokio = { version = "1", features = ["macros", "rt-multi-thread", "signal"] } tokio = { version = "1.35.1", features = ["macros", "rt-multi-thread", "signal"] }
futures-util = "0.3" futures-util = "0.3.30"
dashmap = "5" dashmap = "5.5.3"
json = "0.12" json = "0.12.4"
warp = "0.3" warp = "0.3.6"
dotenv = "0.15" dotenv = "0.15.0"
color-eyre = "0.5" color-eyre = "0.6.2"
async-stream = "0.3" async-stream = "0.3.5"
pin-utils = "0.1" pin-utils = "0.1.0"
hostname = "0.3" hostname = "0.3.1"
warp-reverse-proxy = { version = "0.3", default_features = false, features = ["rustls-tls"] } warp-reverse-proxy = { version = "1.0.0", default_features = false, features = ["rustls-tls"] }
tokio-stream = { version = "0.1.9", features = ["net"] } tokio-stream = { version = "0.1.14", features = ["net"] }
base64 = "0.13.0" base64 = "0.21.7"

View file

@ -22,6 +22,8 @@ Run the binary with the following environment variables
- `MQTT_PASSWORD`: password to authenticate against the mqtt server - `MQTT_PASSWORD`: password to authenticate against the mqtt server
- `PORT`: port this binary MQTT listen on, defaults to 80 - `PORT`: port this binary MQTT listen on, defaults to 80
You can also configure the proxy to send HTTP Basic authentication to the tasmota devices by setting the `TASMOTA_USERNAME` and `TASMOTA_PASSWORD` environment variables.
Setup dns/hosts/etc to point *.example.com to the server running this binary Setup dns/hosts/etc to point *.example.com to the server running this binary
## Usage ## Usage

View file

@ -1,3 +1,4 @@
use base64::prelude::*;
use color_eyre::{eyre::WrapErr, Report, Result}; use color_eyre::{eyre::WrapErr, Report, Result};
use rumqttc::MqttOptions; use rumqttc::MqttOptions;
use std::str::FromStr; use std::str::FromStr;
@ -26,11 +27,7 @@ pub struct Credentials {
impl Credentials { impl Credentials {
pub fn auth_header(&self) -> String { pub fn auth_header(&self) -> String {
let mut header = "Basic ".to_string(); let mut header = "Basic ".to_string();
base64::encode_config_buf( BASE64_STANDARD.encode_string(format!("{}:{}", self.username, self.password), &mut header);
format!("{}:{}", self.username, self.password),
base64::STANDARD,
&mut header,
);
header header
} }
} }

View file

@ -36,7 +36,7 @@ type DeviceStates = Arc<DashMap<String, DeviceState>>;
async fn main() -> Result<()> { async fn main() -> Result<()> {
let config = Config::from_env()?; let config = Config::from_env()?;
let listen = config.listen.clone(); let listen = config.listen.clone();
let tasmota_credentails = config let tasmota_credentials = config
.tasmota_credentials .tasmota_credentials
.as_ref() .as_ref()
.map(|auth| auth.auth_header()); .map(|auth| auth.auth_header());
@ -93,7 +93,7 @@ async fn main() -> Result<()> {
method: Method, method: Method,
mut headers: HeaderMap, mut headers: HeaderMap,
body: Bytes| { body: Bytes| {
if let Some(credentials) = tasmota_credentails.as_deref() { if let Some(credentials) = tasmota_credentials.as_deref() {
headers.append("authorization", HeaderValue::from_str(credentials).unwrap()); headers.append("authorization", HeaderValue::from_str(credentials).unwrap());
} }
proxy_to_and_forward_response( proxy_to_and_forward_response(
@ -129,7 +129,7 @@ async fn main() -> Result<()> {
warp_server warp_server
.serve_incoming_with_graceful_shutdown(stream, cancel) .serve_incoming_with_graceful_shutdown(stream, cancel)
.map(move |_| { .map(move |_| {
remove_file(&socket).ok(); remove_file(socket).ok();
}), }),
) )
} }