Skip to content

Commit 6024f01

Browse files
committed
add netcat support
1 parent 3556ef7 commit 6024f01

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

core.sh

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ debug() {
1818

1919
if [[ "${DEV:-true}" == true ]]; then
2020
USE_HMR="$(which inotifywait)"
21+
22+
# disable HMR when using netcat
23+
if [[ "$TCP_PROVIDER" == "nc" ]]; then
24+
USE_HMR=""
25+
fi
2126
fi
2227

2328
header() {

examples/docs/data/1-configuration.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ will check:
1111
- `HIDE_LOGO` - if this is set, the "powered by bash" logo will be hidden
1212
- `NO_STYLES` - if this is set, no CSS will be linked in the `<head>`
1313
- `ENABLE_SESSIONS` - if this is 'true', bash stack will manage sessions (using a `_session` cookie).
14+
- `TCP_PROVIDER` (default: tcpserver) - you can optionally use `nc` instead.
1415

1516
## Tailwind
1617

start.sh

+22-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,28 @@ mkdir -p data
2323
mkdir -p uploads
2424

2525
PORT=${PORT:-3000}
26-
echo -n "Listening on port "
27-
tcpserver -1 -o -l 0 -H -R -c 1000 0 $PORT ./core.sh
26+
27+
TCP_PROVIDER=${TCP_PROVIDER:-tcpserver}
28+
29+
case "$TCP_PROVIDER" in
30+
tcpserver)
31+
echo -n "Listening on port "
32+
tcpserver -1 -o -l 0 -H -R -c 1000 0 $PORT ./core.sh
33+
;;
34+
nc)
35+
[[ ! -p nc_tunnel ]] && mkfifo nc_tunnel
36+
[[ "${DEV:-true}" == true ]] && \
37+
echo "WARNING: performance while using netcat will be significantly degraded!"
38+
echo "Listening on port $PORT"
39+
while true; do
40+
< nc_tunnel nc -l $PORT | ./core.sh >nc_tunnel
41+
done
42+
;;
43+
*)
44+
echo "ERROR: unsupported TCP_PROVIDER"
45+
exit 1
46+
;;
47+
esac
2848

2949
if [[ ! -z "$PID" ]]; then
3050
kill "$PID"

0 commit comments

Comments
 (0)