25154f5f0c
Still planning to replace wgconfig(8) and wg-keygen(8) by one wg(8) tool compatible with wireguard-tools; update wg(4) for the minor changes from the 2018-06-30 spec to the 2020-06-01 spec; &c. This just clarifies the current state of affairs as it exists in the development tree for now. Mark the man page EXPERIMENTAL for extra clarity.
64 lines
1.0 KiB
Bash
64 lines
1.0 KiB
Bash
#!/bin/sh
|
|
|
|
RUMPLIBS="-lrumpnet -lrumpnet_net -lrumpnet_netinet \
|
|
-lrumpdev -lrumpvfs -lrumpdev_opencrypto -lrumpkern_z \
|
|
-lrumpkern_crypto -lrumpnet_wg -lrumpnet_netinet6"
|
|
HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so \
|
|
RUMPHIJACK=path=/rump,socket=all:nolocal,sysctl=yes"
|
|
|
|
if [ $(whoami) != root ]; then
|
|
echo run as root
|
|
exit 1
|
|
fi
|
|
|
|
usage()
|
|
{
|
|
local prog=$(basename $0)
|
|
|
|
echo "Usage:"
|
|
echo -e "\t$prog <id> create"
|
|
echo -e "\t$prog <id> destroy"
|
|
echo -e "\t$prog <id> ifconfig [args...]"
|
|
echo -e "\t$prog <id> wgconfig [args...]"
|
|
echo
|
|
echo "<id>: must be a numeric number as it's used as an interface ID"
|
|
exit 1
|
|
}
|
|
|
|
if [ $# -lt 2 ]; then
|
|
usage
|
|
fi
|
|
|
|
ifid=$1
|
|
cmd=$2
|
|
shift;shift
|
|
args="$*"
|
|
|
|
tun=tun$ifid
|
|
wg=wg$ifid
|
|
|
|
sock=/var/run/wg_rump.${ifid}.sock
|
|
export RUMP_SERVER=unix://$sock
|
|
|
|
case $cmd in
|
|
create)
|
|
rump_server $RUMPLIBS unix://$sock
|
|
rump.ifconfig $wg create
|
|
rump.ifconfig $wg linkstr $tun
|
|
;;
|
|
destroy)
|
|
rump.halt
|
|
;;
|
|
ifconfig)
|
|
rump.ifconfig $args
|
|
;;
|
|
wgconfig)
|
|
$HIJACKING wgconfig $args
|
|
;;
|
|
debug)
|
|
$HIJACKING $args
|
|
;;
|
|
*)
|
|
usage
|
|
esac
|