3 ms·
nc5
As a useless exercise I rewrote one of the scripts I use frequently for making HTTP requests so that no regular files were used with yy025.
# usage: echo https://example.org | $0
# usage: echo https://example.org | $0 93.184.216.34
# usage: echo https://example.org | $0 93.184.216.34 example.com
# usage: (ka;$0) < url-list
# 127.0.0.61 is haproxy
# 127.0.0.62 is stunnel
test -f /path/stunnel_xyz||echo "
foreground=no
debug=debug
pid=/path/stunnel_xyz.pid
[ x ]
accept=127.0.0.62:80
client=yes
options=NO_TICKET
options=NO_RENEGOTIATION
renegotiation=no
sslVersion=TLSv1.3
sni=
connect=127.0.0.61:443
" > /path/stunnel_xyz
test -f /path/stunnel_xyz.pid||stunnel /path/stunnel_xyz
test -p 1.fifo||mkfifo 1.fifo
test -p 2.fifo||mkfifo 2.fifo
(tmux loadb -b host 1.fifo &)
(tmux loadb -b http 2.fifo &)
x(){ nc -vvn 127.0.0.61 80|yy045;}
x(){ tcpclient -RHDl0 127.0.0.61:80 sh -c "sed >&6;yy045 <&7";}
x(){ socat stdio,ignoreeof tcp:127.0.0.61:80|yy045;}
x(){ openssl s_client -connect 127.0.0.61:443 -ign_eof 2>/dev/null|yy045;}
x(){ bssl client -connect 127.0.0.61:443 2>/dev/null|yy045;}
xy(){ nc -vvn 127.62 80|yy045;}
xy(){ tcpclient -RHDl0 127.0.0.62:80 sh -c "sed >&6;yy045 <&7";}
xy(){ socat stdio,ignoreeof tcp:127.0.0.62:80|yy045;}
yy025 5>1.fifo >2.fifo;x=$(tmux saveb -b host /dev/stdout);
echo "<base href=https://$x />";
case $# in :)
;;0)tmux saveb -b http /dev/stdout|x;
;;1|2)
sed -i "/^ *connect=/s/=.*/=$1:443/;/^ *sni=/s/=.*/=$2/" /path/stunnel_xyz;
read x < /path/stunnel_xyz.pid;
kill -HUP $x;
tmux saveb -b http /dev/stdout|xy;
esac
#tmux deleteb -b http
#tmux deleteb -b host
- 1vuio0pswjnm7 3y agoThis does not work in pipelines where nc5 is to be used more than once. Simpler version using regular files, no fifos, no tmux. test -f /path/stunnel_xyz||echo " foreground=no debug=debug pid=/path/stunnel_xyz.pid [ x ] accept=127.0.0.62:80 client=yes options=NO_TICKET options=NO_RENEGOTIATION renegotiation=no sslVersion=TLSv1.3 sni= connect=127.0.0.61:443 " > /path/stunnel_xyz test -f /path/stunnel_xyz.pid||stunnel /path/stunnel_xyz x(){ tcpclient -RHDl0 127.0.0.61:80 sh -c "sed >&6;yy045 <&7";} x(){ socat stdio,ignoreeof tcp:127.0.0.61:80|yy045;} x(){ openssl s_client -connect 127.0.0.61:443 -ign_eof 2>/dev/null|yy045;} x(){ bssl client -connect 127.0.0.61:443 2>/dev/null|yy045;} x(){ nc -vvn 127.0.0.61 80|yy045;} xy(){ nc -vvn 127.62 80|yy045;} xy(){ tcpclient -RHDl0 127.0.0.62:80 sh -c "sed >&6;yy045 <&7";} xy(){ socat stdio,ignoreeof tcp:127.0.0.62:80|yy045;} yy025 5>.1 >.2;read x<.1 echo "<base href=https://$x />"; case $# in :) ;;0)x<.2; ;;1|2) sed -i "/^ *connect=/s/=.*/=$1:443/;/^ *sni=/s/=.*/=$2/" /path/stunnel_xyz; xy<.2; esac