add inspect command

the inspect command is a simple wrapper arround `ss -tup`, which shows
all processes running in a given net namespace
This commit is contained in:
Guilherme Rugai Freire 2024-02-08 02:41:45 -03:00
parent 44d8318129
commit fdadef7025
No known key found for this signature in database
GPG Key ID: AC1D9B6E48E16AC1
2 changed files with 12 additions and 0 deletions

View File

@ -14,6 +14,9 @@ Usage:
./split-vpn-manager.sh run NETNS_NAME CMD
runs a command in the specified net namespace
./split-vpn-manager.sh inspect NETNS_NAME
list all processes using TCP/UDP sockets inside the specified net namespace
NOTE: Always run this script with privileged permissions (currently not)
```

View File

@ -140,6 +140,10 @@ run() {
exit $EXIT_SUCCESS
}
inspect() {
run $1 ss -tup
}
help() {
echo "Usage:"
echo " $0 launch_openvpn --name NETNS_NAME --config CONFIG_FILE --auth AUTH_FILE"
@ -148,6 +152,9 @@ help() {
echo " $0 run NETNS_NAME CMD"
echo " runs a command in the specified net namespace"
echo ""
echo " $0 inspect NETNS_NAME"
echo " list all processes using TCP/UDP sockets inside the specified net namespace"
echo ""
user_id="$(id -u)"
if [ "$user_id" -ne 0 ]; then
@ -168,6 +175,8 @@ case "$command" in
down_netns "$@";;
run)
run "$@";;
inspect)
inspect "$@";;
help|--help)
help;;
*)