Module: LapisLazuli::WorldModule::Proxy

Includes:
Config, Logging
Included in:
Browser
Defined in:
lib/lapis_lazuli/world/proxy.rb

Overview

Module managing a proxy instance

Instance Method Summary collapse

Methods included from Logging

#log

Methods included from Config

#add_config_from_file, #config, #current_env, #env, #env_or_config, #get_config_from_file, #has_config?, #has_env?, #has_env_or_config?, #init, #load_config, #metadata, #var_from_env

Methods included from Config::ClassMethods

#add_config, #config_file, #config_file=, #config_files

Instance Method Details

#has_proxy?Boolean

Checks if there is a proxy started

Returns:

  • (Boolean)


25
26
27
28
# File 'lib/lapis_lazuli/world/proxy.rb', line 25

def has_proxy?
  proxy = Runtime.instance.get :proxy
  return !proxy.nil?
end

#proxyObject

Get the current proxy



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# 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