mirror of
https://codeberg.org/icewind/tasproxy.git
synced 2026-06-03 10:14:09 +02:00
bump dependencies
This commit is contained in:
parent
c0437522d7
commit
b4bb43820b
5 changed files with 524 additions and 349 deletions
862
Cargo.lock
generated
862
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
28
Cargo.toml
28
Cargo.toml
|
|
@ -7,17 +7,17 @@ license = "MIT OR Apache-2.0"
|
|||
repository = "https://github.com/icewind1991/tasproxy"
|
||||
|
||||
[dependencies]
|
||||
rumqttc = "0.10"
|
||||
tokio = { version = "1", features = ["macros", "rt-multi-thread", "signal"] }
|
||||
futures-util = "0.3"
|
||||
dashmap = "5"
|
||||
json = "0.12"
|
||||
warp = "0.3"
|
||||
dotenv = "0.15"
|
||||
color-eyre = "0.5"
|
||||
async-stream = "0.3"
|
||||
pin-utils = "0.1"
|
||||
hostname = "0.3"
|
||||
warp-reverse-proxy = { version = "0.3", default_features = false, features = ["rustls-tls"] }
|
||||
tokio-stream = { version = "0.1.9", features = ["net"] }
|
||||
base64 = "0.13.0"
|
||||
rumqttc = "0.23.0"
|
||||
tokio = { version = "1.35.1", features = ["macros", "rt-multi-thread", "signal"] }
|
||||
futures-util = "0.3.30"
|
||||
dashmap = "5.5.3"
|
||||
json = "0.12.4"
|
||||
warp = "0.3.6"
|
||||
dotenv = "0.15.0"
|
||||
color-eyre = "0.6.2"
|
||||
async-stream = "0.3.5"
|
||||
pin-utils = "0.1.0"
|
||||
hostname = "0.3.1"
|
||||
warp-reverse-proxy = { version = "1.0.0", default_features = false, features = ["rustls-tls"] }
|
||||
tokio-stream = { version = "0.1.14", features = ["net"] }
|
||||
base64 = "0.21.7"
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ Run the binary with the following environment variables
|
|||
- `MQTT_PASSWORD`: password to authenticate against the mqtt server
|
||||
- `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
|
||||
|
||||
## Usage
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use base64::prelude::*;
|
||||
use color_eyre::{eyre::WrapErr, Report, Result};
|
||||
use rumqttc::MqttOptions;
|
||||
use std::str::FromStr;
|
||||
|
|
@ -26,11 +27,7 @@ pub struct Credentials {
|
|||
impl Credentials {
|
||||
pub fn auth_header(&self) -> String {
|
||||
let mut header = "Basic ".to_string();
|
||||
base64::encode_config_buf(
|
||||
format!("{}:{}", self.username, self.password),
|
||||
base64::STANDARD,
|
||||
&mut header,
|
||||
);
|
||||
BASE64_STANDARD.encode_string(format!("{}:{}", self.username, self.password), &mut header);
|
||||
header
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ type DeviceStates = Arc<DashMap<String, DeviceState>>;
|
|||
async fn main() -> Result<()> {
|
||||
let config = Config::from_env()?;
|
||||
let listen = config.listen.clone();
|
||||
let tasmota_credentails = config
|
||||
let tasmota_credentials = config
|
||||
.tasmota_credentials
|
||||
.as_ref()
|
||||
.map(|auth| auth.auth_header());
|
||||
|
|
@ -93,7 +93,7 @@ async fn main() -> Result<()> {
|
|||
method: Method,
|
||||
mut headers: HeaderMap,
|
||||
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());
|
||||
}
|
||||
proxy_to_and_forward_response(
|
||||
|
|
@ -129,7 +129,7 @@ async fn main() -> Result<()> {
|
|||
warp_server
|
||||
.serve_incoming_with_graceful_shutdown(stream, cancel)
|
||||
.map(move |_| {
|
||||
remove_file(&socket).ok();
|
||||
remove_file(socket).ok();
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue