Sha256: eb2dd962520bce2c78be1effa5f5869711949ab1796dc3b8897a79d42a23affd
Contents?: true
Size: 931 Bytes
Versions: 2
Compression:
Stored size: 931 Bytes
Contents
# frozen_string_literal: true require_relative "tsclient/client" module Tsclient 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 end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tsclient-0.1.1 | lib/tsclient.rb |
tsclient-0.1.0 | lib/tsclient.rb |