From fdadef7025d56a27c34102cf226b3df2ae909b8e Mon Sep 17 00:00:00 2001 From: Guilherme Rugai Freire Date: Thu, 8 Feb 2024 02:41:45 -0300 Subject: [PATCH] add inspect command the inspect command is a simple wrapper arround `ss -tup`, which shows all processes running in a given net namespace --- README.md | 3 +++ split-vpn-manager.sh | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/README.md b/README.md index bfaf532..a6bba14 100644 --- a/README.md +++ b/README.md @@ -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) ``` diff --git a/split-vpn-manager.sh b/split-vpn-manager.sh index 6e5f608..b6f153b 100755 --- a/split-vpn-manager.sh +++ b/split-vpn-manager.sh @@ -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;; *)