Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable use of alternate Tailscale auth server #125

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tailscale/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ For example:
| ---- | ----- | ----- |
| tsroutes | 172.16.0.0/12 | Manually add a tailscale routes, comma separated
| tsversion | 1.60.1 | Use this version of tailscale explicitly
| tsserver | https://headscale.example.com | Enable use of self-hosted login server such as [Headscale](https://headscale.net/)

## Overlapping subnets
You can use tailscales 4via6 feature if you would like to get to devices behind a Cradlepoint routers that might share the same subnet. First come up with a site id you would like to use (0-65535). Then from a computer with tailscale installed execute: `tailscale debug via [site-id] [subnet]`. For example: `tailscale debug via 1 172.16.0.0/12` should generate a 4via6 subnet of `fd7a:115c:a1e0:b1a:0:1:ac10:0/108`. Add this as a tsroute above and you can access the network via ipv6 or by the domain name following the format `Q-R-S-T-via-X` where Q-R-S-T is the ipv4 address and X is the site id, e.g.: `172-16-0-1-via-1`.
2 changes: 1 addition & 1 deletion tailscale/get_tskey.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
if __name__ == "__main__":
command = sys.argv[1]

if command in ["tskey", "tsversion"]:
if command in ["tskey", "tsversion", "tsserver"]:
try:
value = get_appdata(command)
if value:
Expand Down
2 changes: 1 addition & 1 deletion tailscale/package.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tailscale]
uuid = d4c47aa5-4409-4edf-bf1a-550182ad70a1
uuid = 9faa8914-d556-4c82-aec6-d536767d836f
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the uuid is changed, this could affect uploading new versions to NCM correctly. Also, please increment the patch version

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies if I misread the docs- was updating the UUID unnecessary?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes for the sample code, do not change the UUID. When building locally you can distinguish that SDK apps are different by changing the UUID as mentioned in the docs. However, for this repo, since we are building the apps for the "Built Apps" page we want to keep the UUIDs consistent to prevent version mismatch issues.

Moreover, for every change to the sample code, the version should be incremented to also prevent version mismatch issues.

vendor = Cradlepoint
notes = tailscale
version_major = 0
Expand Down
17 changes: 15 additions & 2 deletions tailscale/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -o pipefail
set -o errexit

logger -s -t tailscale -p 6 "tailscale istarting up..."
logger -s -t tailscale -p 6 "tailscale is starting up..."

logerr() {
if [ "$#" -gt 0 ]; then
Expand All @@ -21,6 +21,10 @@ get_tsroutes() {
tsroutes="$(cppython ./get_tskey.py tsroutes)"
}

get_tsserver() {
tsserver="$(cppython ./get_tskey.py tsserver)"
}

get_tsarch() {
arch="$(uname -m)"
if [ "$arch" = "armv7l" ]; then
Expand Down Expand Up @@ -49,10 +53,12 @@ tskey=""
tskey_ec=0
tsroutes=""
tsarch="arm64"
tsserver=""

check_tskey
get_tsroutes
get_tsarch
get_tsserver
download

tsdbinary="tailscaled_$tsarch"
Expand All @@ -77,6 +83,8 @@ check_tskey_change() {
check_tskey
prev_tsroutes=$tsroutes
get_tsroutes
prev_tsserver=$tsserver
get_tsserver

if [ $tskey_ec -ne 0 ] || [ -z "$tskey" ]; then
logerr "Couldn't get tskey. Exiting..."
Expand All @@ -92,13 +100,18 @@ check_tskey_change() {
logerr "tsroutes has changed. Exiting..."
exit_safely
fi

if [ "$tsserver" != "$prev_tsserver" ]; then
logerr "tsserver has changed. Exiting..."
exit_safely
fi
}

trap exit_safely SIGINT SIGTERM EXIT

HOME=$(pwd) ./${tsdbinary} --socket=./tailscaled.sock --tun=userspace-networking --socks5-server=localhost:1055 2>&1 | logerr &
sleep 2
HOME=$(pwd) ./${tsbinary} --socket ./tailscaled.sock up --auth-key="$tskey" --advertise-routes="$tsroutes" 2>&1 | logerr
HOME=$(pwd) ./${tsbinary} --socket ./tailscaled.sock up --auth-key="$tskey" --login-server="$tsserver" --advertise-routes="$tsroutes" 2>&1 | logerr

tsretcode=$?
if [ $tsretcode -ne 0 ]; then
Expand Down