Add script to combine cb uri
with URL munging to access via tailscale
This commit is contained in:
parent
950d1a928e
commit
39c2f883e7
27
local/bin/cb-uri-tailscale
Executable file
27
local/bin/cb-uri-tailscale
Executable file
@ -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())
|
Loading…
Reference in New Issue
Block a user