class Panopticon::Daemon

Constants

DEFAULT_API_PORT
DEFAULT_CAPTURE_PATH
DEFAULT_CONFIG_PATH
DEFAULT_IFNAME
DEFAULT_LOG_FILE

Public Class Methods

default_options() click to toggle source
# File lib/panopticon/command/panopticond.rb, line 14
def self.default_options
  {
    # config file (exclusive)
    :config_file => DEFAULT_CONFIG_PATH,

    # daemon parameters
    :port => DEFAULT_API_PORT,

    # capture parameters
    :ifname => DEFAULT_IFNAME,
    :capture_path => DEFAULT_CAPTURE_PATH,

    # log
    :log_file => DEFAULT_LOG_FILE,
  }
end
new(arg={}) click to toggle source
# File lib/panopticon/command/panopticond.rb, line 31
def initialize arg={}
  @arg = arg

  @config_file = arg[:config_file]

  @arg = read_config(@config_file)
end

Public Instance Methods

read_config(path) click to toggle source
# File lib/panopticon/command/panopticond.rb, line 44
def read_config path
  data = File.read(path)
  conf = JSON.parse(data, :symbolize_names => true)
  @arg = @arg.merge(conf)
  return @arg
end
run() click to toggle source
# File lib/panopticon/command/panopticond.rb, line 39
def run
  $log = Log.new(:output => @arg[:log_file])
  Panopticon::APIServer.run!(@arg)
end