Sha256: 2b1c6fca3362d6a368ba95a7805e85cc2b6c61d74e4f8811b609e9c4c0494ed4

Contents?: true

Size: 825 Bytes

Versions: 1

Compression:

Stored size: 825 Bytes

Contents

require 'singleton'

module Msf
  module Aggregator
    class Router
      include Singleton

      def initialize
        @mutex = Mutex.new
        @forward_routes = {}
      end

      def add_route(rhost, rport, payload)
        forward = [rhost, rport]
        @mutex.synchronize do
          if payload.nil?
            @forward_routes['default'] = forward
            return
          end
          @forward_routes[payload] = forward
        end
      end

      def remove_route(payload)
        unless payload.nil?
          @mutex.synchronize do
            @forward_routes.delete(payload)
          end
        end
      end

      def get_forward(uri)
        unless @forward_routes[uri].nil?
          @forward_routes[uri]
        else
          @forward_routes['default']
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
metasploit-aggregator-0.1.0 lib/msf/aggregator/router.rb