Sha256: 76f9e36d2d49fbc376ee77ace77272e36998500f6cf88eeb6cdea5fde9de8ac7

Contents?: true

Size: 1.64 KB

Versions: 3

Compression:

Stored size: 1.64 KB

Contents

#!/usr/bin/env ruby

require "goliath/runner"
require "phantom_proxy"
require 'optparse'

module PhantomProxy
  def self.load_config
    options = {}
    optparse = OptionParser.new do|opts|
      opts.banner = "Usage: "
      opts.on( '-l [FILE]', '--logfile [FILE]', 'Write log to FILE' ) do |file|
        # PhantomProxy2.logger = Logger.new(file)
        options[:log_file] = file
      end
      opts.on('--hmac [STRING]', 'Use a hmac key to secure the connection' ) do |hmac|
        # PhantomProxy2.hmac_key = hmac
        options[:hmac_key] = hmac
      end
    end
    args = ARGV.dup
    remaining = []
    while !args.empty?
      begin
        head = args.shift
        remaining.concat(optparse.parse([head, args].flatten))
      rescue OptionParser::InvalidOption
        remaining << head
        retry
      end
    end
    PhantomProxy.logger    = Logger.new(options[:log_file]) if options[:log_file]
    PhantomProxy.hmac_key  = options[:hmac_key] if options[:hmac_key] && options[:hmac_key] != "none"
    remaining
  end
  def self.run_phantom_proxy(args)
    puts "Run with #{args}"
    runner = Goliath::Runner.new(args, nil)
    runner.logger=PhantomProxy.logger
    runner.port = PhantomProxy.port if PhantomProxy.respond_to?(:port)
    runner.address = PhantomProxy.address if PhantomProxy.respond_to?(:address)

    Goliath.env = PhantomProxy.env if PhantomProxy.respond_to?(:env)

    runner.api = PhantomProxy::Service.new
    runner.app = Goliath::Rack::Builder.build(PhantomProxy::Service, runner.api)

    puts "Now starting PhantomProxy #{PhantomProxy::VERSION}...."
    runner.run
  end
end

PhantomProxy.run_phantom_proxy PhantomProxy.load_config

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
phantom_proxy-1.3.6 bin/phantom_proxy
phantom_proxy-1.3.5 bin/phantom_proxy
phantom_proxy-1.3.3 bin/phantom_proxy