mirror of
https://github.com/clearml/clearml-session
synced 2025-01-31 02:46:56 +00:00
✨ Added tailscale support
This commit is contained in:
parent
39df1c1735
commit
39c5976a57
@ -562,6 +562,7 @@ def clone_task(state, project_id=None):
|
||||
task_params["{}/vscode_version".format(section)] = state.get('vscode_version') or ''
|
||||
task_params["{}/vscode_extensions".format(section)] = state.get('vscode_extensions') or ''
|
||||
task_params["{}/force_dropbear".format(section)] = bool(state.get('force_dropbear'))
|
||||
task_params["{}/tailscale".format(section)] = bool(state.get('tailscale'))
|
||||
if state.get('user_folder'):
|
||||
task_params['{}/user_base_directory'.format(section)] = state.get('user_folder')
|
||||
docker = state.get('docker') or task.get_base_docker()
|
||||
@ -1087,6 +1088,9 @@ def setup_parser(parser):
|
||||
action='store_true', default=False,
|
||||
help='Automatic yes to prompts; assume \"yes\" as answer '
|
||||
'to all prompts and run non-interactively',)
|
||||
parser.add_argument('--tailscale',
|
||||
action='store_true', default=False,
|
||||
help='Use tailscale to network (host and client need tailscale access)',)
|
||||
|
||||
|
||||
def get_version():
|
||||
|
@ -1,4 +1,5 @@
|
||||
import base64
|
||||
import ipaddress
|
||||
import json
|
||||
import os
|
||||
import socket
|
||||
@ -910,6 +911,33 @@ def setup_user_env(param, task):
|
||||
|
||||
|
||||
def get_host_name(task, param):
|
||||
hostname = []
|
||||
hostnames = []
|
||||
|
||||
|
||||
if task.get_parameter(name='interactive_session/tailscale'):
|
||||
def get_tailscale_interfaces():
|
||||
interfaces = psutil.net_if_addrs()
|
||||
tailscale_address = None
|
||||
for interface_name, interface_addresses in interfaces.items():
|
||||
for address in interface_addresses:
|
||||
if "tailscale" in interface_name:
|
||||
print(address)
|
||||
try:
|
||||
ipaddress.IPv4Address(address.address)
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
tailscale_address = address.address
|
||||
return tailscale_address
|
||||
|
||||
tl_addr = get_tailscale_interfaces()
|
||||
if tl_addr:
|
||||
hostname = tl_addr
|
||||
hostnames = tl_addr
|
||||
task.set_parameter(name='properties/external_address', value=str(tl_addr))
|
||||
return hostname, hostnames
|
||||
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
hostname = socket.gethostname()
|
||||
@ -1014,6 +1042,7 @@ def main():
|
||||
"public_ip": False,
|
||||
"ssh_ports": None,
|
||||
"force_dropbear": False,
|
||||
"tailscale": False
|
||||
}
|
||||
task = init_task(param, default_ssh_fingerprint)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user