From e9e4ca02630da1bf6313f1ad41f0ec1918c36dac Mon Sep 17 00:00:00 2001 From: Stefan Tomanek Date: Mon, 25 Jul 2016 23:15:45 +0200 Subject: add preference switching options to ipv6pref.sh --- bash_completion/ipv6pref | 13 +++++++++++-- ipv6pref.pod | 19 ++++++++++++++++++- scripts/ipv6pref.sh | 17 ++++++++++++++++- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/bash_completion/ipv6pref b/bash_completion/ipv6pref index 0840faf..e0c8eef 100644 --- a/bash_completion/ipv6pref +++ b/bash_completion/ipv6pref @@ -1,9 +1,18 @@ # bash completion for ipv6pref(1) _ipv6pref() { + local cur prev words cword _init_completion || return for (( i=1; i <= COMP_CWORD; i++ )); do - _command_offset $i + if [[ ${COMP_WORDS[i]} != -* ]]; then + _command_offset $i + return + fi done -} && complete -F _ipv6pref ipv6pref v6pub v6tmp + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-p -t' -- "$cur" ) ) + return + fi + +} && complete -F _ipv6pref ipv6pref.sh ipv6pref v6pub v6tmp diff --git a/ipv6pref.pod b/ipv6pref.pod index 7ca7240..38e0533 100644 --- a/ipv6pref.pod +++ b/ipv6pref.pod @@ -6,7 +6,7 @@ ipv6pref -- set IPv6 address selection preference =head1 SYNOPSIS -B F<< >> +B [B<-p> | B<-t>] F<< >> B F<< >> @@ -24,6 +24,23 @@ IPv6 Privacy Extensions. =back +=head1 OPTIONS + +=over + +=item B<-p> + +Instruct the called program to use the public IPv6 address for outgoing +connections. This is the default if the wrapper is called by the name B. + +=item B<-t> + +Instruct the called program to use the temporary, randomly generated IPv6 +addresses for outgoing connections. This is the default if the wrapper is +called by the name B. + +=back + =head1 AUTHOR Stefan Tomanek Estefan.tomanek@wertarbyte.deE diff --git a/scripts/ipv6pref.sh b/scripts/ipv6pref.sh index a7e583b..3d0af01 100755 --- a/scripts/ipv6pref.sh +++ b/scripts/ipv6pref.sh @@ -39,17 +39,32 @@ if ! [ "${IPV6PREF_WAS_HERE:-}" ]; then export LD_PRELOAD="${LIB} ${LD_PRELOAD}" fi + # check wrapper name WRAPPER="$(basename $0)" case "$WRAPPER" in v6pub) - dbg "Using public address" + dbg "Using public address by default" export IPV6PREF_ADDR="pub" ;; v6tmp) + dbg "Using temporary address by default" + export IPV6PREF_ADDR="tmp" + ;; + esac + # check for argument + case "${1:-}" in + "-p") + dbg "Using public address" + export IPV6PREF_ADDR="pub" + shift + ;; + "-t") dbg "Using temporary address" export IPV6PREF_ADDR="tmp" + shift ;; esac + fi IPV6PREF_WAS_HERE=1 exec "$@" -- cgit v1.2.3