tinc/bash_completion.d/tinc
Etienne Dechamps 7939ee1283 Add UDP discovery mechanism.
This adds a new mechanism by which tinc can determine if a node is
reachable via UDP. The new mechanism is currently redundant with the
PMTU discovery mechanism - that will be fixed in a future commit.

Conceptually, the UDP discovery mechanism works similarly to PMTU
discovery: it sends UDP probes (of minmtu size, to make sure the tunnel
is fully usable), and assumes UDP is usable if it gets replies. It
assumes UDP is broken if too much time has passed since the last reply.

The big difference with the current PMTU discovery mechanism, however,
is that UDP discovery probes are only triggered as part of the
packet TX path (through try_tx()). This is quite interesting, because
it means tinc will never send UDP pings more often than normal packets,
and most importantly, it will automatically stop sending pings as soon
as packets stop flowing, thereby nicely reducing network chatter.

Of course, there are small drawbacks in some edge cases: for example,
if a node only sends one packet every minute to another node, these
packets will only be sent over TCP, because the interval between packets
is too long for tinc to maintain the UDP tunnel. I consider this a
feature, not a bug: I believe it is appropriate to use TCP in scenarios
where traffic is negligible, so that we don't pollute the network with
pings just to maintain a UDP tunnel that's seeing negligible usage.
2015-01-01 17:40:15 +00:00

92 lines
2.8 KiB
Text

_tinc() {
local cur prev opts confvars commands nets
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="-c -d -D -K -n -o -L -R -U --config --no-detach --debug --net --option --mlock --logfile --pidfile --chroot --user --help --version"
confvars="Address AddressFamily BindToAddress BindToInterface Broadcast BroadcastSubnet Cipher ClampMSS Compression ConnectTo DecrementTTL Device DeviceStandby DeviceType Digest DirectOnly Ed25519PrivateKeyFile Ed25519PublicKey Ed25519PublicKeyFile ExperimentalProtocol Forwarding GraphDumpFile Hostnames IffOneQueue IndirectData Interface KeyExpire ListenAddress LocalDiscovery MACExpire MACLength MaxOutputBufferSize MaxTimeout Mode Name PMTU PMTUDiscovery PingInterval PingTimeout Port PriorityInheritance PrivateKeyFile ProcessPriority Proxy PublicKeyFile ReplayWindow StrictSubnets Subnet TCPOnly TunnelServer UDPDiscovery UDPDiscoveryInterval UDPDiscoveryTimeout UDPRcvBuf UDPSndBuf VDEGroup VDEPort Weight"
commands="add connect debug del disconnect dump edit export export-all generate-ed25519-keys generate-keys generate-rsa-keys get help import info init invite join log network pcap pid purge reload restart retry set start stop top version"
case ${prev} in
-c|--config)
compopt -o dirnames 2>/dev/null
return 0
;;
-n|--net)
nets=""
pushd /etc/tinc >/dev/null 2>/dev/null
for dir in *; do
if [[ -f "$dir/tinc.conf" ]]; then
nets="$nets $dir"
fi
done
popd >/dev/null 2>/dev/null
COMPREPLY=( $(compgen -W "${nets}" -- ${cur}) )
return 0
;;
-o|--option)
compopt -o nospace
COMPREPLY=( $(compgen -W "${confvars}" -- ${cur}) )
if [[ ${#COMPREPLY[*]} == 1 ]] ; then
COMPREPLY=$COMPREPLY=
fi
return 0
;;
-U|--user)
COMPREPLY=( $(compgen -u ${cur}) )
return 0
;;
--logfile|--pidfile)
compopt -o filenames 2>/dev/null
COMPREPLY=( $(compgen -f ${cur}) )
return 0
esac
if [[ ${cur} == -* ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
if [[ $1 == "d" ]]; then
if [[ -z ${cur} ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
fi
return 0
fi
COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) )
case $prev in
get|set|add|del)
COMPREPLY=( $(compgen -W "${confvars}" -- ${cur}) )
return 0
;;
dump|reachable)
COMPREPLY=( $(compgen -W "reachable nodes edges subnets connections graph" -- ${cur}) )
return 0
;;
network)
nets=""
pushd /etc/tinc >/dev/null 2>/dev/null
for dir in *; do
if [[ -f "$dir/tinc.conf" ]]; then
nets="$nets $dir"
fi
done
popd >/dev/null 2>/dev/null
COMPREPLY=( $(compgen -W "${nets}" -- ${cur}) )
return 0
;;
esac
if [[ -z ${cur} ]] ; then
COMPREPLY=( $(compgen -W "${opts} ${commands}" -- ${cur}) )
fi
return 0
}
_tincd() {
_tinc d;
}
_tincctl() {
_tinc ctl;
}
complete -F _tincd tincd
complete -F _tincctl tinc