module LapisLazuli::WorldModule::Proxy

Module managing a proxy instance

Public Instance Methods

has_proxy?() click to toggle source

Checks if there is a proxy started

# File lib/lapis_lazuli/world/proxy.rb, line 25
def has_proxy?
  proxy = Runtime.instance.get :proxy
  return !proxy.nil?
end
proxy() click to toggle source

Get the current proxy

# File lib/lapis_lazuli/world/proxy.rb, line 32
def proxy
  return Runtime.instance.set_if(self, :proxy) do
    # Check if we can start a proxy
    begin
      # Default proxy settings
      proxy_ip = "localhost"
      proxy_port = 10000
      proxy_master = true

      # Do we have a config?
      if has_env_or_config?("proxy.ip") and has_env_or_config?("proxy.port")
        proxy_ip = env_or_config("proxy.ip")
        proxy_port = env_or_config("proxy.port")
        proxy_master = env_or_config("proxy.spritecloud", true)
      end

      # Try to start the proxy
      proxy = LapisLazuli::Proxy.new(proxy_ip, proxy_port, proxy_master)

      log.debug("Found proxy: #{proxy_ip}:#{proxy_port}, spritecloud: #{proxy_master}")
    rescue StandardError => err
      log.debug("No proxy available: #{err}")
    end
  end
end