lib/metasploit/aggregator/connection_manager.rb in metasploit-aggregator-0.2.1 vs lib/metasploit/aggregator/connection_manager.rb in metasploit-aggregator-0.2.2
- old
+ new
@@ -16,10 +16,11 @@
def initialize
@cables = []
@manager_mutex = Mutex.new
@router = Router.instance
@details_cache = SessionDetailService.instance
+ @connection_cleaner = Thread.new { flush_connections }
end
def self.ssl_generate_certificate
yr = 24*3600*365
vf = Time.at(Time.now.to_i - rand(yr * 3) - yr)
@@ -180,14 +181,25 @@
@cables.each do |listener|
listener.server.close
listener.thread.exit
end
end
+ @connection_cleaner.exit
end
def park(payload)
@router.add_route(nil, payload)
Logger.log "parking #{payload}"
+ end
+
+ def flush_connections
+ while true
+ @cables.each do |cable|
+ # this relies on a side effect that accessing clears stale connections
+ cable.forwarder.connections.length
+ end
+ sleep 10
+ end
end
private :ssl_parse_certificate
end
end