class Girl::Proxyd
Public Class Methods
new( config_path = nil )
click to toggle source
# File lib/girl/proxyd.rb, line 27 def initialize( config_path = nil ) if config_path then raise "not found config file #{ config_path }" unless File.exist?( config_path ) conf = JSON.parse( IO.binread( config_path ), symbolize_names: true ) proxyd_port = conf[ :proxyd_port ] infod_port = conf[ :infod_port ] end unless proxyd_port then proxyd_port = 6060 end unless infod_port then infod_port = 6070 end text = IO.read( '/etc/resolv.conf' ) match_data = /^nameserver .*\n/.match( text ) nameserver = match_data ? match_data.to_a.first.split(' ')[ 1 ].strip : '8.8.8.8' puts "girl proxyd #{ Girl::VERSION }" puts "proxyd #{ proxyd_port } infod #{ infod_port } nameserver #{ nameserver }" worker = Girl::ProxydWorker.new( proxyd_port, infod_port, nameserver ) Signal.trap( :TERM ) do puts 'exit' worker.quit! end worker.looping end