-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlistenin.nix
More file actions
36 lines (30 loc) · 813 Bytes
/
listenin.nix
File metadata and controls
36 lines (30 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{ config, stdenv, pkgs, ...}:
let
port = 80;
file = pkgs.writeText "index.html" ''
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Server: Your moms Server
<!doctype html>
<html>
<head><title>Hello :)</title>
<body>
<h1>Hi, you hit my computer</h1>
<p>You can leave me a message if you netcat onto this port :)</p>
</body>
</html>
'';
in {
systemd.services."listenin" = {
enable = true;
after = [ "network.target" ];
path = [ pkgs.netcat ];
description = "listening in if somebody is doing stuff :)";
script = ''
while true; do
< "${file}" nc -N -4 -l ${builtins.toString port}
done
'';
};
networking.firewall.allowedTCPPorts = [ port ];
}