Revolutionized
This commit is contained in:
@@ -34,7 +34,7 @@ struct AppState {
|
||||
total_tasks: Mutex<u64>,
|
||||
stats_tx: broadcast::Sender<String>,
|
||||
node_channels: tokio::sync::RwLock<HashMap<u64, tokio::sync::mpsc::UnboundedSender<String>>>, // Kohdennettu reititys
|
||||
pending_consensus: tokio::sync::RwLock<HashMap<String, Vec<serde_json::Value>>>, // Proof of Compute -konsensus
|
||||
_pending_consensus: tokio::sync::RwLock<HashMap<String, Vec<serde_json::Value>>>, // Proof of Compute -konsensus
|
||||
feature_flags: tokio::sync::RwLock<HashMap<String, bool>>, // Tuntee TODO.md:n ruksit lennosta
|
||||
ip_connections: Mutex<HashMap<IpAddr, u32>>,
|
||||
node_ips: Mutex<HashMap<u64, IpAddr>>,
|
||||
@@ -256,7 +256,7 @@ async fn main() {
|
||||
total_tasks: Mutex::new(0),
|
||||
stats_tx: stats_tx.clone(),
|
||||
node_channels: tokio::sync::RwLock::new(HashMap::new()),
|
||||
pending_consensus: tokio::sync::RwLock::new(HashMap::new()),
|
||||
_pending_consensus: tokio::sync::RwLock::new(HashMap::new()),
|
||||
feature_flags: tokio::sync::RwLock::new(HashMap::new()),
|
||||
ip_connections: Mutex::new(HashMap::new()),
|
||||
node_ips: Mutex::new(HashMap::new()),
|
||||
@@ -502,7 +502,12 @@ async fn ws_handler(
|
||||
) -> impl IntoResponse {
|
||||
// Origin-tarkistus — estää cross-site WebSocket hijackingin
|
||||
if let Some(origin) = headers.get("origin").and_then(|v| v.to_str().ok()) {
|
||||
if !ALLOWED_ORIGINS.iter().any(|&allowed| origin == allowed) {
|
||||
let is_allowed = ALLOWED_ORIGINS.iter().any(|&allowed| origin == allowed)
|
||||
|| origin.starts_with("http://192.168.")
|
||||
|| origin.starts_with("http://10.")
|
||||
|| origin.starts_with("http://172."); // LAN-avaruudet
|
||||
|
||||
if !is_allowed {
|
||||
tracing::warn!("Estetty yhteys väärällä originilla: {}", origin);
|
||||
return (
|
||||
axum::http::StatusCode::FORBIDDEN,
|
||||
@@ -1099,7 +1104,7 @@ async fn api_chat_completions(
|
||||
// Etsitään vapaa solmu — priorisoidaan natiivisolmut (GPU) selaimen edelle
|
||||
let (target_node, _total_matching) = {
|
||||
let tasks = state.node_tasks.lock().unwrap();
|
||||
let busy = state.node_busy.lock().unwrap();
|
||||
let _busy = state.node_busy.lock().unwrap();
|
||||
let node_types = state.node_types.lock().unwrap();
|
||||
let matching: Vec<u64> = tasks.iter().filter(|(_, task)| {
|
||||
// Eksakti match tai qwen-perheen yhteensopivuus (selain: qwen-coder-05b, natiivi: qwen2.5-coder:7b)
|
||||
|
||||
Reference in New Issue
Block a user