📝 Playing around with netcat

This commit is contained in:
z3rOR0ne 2022-12-16 19:45:33 -08:00
parent 58a1590583
commit e40b10096e
5 changed files with 28 additions and 9 deletions

View file

@ -0,0 +1,2 @@
This directory is simply to play around with nc. Eventually the hope is to
replace live-server with a nc/websockets implementation in bash.

View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>test</title>
</head>
<body>
<h1 style="color: red;">This is a test, and this is more.</h1>
<script type="application/javascript" src="http://localhost:8081"></script>
</body>
</html>

1
scripts/nc_play/index.js Normal file
View file

@ -0,0 +1 @@
console.log('hi')

13
scripts/nc_play/nk Executable file
View file

@ -0,0 +1,13 @@
#!/usr/bin/env bash
servefile="$1"
port="$2"
main() {
while :
do
echo -e "HTTP/1.1 200 OK\n\n$(cat "$servefile")" | nc -l -p "$port" -q 1
done
}
main

View file

@ -1,9 +0,0 @@
#!/usr/bin/env bash
servefile="$1"
while :
do
# echo -e "HTTP/1.1 200 OK\n\n$(echo '<h1>Hi there</h1>')" | nc -l -k -p 8080 -q 1
echo -e "HTTP/1.1 200 OK\n\n$(cat "$servefile")" | nc -l -k -p 8080 -q 1
done