diff --git a/local/bin/cb-uri-tailscale b/local/bin/cb-uri-tailscale new file mode 100755 index 0000000..6cf9434 --- /dev/null +++ b/local/bin/cb-uri-tailscale @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +import subprocess +import sys +import urllib.parse + + +def main(sysargs=sys.argv[:]): + cb_uri = subprocess.check_output(["cb", "uri", *sysargs[1:]], text=True) + + parsed_cb_uri = urllib.parse.urlsplit(cb_uri) + tailscale_cb_uri = parsed_cb_uri._replace( + netloc=str(parsed_cb_uri.username) + + ":" + + str(parsed_cb_uri.password) + + "@" + + str(parsed_cb_uri.hostname).split(".")[1] + + ":" + + str(parsed_cb_uri.port) + ) + + print(tailscale_cb_uri.geturl()) + + return 0 + + +if __name__ == "__main__": + sys.exit(main())