security/tailscale: Add suupport for extra arguments

Add a rc.conf variable to support passing extra arguments to tailscale
up.

Thanks to Gregory for advicing on the implementation.

Reported by:	Gregory Shapiro <gshapiro at gshapiro dot net>
This commit is contained in:
Ashish SHUKLA 2022-10-21 16:12:08 +00:00
parent 4b8953300f
commit 1e38c92fd1
No known key found for this signature in database
2 changed files with 8 additions and 1 deletions

View file

@ -1,5 +1,6 @@
PORTNAME= tailscale
PORTVERSION= 1.32.0
PORTREVISION= 1
DISTVERSIONPREFIX= v
CATEGORIES= security net-vpn

View file

@ -19,6 +19,8 @@
# Default is "daemon". See daemon(8).
# tailscaled_exitnode_enable (bool): Set it to YES to announce tailscaled as
# an exit node. Default is "NO".
# tailscaled_up_args (str): Additional arguments to pass to tailscale up
# Default is "" (empty string).
# tailscaled_tun_dev (str): Set the name of the tun interface tailscaled creates.
# Default is "tailscale0"
@ -32,6 +34,7 @@ load_rc_config $name
: ${tailscaled_enable:="NO"}
: ${tailscaled_port:="41641"}
: ${tailscaled_exitnode_enable:="NO"}
: ${tailscaled_up_args:=""}
: ${tailscaled_tun_dev:="tailscale0"}
DAEMON=$(/usr/sbin/daemon 2>&1 | grep -q syslog ; echo $?)
@ -78,7 +81,10 @@ tailscaled_poststart()
{
if checkyesno tailscaled_exitnode_enable; then
logger -s -t tailscale "Enabling Exit node mode"
${ctlname} up --advertise-exit-node
tailscaled_up_args=" --advertise-exit-node ${tailscaled_up_args}"
fi
if [ -n "${tailscaled_up_args}" ]; then
${ctlname} up ${tailscaled_up_args}
fi
}