#!/bin/bash
# Test-Ersatz fuer ss: echte Ausgabe plus erfundene Lauscher, etwa ein
# anderer Webserver auf Port 80/443 dieses Rechners.
#   STUB_LISTEN="tcp:80:nginx tcp:443:nginx"
. "$(dirname "$0")/../stublib"
real=$(PATH=$(printf '%s' "$PATH" | tr ':' '\n' | grep -v '/installer/tests/stubs/' | paste -sd: -) command -v ss)
"$real" "$@" 2>/dev/null
case " $* " in
*" -Hlntup "*)
	for l in ${STUB_LISTEN:-}; do
		IFS=: read -r proto port name <<<"$l"
		printf '%s   LISTEN 0      511          0.0.0.0:%s        0.0.0.0:*    users:(("%s",pid=999999,fd=6))\n' "$proto" "$port" "$name"
	done
	;;
esac
exit 0
