This commit is contained in:
LittleSheep 2024-02-13 18:27:01 +08:00
parent e27023c130
commit 3fbe1db1ef
10 changed files with 206 additions and 165 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
/config /config
/certs
/letsencrypt /letsencrypt
# Added by cargo # Added by cargo

96
Cargo.lock generated
View File

@ -51,6 +51,7 @@ dependencies = [
"actix-codec", "actix-codec",
"actix-rt", "actix-rt",
"actix-service", "actix-service",
"actix-tls",
"actix-utils", "actix-utils",
"ahash", "ahash",
"base64", "base64",
@ -168,8 +169,10 @@ dependencies = [
"impl-more", "impl-more",
"openssl", "openssl",
"pin-project-lite", "pin-project-lite",
"rustls-pki-types",
"tokio", "tokio",
"tokio-openssl", "tokio-openssl",
"tokio-rustls",
"tokio-util", "tokio-util",
"tracing", "tracing",
] ]
@ -197,6 +200,7 @@ dependencies = [
"actix-rt", "actix-rt",
"actix-server", "actix-server",
"actix-service", "actix-service",
"actix-tls",
"actix-utils", "actix-utils",
"actix-web-codegen", "actix-web-codegen",
"ahash", "ahash",
@ -1267,6 +1271,20 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
[[package]]
name = "ring"
version = "0.17.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74"
dependencies = [
"cc",
"getrandom",
"libc",
"spin",
"untrusted",
"windows-sys",
]
[[package]] [[package]]
name = "roadsign" name = "roadsign"
version = "0.1.0" version = "0.1.0"
@ -1284,6 +1302,8 @@ dependencies = [
"queryst", "queryst",
"rand", "rand",
"regex", "regex",
"rustls",
"rustls-pemfile",
"serde", "serde",
"serde_json", "serde_json",
"tokio", "tokio",
@ -1331,6 +1351,47 @@ dependencies = [
"semver", "semver",
] ]
[[package]]
name = "rustls"
version = "0.22.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e87c9956bd9807afa1f77e0f7594af32566e830e088a5576d27c5b6f30f49d41"
dependencies = [
"log",
"ring",
"rustls-pki-types",
"rustls-webpki",
"subtle",
"zeroize",
]
[[package]]
name = "rustls-pemfile"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35e4980fa29e4c4b212ffb3db068a564cbf560e51d3944b7c88bd8bf5bec64f4"
dependencies = [
"base64",
"rustls-pki-types",
]
[[package]]
name = "rustls-pki-types"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a716eb65e3158e90e17cd93d855216e27bde02745ab842f2cab4a39dba1bacf"
[[package]]
name = "rustls-webpki"
version = "0.102.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610"
dependencies = [
"ring",
"rustls-pki-types",
"untrusted",
]
[[package]] [[package]]
name = "ryu" name = "ryu"
version = "1.0.16" version = "1.0.16"
@ -1466,6 +1527,18 @@ dependencies = [
"windows-sys", "windows-sys",
] ]
[[package]]
name = "spin"
version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
[[package]]
name = "subtle"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.109" version = "1.0.109"
@ -1613,6 +1686,17 @@ dependencies = [
"tokio", "tokio",
] ]
[[package]]
name = "tokio-rustls"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f"
dependencies = [
"rustls",
"rustls-pki-types",
"tokio",
]
[[package]] [[package]]
name = "tokio-tungstenite" name = "tokio-tungstenite"
version = "0.21.0" version = "0.21.0"
@ -1798,6 +1882,12 @@ version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202"
[[package]]
name = "untrusted"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
[[package]] [[package]]
name = "url" name = "url"
version = "2.5.0" version = "2.5.0"
@ -1977,6 +2067,12 @@ dependencies = [
"syn 2.0.48", "syn 2.0.48",
] ]
[[package]]
name = "zeroize"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d"
[[package]] [[package]]
name = "zstd" name = "zstd"
version = "0.13.0" version = "0.13.0"

View File

@ -8,7 +8,7 @@ edition = "2021"
[dependencies] [dependencies]
actix-files = "0.6.5" actix-files = "0.6.5"
actix-proxy = "0.2.0" actix-proxy = "0.2.0"
actix-web = "4.5.1" actix-web = { version = "4.5.1", features = ["rustls-0_22"] }
actix-web-httpauth = "0.8.1" actix-web-httpauth = "0.8.1"
awc = "3.4.0" awc = "3.4.0"
config = { version = "0.14.0", features = ["toml"] } config = { version = "0.14.0", features = ["toml"] }
@ -32,3 +32,5 @@ tracing = "0.1.40"
tracing-subscriber = "0.3.18" tracing-subscriber = "0.3.18"
wildmatch = "2.3.0" wildmatch = "2.3.0"
derive_more = "0.99.17" derive_more = "0.99.17"
rustls = "0.22.2"
rustls-pemfile = "2.0.0"

View File

@ -5,3 +5,8 @@ secret = "aEXcED5xJ3"
proxies = "0.0.0.0:80" proxies = "0.0.0.0:80"
proxies_tls = "0.0.0.0:443" proxies_tls = "0.0.0.0:443"
sideload = "0.0.0.0:81" sideload = "0.0.0.0:81"
[[certificates]]
domain = "localhost"
certs = "certs/fullchain.pem"
key = "certs/privkey.pem"

View File

@ -1,98 +0,0 @@
-----BEGIN CERTIFICATE-----
MIIGITCCBQmgAwIBAgISBPa2ahmRa5l0SrbR75K29TlqMA0GCSqGSIb3DQEBCwUA
MDIxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQD
EwJSMzAeFw0yNDAxMjgxNjM1MzZaFw0yNDA0MjcxNjM1MzVaMBwxGjAYBgNVBAMT
EXNtYXJ0c2hlZXAuc3R1ZGlvMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKC
AgEAumtDoEkBHiqBGNl9JUbt3Nw1a/iLa2JHZvCmUuilvafAj0k1UPEu457iJVjh
nxlTl/tgpCooRNviboB0lMAecwiKb5PIZzInY2/gb+rceL7rycalDAjWnwZZg8Tl
3JWJaU0D3+jeBQ9p7xkRPTcRpkGxFX9hRdInRqFGmCK4/OXrBwI3FkoP9Z8Nvgzc
RyIhmMEafOi2AaLJSXZQE508djHpcxlwoxvVmFIYsjTMJiq+zdqCZDTjDqt7bZC+
mp3n/DFLL0sTzIBLuHnPkrjwlE4w/XTLkMLgrGPvEJVHn4kOvnJSWJb95d3sRZqB
PLrekQGDtcb0dpFx8ctWycVp0qhBTpuLAoN+AK6cJ3IkxOcGm7sKzYwRINjAblMe
n1Y6as6JKL4zSZBt1jxua1NGIRQ1c4ReA78NniTMrFIk1mFL4kNT9ppgDsWGNTJx
FqC76rr3TdKXKzD/c8h57j3CPTF9lGB4Vmlkrq/zA++br0IG7Ki/+1n04Q1UDN0E
8z/vgUsT+pMItrmUhpnhb+4QWLQHTWOg1CyWT9xSm77ArkuNSdzNFGjpSbYZEPlh
pmAYTz+kWvnyg7T3Lt7fmSPCBnnIWhi9CJofvyomICWfcKEfwc0msJquXMyJBayA
K91VM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ZxgQC4SgOOXedl7wXXgSEraUduy5pa6/l17+jX/PJwhrm
lcbh1xIbuYXFeOmqtEvzvolcHThHcFBwZOtxOvZh7eAAtA8WvUt6RaV9IQWFFvDS
UbVUUq00hCi2DP7xq3JDkLOHVESQJB1PPvAP4ohrtkRpwrANF0rwB6cuXRWtyoWa
nuj9/ZfmTOL5gsuKA4oeZIXddyQ2yxhiEfA148VLdd67Mv1o6xsSm+4daa4MNysf
Hz6bIlpxiK6/eNPCDyHIKJ3ITzM/B1Eb0CdUh+P+/DWHCvEFG5nEQGKsa4esKYyc
7oXEYNuvR8MrH4TFi+kRuMEqebnzFYNdAoIBAQDHBExE+HRcpIrjIqMSngQ2VgxZ
u21sMg10S+c3BxYQYldGzRVg5rzTU+5EKWtsEKjfJ0+zVCMVFlQ/m3LclLTZbXem
ZFUW6fnPqEyZfabrnevwzomgxj56Jzj8mszfWhaCxDUflNgNoB7pVPLiBpnJKqCL
mFiuQ6mhGguqlq3usRi/cNE5ClOiYJlKlzc5W0kEI9Z0LdUdyf6EudpSsXaHVU6d
b15c855UU/LnLNtASTbeWqStJSXDJVSqqj0FR2Zl4KOoXhrRql3xn9N2X2Kti6LD
iaqoobkYpjnhBsB1HyhLaosX78qNdG0+UOfL8i27AkIEX/YzlNiEt7BGgE++
-----END RSA PRIVATE KEY-----

View File

@ -7,5 +7,5 @@ use crate::config::loader::load_settings;
pub mod loader; pub mod loader;
lazy_static! { lazy_static! {
pub static ref C: RwLock<Config> = RwLock::new(load_settings()); pub static ref CFG: RwLock<Config> = RwLock::new(load_settings());
} }

View File

@ -2,7 +2,9 @@ mod config;
mod proxies; mod proxies;
mod sideload; mod sideload;
pub mod warden; pub mod warden;
mod tls;
use std::error;
use actix_web::{App, HttpServer, web}; use actix_web::{App, HttpServer, web};
use actix_web::middleware::Logger; use actix_web::middleware::Logger;
use actix_web_httpauth::extractors::AuthenticationError; use actix_web_httpauth::extractors::AuthenticationError;
@ -20,7 +22,7 @@ lazy_static! {
} }
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), std::io::Error> { async fn main() -> Result<(), Box<dyn error::Error>> {
// Setting up logging // Setting up logging
tracing_subscriber::fmt() tracing_subscriber::fmt()
.with_max_level(Level::DEBUG) .with_max_level(Level::DEBUG)
@ -29,11 +31,10 @@ async fn main() -> Result<(), std::io::Error> {
// Prepare all the stuff // Prepare all the stuff
info!("Loading proxy regions..."); info!("Loading proxy regions...");
match proxies::loader::scan_regions( match proxies::loader::scan_regions(
config::C config::CFG
.read() .read()
.await .await
.get_string("regions") .get_string("regions")?
.unwrap_or("./regions".to_string()),
) { ) {
Err(_) => error!("Loading proxy regions... failed"), Err(_) => error!("Loading proxy regions... failed"),
Ok((regions, count)) => { Ok((regions, count)) => {
@ -48,23 +49,30 @@ async fn main() -> Result<(), std::io::Error> {
.wrap(Logger::default()) .wrap(Logger::default())
.app_data(web::Data::new(Client::default())) .app_data(web::Data::new(Client::default()))
.route("/", web::to(route::handle)) .route("/", web::to(route::handle))
}).bind( }).bind_rustls_0_22(
config::C config::CFG
.read() .read()
.await .await
.get_string("listen.proxies") .get_string("listen.proxies_tls")?,
.unwrap_or("0.0.0.0:80".to_string()) tls::use_rustls().await?,
)?.bind(
config::CFG
.read()
.await
.get_string("listen.proxies")?
)?.run(); )?.run();
// Sideload // Sideload
let sideload_server = HttpServer::new(|| { let sideload_server = HttpServer::new(|| {
App::new() App::new()
.wrap(HttpAuthentication::basic(|req, credentials| async move { .wrap(HttpAuthentication::basic(|req, credentials| async move {
let password = config::C let password = match config::CFG
.read() .read()
.await .await
.get_string("secret") .get_string("secret") {
.unwrap_or("".to_string()); Ok(val) => val,
Err(_) => return Err((AuthenticationError::new(Basic::new()).into(), req))
};
if credentials.password().unwrap_or("") != password { if credentials.password().unwrap_or("") != password {
Err((AuthenticationError::new(Basic::new()).into(), req)) Err((AuthenticationError::new(Basic::new()).into(), req))
} else { } else {
@ -73,12 +81,12 @@ async fn main() -> Result<(), std::io::Error> {
})) }))
.service(sideload::service()) .service(sideload::service())
}).bind( }).bind(
config::C config::CFG
.read() .read()
.await .await
.get_string("listen.sideload") .get_string("listen.sideload")
.unwrap_or("0.0.0.0:81".to_string()) .unwrap_or("0.0.0.0:81".to_string())
)?.run(); )?.workers(1).run();
// Process manager // Process manager
{ {

78
src/tls.rs Normal file
View File

@ -0,0 +1,78 @@
use std::fs::File;
use std::{error};
use std::io::BufReader;
use std::sync::Arc;
use config::ConfigError;
use lazy_static::lazy_static;
use rustls::crypto::ring::sign::RsaSigningKey;
use rustls::server::{ClientHello, ResolvesServerCert};
use rustls::sign::CertifiedKey;
use serde::{Deserialize, Serialize};
use std::sync::Mutex;
use wildmatch::WildMatch;
lazy_static! {
static ref CERTS: Mutex<Vec<CertificateConfig>> = Mutex::new(Vec::new());
}
#[derive(Debug)]
struct ProxyCertResolver;
impl ResolvesServerCert for ProxyCertResolver {
fn resolve(&self, handshake: ClientHello) -> Option<Arc<CertifiedKey>> {
let domain = handshake.server_name()?;
let certs = CERTS.lock().unwrap();
for cert in certs.iter() {
if WildMatch::new(cert.domain.as_str()).matches(domain) {
return match cert.clone().load() {
Ok(val) => Some(val),
Err(_) => None
};
}
}
None
}
}
#[derive(Clone, Serialize, Deserialize)]
struct CertificateConfig {
pub domain: String,
pub certs: String,
pub key: String,
}
impl CertificateConfig {
pub fn load(self) -> Result<Arc<CertifiedKey>, Box<dyn error::Error>> {
let certs =
rustls_pemfile::certs(&mut BufReader::new(&mut File::open(self.certs)?))
.collect::<Result<Vec<_>, _>>()?;
let key =
rustls_pemfile::private_key(&mut BufReader::new(&mut File::open(self.key)?))?
.unwrap();
let sign = RsaSigningKey::new(&key)?;
Ok(Arc::new(CertifiedKey::new(certs, Arc::new(sign))))
}
}
pub async fn load_certificates() -> Result<(), ConfigError> {
let certs = crate::config::CFG
.read()
.await
.get::<Vec<CertificateConfig>>("certificates")?;
CERTS.lock().unwrap().clone_from(&certs);
Ok(())
}
pub async fn use_rustls() -> Result<rustls::ServerConfig, ConfigError> {
load_certificates().await?;
Ok(
rustls::ServerConfig::builder()
.with_no_client_auth()
.with_cert_resolver(Arc::new(ProxyCertResolver))
)
}