Module: Lich::Main::BindAddressOption

Defined in:
documented/main/bind_address_option.rb

Overview

Applies keyword resolution to the parsed --bind-address value, giving it the same host vocabulary as --detachable-client / --headless: tailscale, lan, any, an IP address, or a hostname.

Resolution happens once at startup, so every listener Lich opens (the frontend socket, the --game proxy, and a detachable client that inherits the bind address) binds the same concrete address -- and a keyword failure (say, Tailscale not running) is reported before any socket work begins.

Since:

  • 5.19.2

Defined Under Namespace

Classes: Result

Class Method Summary collapse

Class Method Details

.apply(token, resolver: Lich::Common::BindHostResolver) ⇒ Result

Resolves the raw --bind-address token.

Parameters:

  • token (String, nil)

    the parsed flag value, or nil when absent

  • resolver (#resolve) (defaults to: Lich::Common::BindHostResolver)

    injectable for tests

Returns:

Since:

  • 5.19.2



32
33
34
35
36
37
38
39
# File 'documented/main/bind_address_option.rb', line 32

def self.apply(token, resolver: Lich::Common::BindHostResolver)
  return Result.new if token.nil?

  resolution = resolver.resolve(token)
  Result.new(host: resolution.host, warning: resolution.warning)
rescue Lich::Common::BindHostResolver::Error => e
  Result.new(error: e.message)
end