9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/tsclient/api_finder.rb', line 9
def call(env: ENV, ruby_platform: RUBY_PLATFORM)
os = find_os(ruby_platform)
if env.key?("TSCLIENT_API_URI")
URI(env.fetch("TSCLIENT_API_URI"))
elsif os == "linux"
URI("unix://#{DEFAULT_SOCKET_PATH}") if File.exist?(DEFAULT_SOCKET_PATH)
elsif os == "macos"
if (tsfile = Pathname.glob("#{env["HOME"]}/Library/Group Containers/*.io.tailscale.ipn.macos/sameuserproof-*-*").first)
_, port, password = tsfile.basename.to_s.split("-", 3)
URI("http://:#{password}@localhost:#{port}")
end
elsif os == "windows"
raise NotImplementedError, "Windows not currently implemented"
end
end
|