caddy fiilailuu
This commit is contained in:
5
network-poc/.dockerignore
Normal file
5
network-poc/.dockerignore
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
target/
|
||||||
|
target-native/
|
||||||
|
static/pkg/
|
||||||
|
.git/
|
||||||
|
*.md
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
kipina.studio {
|
kipina.studio {
|
||||||
reverse_proxy hub:3000
|
reverse_proxy hub:3000 {
|
||||||
|
header_up X-Forwarded-For {remote_host}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,29 @@ RUN apt-get update && apt-get install -y \
|
|||||||
RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
|
RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
|
||||||
|
# 1. Kopioi vain Cargo-tiedostot → riippuvuudet cacheen
|
||||||
|
COPY Cargo.toml Cargo.lock ./
|
||||||
|
COPY hub/Cargo.toml hub/Cargo.toml
|
||||||
|
COPY node/Cargo.toml node/Cargo.toml
|
||||||
|
COPY native-node/Cargo.toml native-node/Cargo.toml
|
||||||
|
|
||||||
|
# Tyhjät lähteet riippuvuuksien esikääntämistä varten
|
||||||
|
RUN mkdir -p hub/src node/src native-node/src \
|
||||||
|
&& echo "fn main(){}" > hub/src/main.rs \
|
||||||
|
&& echo "" > node/src/lib.rs \
|
||||||
|
&& mkdir -p node/src && touch node/src/storage.rs \
|
||||||
|
&& echo "fn main(){}" > native-node/src/main.rs \
|
||||||
|
&& cargo build --release -p hub 2>/dev/null || true \
|
||||||
|
&& wasm-pack build node --target web --out-dir ../static/pkg 2>/dev/null || true
|
||||||
|
|
||||||
|
# 2. Kopioi oikea lähdekoodi → vain src käännetään uudelleen
|
||||||
|
COPY hub/src hub/src
|
||||||
|
COPY node/src node/src
|
||||||
|
COPY static static
|
||||||
|
|
||||||
|
# Pakota uudelleenkäännös
|
||||||
|
RUN touch hub/src/main.rs node/src/lib.rs
|
||||||
|
|
||||||
# Rakenna Wasm-paketti
|
# Rakenna Wasm-paketti
|
||||||
RUN cd node && wasm-pack build --target web --out-dir ../static/pkg
|
RUN cd node && wasm-pack build --target web --out-dir ../static/pkg
|
||||||
|
|||||||
@@ -142,11 +142,11 @@ async fn ws_handler(
|
|||||||
{
|
{
|
||||||
let conns = state.ip_connections.lock().unwrap();
|
let conns = state.ip_connections.lock().unwrap();
|
||||||
let count = conns.get(&ip).copied().unwrap_or(0);
|
let count = conns.get(&ip).copied().unwrap_or(0);
|
||||||
if count >= 2 {
|
if count >= 4 {
|
||||||
tracing::warn!("IP {} ylitti yhteysrajan ({}/2) — estetty", ip, count);
|
tracing::warn!("IP {} ylitti yhteysrajan ({}/4) — estetty", ip, count);
|
||||||
return (
|
return (
|
||||||
axum::http::StatusCode::TOO_MANY_REQUESTS,
|
axum::http::StatusCode::TOO_MANY_REQUESTS,
|
||||||
"Max 2 yhteyttä per IP",
|
"Max 4 yhteyttä per IP",
|
||||||
).into_response();
|
).into_response();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user