make proxy part of the project structure
This commit is contained in:
+10
-13
@@ -1,8 +1,9 @@
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use axum::extract::State;
|
||||
use axum::http::{Response, StatusCode};
|
||||
use axum::response::IntoResponse;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use color_eyre::eyre::{anyhow, Context, Error, Result};
|
||||
use mumble_web2_common::GuiConfig;
|
||||
use serde::Deserialize;
|
||||
use std::future::IntoFuture;
|
||||
use std::net::{SocketAddr, ToSocketAddrs};
|
||||
use std::path::PathBuf;
|
||||
@@ -88,18 +89,12 @@ impl ServerCertVerifier for NoCertificateVerification {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
struct GuiConfig {
|
||||
proxy_url: Option<String>,
|
||||
cert_hash: Option<Vec<u8>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize)]
|
||||
struct Config {
|
||||
proxy_listen_address: SocketAddr,
|
||||
http_listen_address: SocketAddr,
|
||||
cert_path: String,
|
||||
key_path: String,
|
||||
cert_path: PathBuf,
|
||||
key_path: PathBuf,
|
||||
#[serde(default)]
|
||||
serve_https: bool,
|
||||
mumble_server_url: String,
|
||||
@@ -133,7 +128,7 @@ async fn serve_index_html_with_config(State(config): State<Config>) -> impl Into
|
||||
.into_response()
|
||||
}
|
||||
|
||||
fn configure_tls(config: &Config) -> Result<rustls::ServerConfig, anyhow::Error> {
|
||||
fn configure_tls(config: &Config) -> Result<rustls::ServerConfig, Error> {
|
||||
// Thanks perplexity!
|
||||
use rustls_pemfile::{certs, pkcs8_private_keys};
|
||||
use std::fs::File;
|
||||
@@ -143,12 +138,14 @@ fn configure_tls(config: &Config) -> Result<rustls::ServerConfig, anyhow::Error>
|
||||
//(rustls::server::NoClientAuth::new());
|
||||
|
||||
// Read the certificate file
|
||||
let cert_file = File::open(&config.cert_path)?;
|
||||
let cert_file = File::open(&config.cert_path)
|
||||
.context(format!("opening cert {}", config.cert_path.display()))?;
|
||||
let mut cert_reader = BufReader::new(cert_file);
|
||||
let cert_chain = certs(&mut cert_reader).collect::<Result<_, _>>()?;
|
||||
|
||||
// Read the private key file
|
||||
let key_file = File::open(&config.key_path)?;
|
||||
let key_file = File::open(&config.key_path)
|
||||
.context(format!("opening key {}", config.key_path.display()))?;
|
||||
let mut key_reader = BufReader::new(key_file);
|
||||
let key = pkcs8_private_keys(&mut key_reader)
|
||||
.next()
|
||||
|
||||
Reference in New Issue
Block a user