Initial commit

This commit is contained in:
Pierre HUBERT 2024-08-21 14:15:51 +02:00
commit fa4a5458c2
6 changed files with 2032 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/target
.idea

1427
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

10
Cargo.toml Normal file
View File

@ -0,0 +1,10 @@
[package]
name = "hidden_server"
version = "0.1.0"
edition = "2021"
[dependencies]
log = "0.4.22"
env_logger = "0.11.5"
actix-web = "4"
rand = "0.9.0-alpha.2"

2
README.md Normal file
View File

@ -0,0 +1,2 @@
# Hidden Server
A server that spawns in a random port at each start

558
assets/home.html Normal file
View File

@ -0,0 +1,558 @@
<!-- Credits to https://codepen.io/alvaromontoro/pen/GRNmdzB -->
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>You win</title>
<style>
html, body {
padding: 0;
margin: 0;
width: 100vw;
height: 100vh;
position: relative;
overflow: hidden;
background: linear-gradient(#123, #111);
}
.snowflake {
--size: 1vw;
width: var(--size);
height: var(--size);
background: white;
border-radius: 50%;
position: absolute;
top: -5vh;
}
@keyframes snowfall {
0% {
transform: translate3d(var(--left-ini), 0, 0);
}
100% {
transform: translate3d(var(--left-end), 110vh, 0);
}
}
.snowflake:nth-child(1) {
--size: 0.8vw;
--left-ini: 0vw;
--left-end: -3vw;
left: 55vw;
animation: snowfall 10s linear infinite;
animation-delay: -3s;
}
.snowflake:nth-child(2) {
--size: 0.2vw;
--left-ini: -4vw;
--left-end: 7vw;
left: 85vw;
animation: snowfall 13s linear infinite;
animation-delay: -6s;
}
.snowflake:nth-child(3) {
--size: 0.6vw;
--left-ini: -3vw;
--left-end: 10vw;
left: 70vw;
animation: snowfall 7s linear infinite;
animation-delay: -8s;
}
.snowflake:nth-child(4) {
--size: 0.6vw;
--left-ini: 1vw;
--left-end: 0vw;
left: 26vw;
animation: snowfall 7s linear infinite;
animation-delay: -8s;
}
.snowflake:nth-child(5) {
--size: 0.4vw;
--left-ini: -2vw;
--left-end: -9vw;
left: 2vw;
animation: snowfall 6s linear infinite;
animation-delay: -3s;
}
.snowflake:nth-child(6) {
--size: 0.8vw;
--left-ini: -7vw;
--left-end: 6vw;
left: 12vw;
animation: snowfall 13s linear infinite;
animation-delay: -7s;
}
.snowflake:nth-child(7) {
--size: 0.8vw;
--left-ini: 1vw;
--left-end: 6vw;
left: 50vw;
animation: snowfall 10s linear infinite;
animation-delay: -7s;
}
.snowflake:nth-child(8) {
--size: 1vw;
--left-ini: -8vw;
--left-end: 6vw;
left: 33vw;
animation: snowfall 11s linear infinite;
animation-delay: -6s;
}
.snowflake:nth-child(9) {
--size: 0.8vw;
--left-ini: 7vw;
--left-end: 10vw;
left: 93vw;
animation: snowfall 15s linear infinite;
animation-delay: -1s;
}
.snowflake:nth-child(10) {
--size: 0.4vw;
--left-ini: -9vw;
--left-end: -6vw;
left: 77vw;
animation: snowfall 11s linear infinite;
animation-delay: -4s;
}
.snowflake:nth-child(11) {
--size: 0.4vw;
--left-ini: 5vw;
--left-end: -5vw;
left: 25vw;
animation: snowfall 14s linear infinite;
animation-delay: -10s;
}
.snowflake:nth-child(12) {
--size: 0.6vw;
--left-ini: -9vw;
--left-end: 2vw;
left: 55vw;
animation: snowfall 9s linear infinite;
animation-delay: -9s;
}
.snowflake:nth-child(13) {
--size: 0.4vw;
--left-ini: 5vw;
--left-end: -4vw;
left: 57vw;
animation: snowfall 11s linear infinite;
animation-delay: -9s;
}
.snowflake:nth-child(14) {
--size: 0.6vw;
--left-ini: -8vw;
--left-end: -3vw;
left: 80vw;
animation: snowfall 7s linear infinite;
animation-delay: -5s;
}
.snowflake:nth-child(15) {
--size: 0.6vw;
--left-ini: 3vw;
--left-end: -4vw;
left: 58vw;
animation: snowfall 7s linear infinite;
animation-delay: -9s;
}
.snowflake:nth-child(16) {
--size: 1vw;
--left-ini: -5vw;
--left-end: -6vw;
left: 70vw;
animation: snowfall 11s linear infinite;
animation-delay: -3s;
}
.snowflake:nth-child(17) {
--size: 0.2vw;
--left-ini: 9vw;
--left-end: 0vw;
left: 14vw;
animation: snowfall 14s linear infinite;
animation-delay: -8s;
}
.snowflake:nth-child(18) {
--size: 0.2vw;
--left-ini: 7vw;
--left-end: 8vw;
left: 75vw;
animation: snowfall 10s linear infinite;
animation-delay: -4s;
}
.snowflake:nth-child(19) {
--size: 0.4vw;
--left-ini: 1vw;
--left-end: -6vw;
left: 73vw;
animation: snowfall 9s linear infinite;
animation-delay: -5s;
}
.snowflake:nth-child(20) {
--size: 0.8vw;
--left-ini: 3vw;
--left-end: -7vw;
left: 61vw;
animation: snowfall 13s linear infinite;
animation-delay: -8s;
}
.snowflake:nth-child(21) {
--size: 0.6vw;
--left-ini: -4vw;
--left-end: 1vw;
left: 23vw;
animation: snowfall 8s linear infinite;
animation-delay: -10s;
}
.snowflake:nth-child(22) {
--size: 0.8vw;
--left-ini: -8vw;
--left-end: 7vw;
left: 58vw;
animation: snowfall 10s linear infinite;
animation-delay: -2s;
}
.snowflake:nth-child(23) {
--size: 0.4vw;
--left-ini: 8vw;
--left-end: 0vw;
left: 36vw;
animation: snowfall 12s linear infinite;
animation-delay: -4s;
}
.snowflake:nth-child(24) {
--size: 0.2vw;
--left-ini: 0vw;
--left-end: 3vw;
left: 70vw;
animation: snowfall 14s linear infinite;
animation-delay: -10s;
}
.snowflake:nth-child(25) {
--size: 0.6vw;
--left-ini: 0vw;
--left-end: -1vw;
left: 59vw;
animation: snowfall 9s linear infinite;
animation-delay: -7s;
}
.snowflake:nth-child(26) {
--size: 1vw;
--left-ini: 1vw;
--left-end: 0vw;
left: 7vw;
animation: snowfall 8s linear infinite;
animation-delay: -7s;
}
.snowflake:nth-child(27) {
--size: 1vw;
--left-ini: 3vw;
--left-end: -1vw;
left: 42vw;
animation: snowfall 7s linear infinite;
animation-delay: -1s;
}
.snowflake:nth-child(28) {
--size: 0.2vw;
--left-ini: 9vw;
--left-end: 2vw;
left: 13vw;
animation: snowfall 14s linear infinite;
animation-delay: -5s;
}
.snowflake:nth-child(29) {
--size: 0.6vw;
--left-ini: 9vw;
--left-end: 8vw;
left: 1vw;
animation: snowfall 8s linear infinite;
animation-delay: -8s;
}
.snowflake:nth-child(30) {
--size: 0.4vw;
--left-ini: 5vw;
--left-end: -6vw;
left: 70vw;
animation: snowfall 6s linear infinite;
animation-delay: -3s;
}
.snowflake:nth-child(31) {
--size: 0.4vw;
--left-ini: 7vw;
--left-end: -7vw;
left: 10vw;
animation: snowfall 11s linear infinite;
animation-delay: -7s;
}
.snowflake:nth-child(32) {
--size: 0.6vw;
--left-ini: 7vw;
--left-end: 7vw;
left: 90vw;
animation: snowfall 14s linear infinite;
animation-delay: -3s;
}
.snowflake:nth-child(33) {
--size: 1vw;
--left-ini: 1vw;
--left-end: 9vw;
left: 60vw;
animation: snowfall 15s linear infinite;
animation-delay: -1s;
}
.snowflake:nth-child(34) {
--size: 0.4vw;
--left-ini: -9vw;
--left-end: -6vw;
left: 96vw;
animation: snowfall 11s linear infinite;
animation-delay: -2s;
}
.snowflake:nth-child(35) {
--size: 1vw;
--left-ini: 10vw;
--left-end: 8vw;
left: 85vw;
animation: snowfall 15s linear infinite;
animation-delay: -7s;
}
.snowflake:nth-child(36) {
--size: 1vw;
--left-ini: 7vw;
--left-end: -5vw;
left: 6vw;
animation: snowfall 14s linear infinite;
animation-delay: -6s;
}
.snowflake:nth-child(37) {
--size: 0.4vw;
--left-ini: 3vw;
--left-end: 3vw;
left: 76vw;
animation: snowfall 12s linear infinite;
animation-delay: -5s;
}
.snowflake:nth-child(38) {
--size: 0.8vw;
--left-ini: -4vw;
--left-end: -3vw;
left: 53vw;
animation: snowfall 11s linear infinite;
animation-delay: -4s;
}
.snowflake:nth-child(39) {
--size: 0.6vw;
--left-ini: -3vw;
--left-end: 2vw;
left: 2vw;
animation: snowfall 7s linear infinite;
animation-delay: -3s;
}
.snowflake:nth-child(40) {
--size: 0.6vw;
--left-ini: 9vw;
--left-end: -1vw;
left: 80vw;
animation: snowfall 13s linear infinite;
animation-delay: -7s;
}
.snowflake:nth-child(41) {
--size: 0.8vw;
--left-ini: -2vw;
--left-end: 6vw;
left: 52vw;
animation: snowfall 15s linear infinite;
animation-delay: -9s;
}
.snowflake:nth-child(42) {
--size: 0.2vw;
--left-ini: 3vw;
--left-end: 4vw;
left: 9vw;
animation: snowfall 6s linear infinite;
animation-delay: -3s;
}
.snowflake:nth-child(43) {
--size: 0.6vw;
--left-ini: 3vw;
--left-end: 3vw;
left: 80vw;
animation: snowfall 14s linear infinite;
animation-delay: -2s;
}
.snowflake:nth-child(44) {
--size: 0.2vw;
--left-ini: -5vw;
--left-end: 8vw;
left: 14vw;
animation: snowfall 6s linear infinite;
animation-delay: -2s;
}
.snowflake:nth-child(45) {
--size: 0.8vw;
--left-ini: 9vw;
--left-end: -9vw;
left: 46vw;
animation: snowfall 12s linear infinite;
animation-delay: -1s;
}
.snowflake:nth-child(46) {
--size: 0.4vw;
--left-ini: 8vw;
--left-end: -4vw;
left: 11vw;
animation: snowfall 9s linear infinite;
animation-delay: -10s;
}
.snowflake:nth-child(47) {
--size: 1vw;
--left-ini: -7vw;
--left-end: 0vw;
left: 74vw;
animation: snowfall 12s linear infinite;
animation-delay: -3s;
}
.snowflake:nth-child(48) {
--size: 0.6vw;
--left-ini: -5vw;
--left-end: -4vw;
left: 24vw;
animation: snowfall 7s linear infinite;
animation-delay: -7s;
}
.snowflake:nth-child(49) {
--size: 0.4vw;
--left-ini: 0vw;
--left-end: -9vw;
left: 15vw;
animation: snowfall 11s linear infinite;
animation-delay: -4s;
}
.snowflake:nth-child(50) {
--size: 0.2vw;
--left-ini: 8vw;
--left-end: -2vw;
left: 42vw;
animation: snowfall 6s linear infinite;
animation-delay: -9s;
}
/* added small blur every 6 snowflakes*/
.snowflake:nth-child(6n) {
filter: blur(1px);
}
@keyframes blinker {
50% {
opacity: 0;
}
}
</style>
</head>
<body>
<div style="font-size: 150%; text-align: center; color: white;animation: blinker 1s step-start infinite;">You found the hidden server!</div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
</body>
</html>

33
src/main.rs Normal file
View File

@ -0,0 +1,33 @@
use actix_web::middleware::Logger;
use actix_web::{web, App, HttpResponse, HttpServer};
use log::LevelFilter;
use rand::Rng;
async fn home() -> HttpResponse {
log::info!("Successfully found the port!");
HttpResponse::Ok()
.content_type("text/html")
.body(include_str!("../assets/home.html"))
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
env_logger::Builder::new()
.filter_module("actix_server::server", LevelFilter::Warn)
.filter(None, LevelFilter::Info)
.init();
log::info!("Choosing a random port to start...");
let mut rng = rand::thread_rng();
let port: u16 = 80 + rng.random::<u16>() % 10000;
HttpServer::new(|| {
App::new()
.wrap(Logger::default())
.route("/", web::get().to(home))
})
.bind(("127.0.0.1", port))?
.run()
.await
}