Files
metasploit-gs/lib/msf/core/db_manager/adapter.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

49 lines
1023 B
Ruby
Raw Normal View History

2014-10-13 14:49:26 -05:00
module Msf::DBManager::Adapter
#
# CONSTANTS
#
# The adapter to use to establish database connection.
ADAPTER = 'postgresql'
#
# Attributes
#
# Returns the list of usable database drivers
def drivers
@drivers ||= []
end
attr_writer :drivers
# Returns the active driver
attr_accessor :driver
#
# Instance Methods
#
#
# Scan through available drivers
#
def initialize_adapter
2022-11-02 17:28:23 -05:00
ActiveRecord.default_timezone = :utc
2014-10-13 14:49:26 -05:00
2021-05-18 15:05:13 -05:00
if connection_established? && ApplicationRecord.connection_db_config.configuration_hash[:adapter] == ADAPTER
2014-10-13 14:49:26 -05:00
dlog("Already established connection to #{ADAPTER}, so reusing active connection.")
self.drivers << ADAPTER
self.driver = ADAPTER
else
begin
ApplicationRecord.establish_connection(adapter: ADAPTER)
ApplicationRecord.remove_connection
2014-10-13 14:49:26 -05:00
rescue Exception => error
@adapter_error = error
else
self.drivers << ADAPTER
self.driver = ADAPTER
end
end
end
end