config/users/pbsds/home/profiles/sshuttle.nix

22 lines
669 B
Nix
Raw Normal View History

2024-07-31 01:57:47 +02:00
# https://nix-community.github.io/home-manager/options.html
{ pkgs, config, ... }:
{
home.packages = with pkgs; [
sshuttle
];
programs.bash.initExtra = ''
function vpn (
ip="$(dig +short -x a $1 | tail -n 1)"
set -x
sshuttle 0.0.0.0/0 --disable-ipv6 --dns -r "$1" -x $ip -x 127.0.0.1 -x 172.0.0.0/8
)
if test -f ~/.ssh/config; then
complete -W "$(cat ~/.ssh/config | grep "^Host " | cut -d" " -f2- | grep -v '\*')" vpn
complete -W "$(cat ~/.ssh/config | grep "^Host " | cut -d" " -f2- | grep -v '\*')" lvpn
complete -W "$(cat ~/.ssh/config | grep "^Host " | cut -d" " -f2- | grep -v '\*')" dvpn
fi
'';
}