Module: Tsclient
- Defined in:
- lib/tsclient.rb,
lib/tsclient/client.rb,
lib/tsclient/result.rb,
lib/tsclient/profile.rb,
lib/tsclient/version.rb
Defined Under Namespace
Classes: Client, Profile, Result
Constant Summary collapse
- VERSION =
"0.1.1"
Class Method Summary collapse
Class Method Details
.default_client ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/tsclient.rb', line 6 def self.default_client return @default_client if defined?(@default_client) # Attempt to setup the default client from various known strategies # Envariables override everything uri = if ENV.key?("TS_LOCALAPI_PORT") URI("http://:#{ENV["TS_LOCALAPI_KEY"]}@localhost:#{ENV["TS_LOCALAPI_PORT"]}") # Running on macOS, need to find api deets from filesystem elsif RUBY_PLATFORM["darwin"] 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}") # Throw our hands in the air, we just don't ~~care~~ know else raise NotImplemented, "Can't figure out where localapi is" end @default_client = Client.new(uri: uri) end |