Module: Msf::DBManager::Adapter
- Included in:
- Msf::DBManager
- Defined in:
- lib/msf/core/db_manager/adapter.rb
Constant Summary collapse
- ADAPTER =
The adapter to use to establish database connection.
'postgresql'
Instance Attribute Summary collapse
-
#driver ⇒ Object
Returns the active driver.
-
#drivers ⇒ Object
Returns the list of usable database drivers.
Instance Method Summary collapse
-
#initialize_adapter ⇒ Object
Scan through available drivers.
Instance Attribute Details
#driver ⇒ Object
Returns the active driver
20 21 22 |
# File 'lib/msf/core/db_manager/adapter.rb', line 20 def driver @driver end |
#drivers ⇒ Object
Returns the list of usable database drivers
14 15 16 |
# File 'lib/msf/core/db_manager/adapter.rb', line 14 def drivers @drivers ||= [] end |
Instance Method Details
#initialize_adapter ⇒ Object
Scan through available drivers
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/msf/core/db_manager/adapter.rb', line 29 def initialize_adapter ActiveRecord.default_timezone = :utc if connection_established? && ApplicationRecord.connection_db_config.configuration_hash[:adapter] == ADAPTER 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 rescue Exception => error @adapter_error = error else self.drivers << ADAPTER self.driver = ADAPTER end end end |