1#!/bin/sh 2 3RUMPLIBS="-lrumpnet -lrumpnet_net -lrumpnet_netinet \ 4 -lrumpdev -lrumpvfs -lrumpdev_opencrypto -lrumpkern_z \ 5 -lrumpkern_crypto -lrumpnet_wg -lrumpnet_netinet6" 6HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so \ 7 RUMPHIJACK=path=/rump,socket=all:nolocal,sysctl=yes" 8 9if [ $(whoami) != root ]; then 10 echo run as root 11 exit 1 12fi 13 14usage() 15{ 16 local prog=$(basename $0) 17 18 echo "Usage:" 19 echo -e "\t$prog <id> create" 20 echo -e "\t$prog <id> destroy" 21 echo -e "\t$prog <id> ifconfig [args...]" 22 echo -e "\t$prog <id> wgconfig [args...]" 23 echo 24 echo "<id>: must be a numeric number as it's used as an interface ID" 25 exit 1 26} 27 28if [ $# -lt 2 ]; then 29 usage 30fi 31 32ifid=$1 33cmd=$2 34shift;shift 35args="$*" 36 37tun=tun$ifid 38wg=wg$ifid 39 40sock=/var/run/wg_rump.${ifid}.sock 41export RUMP_SERVER=unix://$sock 42 43case $cmd in 44create) 45 rump_server $RUMPLIBS unix://$sock 46 rump.ifconfig $wg create 47 rump.ifconfig $wg linkstr $tun 48 ;; 49destroy) 50 rump.halt 51 ;; 52ifconfig) 53 rump.ifconfig $args 54 ;; 55wgconfig) 56 $HIJACKING wgconfig $args 57 ;; 58debug) 59 $HIJACKING $args 60 ;; 61*) 62 usage 63esac 64