make proxy part of the project structure
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
/target
|
||||
cert.pem
|
||||
key.pem
|
||||
bundle
|
||||
|
||||
+3
-4
@@ -1,12 +1,10 @@
|
||||
[package]
|
||||
name = "mumble-webtransport-proxy"
|
||||
name = "mumble-web2-proxy"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.86"
|
||||
color-eyre = "0.6.3"
|
||||
axum = "0.7.7"
|
||||
axum-server = { version = "0.7.1", features = ["tls-rustls"] }
|
||||
lazy_static = "1.4.0"
|
||||
@@ -21,3 +19,4 @@ tower-http = { version = "0.6.1", features = ["fs"] }
|
||||
tracing = { version = "0.1.40", features = ["async-await"] }
|
||||
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
||||
wtransport = "0.1.13"
|
||||
mumble-web2-common = { workspace = true }
|
||||
|
||||
@@ -3,9 +3,10 @@ http_listen_address = "127.0.0.1:4434"
|
||||
cert_path = "./cert.pem"
|
||||
key_path = "./key.pem"
|
||||
mumble_server_url = "voip.ohea.xyz:64738"
|
||||
gui_path = "../mumble-web2/dist"
|
||||
serve_https = true
|
||||
gui_path = "../gui/dist"
|
||||
serve_https = false
|
||||
|
||||
[gui]
|
||||
proxy_url = "https://voip2.ohea.xyz"
|
||||
force_proxy = true
|
||||
proxy_url = "https://localhost:4433"
|
||||
# cert_hash = [...]
|
||||
|
||||
+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